Skip to content

Commit

Permalink
feat: Add link attributes support to direct links in lunamark
Browse files Browse the repository at this point in the history
Not a definitive implementation, but allows progressing on
the SILE writer and package support side.
  • Loading branch information
Omikhleia authored and Didier Willis committed Dec 31, 2022
1 parent 85623d6 commit 8a15a6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
26 changes: 19 additions & 7 deletions lua-libraries/lunamark/reader/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1225,13 +1225,25 @@ function M.new(writer, options)
return writer.link(writer.string(email),"mailto:"..email)
end

larsers.DirectLink = (parsers.tag / parse_inlines_no_link) -- no links inside links
* parsers.spnl
* parsers.lparent
* (parsers.url + Cc("")) -- link can be empty [foo]()
* parsers.optionaltitle
* parsers.rparent
/ writer.link
if options.link_attributes then
-- Support additional attributes
larsers.DirectLink = (parsers.tag / parse_inlines_no_link) -- no links inside links
* parsers.spnl
* parsers.lparent
* (parsers.url + Cc("")) -- link can be empty [foo]()
* parsers.optionaltitle
* parsers.rparent
* (parsers.attributes + Ct(""))
/ writer.link
else
larsers.DirectLink = (parsers.tag / parse_inlines_no_link) -- no links inside links
* parsers.spnl
* parsers.lparent
* (parsers.url + Cc("")) -- link can be empty [foo]()
* parsers.optionaltitle
* parsers.rparent
/ writer.link
end

larsers.IndirectLink = parsers.tag * (C(parsers.spnl) * parsers.tag)^-1
/ indirect_link
Expand Down
3 changes: 2 additions & 1 deletion lua-libraries/lunamark/writer/generic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ function M.new(options)
end

--- A link with link text `label`, uri `uri`,
-- and title `title`.
-- and title `title`,
-- additional attributes `attr`
function W.link(label)
return label
end
Expand Down

0 comments on commit 8a15a6f

Please sign in to comment.