Skip to content

Commit

Permalink
Added lua script from pandoc discussion to convert links to new tab i…
Browse files Browse the repository at this point in the history
…n html
  • Loading branch information
nitrocode committed Apr 14, 2018
1 parent 2260bc1 commit 3029057
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ html: init
FILE_NAME=`basename $$f | sed 's/.md//g'`; \
echo $$FILE_NAME.html; \
pandoc --standalone --include-in-header $(STYLES_DIR)/$(STYLE).css \
--lua-filter=pdc-links-target-blank.lua \
--from markdown --to html \
--output $(OUT_DIR)/$$FILE_NAME.html $$f; \
done
Expand Down
15 changes: 15 additions & 0 deletions pdc-links-target-blank.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Add target="_blank" attributes to all http links in a Pandoc document

local function add_target_blank (link)
if string.match(link.target, '^http') then -- here .target == href attribute
link.attributes.target = '_blank' -- here .target == traget attribute
end
return link
end

-- remove lines 4 and 6 to add target="_blank" to all links, not just http(s)

return {
{ Link = add_target_blank }
}

0 comments on commit 3029057

Please sign in to comment.