Use underscores for emphasis in Markdown writer. #11198
-
Currently, when converting a I tried figuring out if this can be done with a filter, but from what I managed to find out, it can't, because filters work on the AST, where the actual representation of elements such as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The main reason is that underscores are more limited. (In many markdown dialects, intra-word underscores are not treated as emphasis.) Anyway, yes, you can do it with a filter. It's not terribly hard. Here is one approach: function Emph(el)
if FORMAT == "markdown" then
local underscore = pandoc.RawInline("markdown", "_")
return ({underscore} .. el.content .. {underscore})
end
end
function Strong(el)
if FORMAT == "markdown" then
local doubleunderscore = pandoc.RawInline("markdown", "__")
return ({doubleunderscore} .. el.content .. {doubleunderscore})
end
end |
Beta Was this translation helpful? Give feedback.
The main reason is that underscores are more limited. (In many markdown dialects, intra-word underscores are not treated as emphasis.)
Anyway, yes, you can do it with a filter. It's not terribly hard. Here is one approach: