-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserving <i>, <b> and <cite> in non-HTML formats #6515
Comments
<i>
, <b>
and <cite>
in non-HTML formats
For HTML input this already works...
But you're talking about markdown input, or..?
true, there it's converted to raw HTML, which will only work for HTML output and be dropped otherwise... but why would you want to use HTML |
Yes, using a markdown source document to generate html and other output formats, including some custom lua ones. |
I'm way OK with another solution to create b and i and cite too. We've previously argued for having |
ah, you can write a lua filter to change the native |
What I want is the opposite; to write markdown that fits on all kinds of
markdown sites (that don't all use pandoc)—and I can do that with the
`<i>` and `<b>` most places—and then still have pandoc turn `<i>` into
italic or `<b>` into bold when I want to generate ConTeXt.
So I guess one workaround there is to preprocess it before I pass it to
pandoc.
Also I love markdown but this is such a weird part of the language.
|
haha, I don't get it. If you want to use portable markdown, just use |
If I write `_Taraxacum officinale_ grows from unbranched taproots` and
that gets turned into `<em>Taraxacum officinale</em> grows from
unbranched taproots`, that's wrong. It's not emphasis.
|
Ah, so this is a duplicate of #4297 ? |
It's another solution to the same problem!
|
If I understand correctly, then you want to write function Span (span)
if not span.classes:includes 'species' then
return nil
elseif FORMAT:match 'html' then
return {pandoc.RawInline('html', '<i>')} .. span.content .. {pandoc.RawInline('html', '</i>')}
else
return pandoc.Emph(span.content)
end
end (Untested) |
For completeness, here's a filter which allows using if FORMAT:match 'html' then
return {}
end
local List = require 'pandoc.List'
function is_italics_start(inln)
return inln.t == 'RawInline'
and inln.format:match 'html'
and inln.text:match '<i>'
end
function is_italics_end(inln)
return inln.t == 'RawInline'
and inln.format:match 'html'
and inln.text:match '</i>'
end
function Inlines (inlns)
local result = List()
local italics = nil
for _, inln in ipairs(inlns) do
if is_italics_start(inln) then
italics = List()
elseif is_italics_end(inln) then
result:insert(pandoc.Emph(italics))
italics = nil
elseif italics then
italics:insert(inln)
else
result:insert(inln)
end
end
return result
end Any additional discussions should happen on the pandoc-discuss mailing list. |
So the position seems to be that em and strong are OK for
*
and**
but then how about this idea, as per discussed on commonmark's issue tracker: that we can write<i>
,<cite>
and<b>
and have them be understood by pandoc (as an exception to most other HTML tags just being passed through or dropped) and turned to italics and bold in other formats, like ContTeXt and LaTeX?The text was updated successfully, but these errors were encountered: