pdc-links-target-blank.lua 431 B

123456789101112131415
  1. -- Add target="_blank" attributes to all http links in a Pandoc document
  2. local function add_target_blank (link)
  3. if string.match(link.target, '^http') then -- here .target == href attribute
  4. link.attributes.target = '_blank' -- here .target == traget attribute
  5. end
  6. return link
  7. end
  8. -- remove lines 4 and 6 to add target="_blank" to all links, not just http(s)
  9. return {
  10. { Link = add_target_blank }
  11. }