Skip to content

Commit

Permalink
Implement bracketed_spans syntax extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Nov 9, 2022
1 parent e2d1a2f commit afe1223
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -22691,11 +22691,34 @@ M.extensions = {}
%
% \end{markdown}
% \begin{macrocode}
M.extensions.bracketed_spans = function()
M.extensions.bracketed_spans = function(self)
return {
name = "built-in bracketed_spans syntax extension",
extend_writer = function()
end, extend_reader = function()
extend_writer = function(self)
% \end{macrocode}
% \par
% \begin{markdown}
%
% Define \luamdef{writer->span} as a function that will transform an input
% bracketed span `s` to the output format.
%
% \end{markdown}
% \begin{macrocode}
function self.span(s)
return {"\\markdownRendererBracketedSpan{",s,"}"}
end
end, extend_reader = function(self)
local parsers = self.parsers
local writer = self.writer

local Span = parsers.between(parsers.Inline,
parsers.lbracket,
parsers.rbracket)
* parsers.attributes
/ writer.span

self.insert_pattern("Inline after Emph",
Span, "Span")
end
}
end
Expand Down

0 comments on commit afe1223

Please sign in to comment.