обычный html в уценке Юлии - PullRequest
1 голос
/ 19 апреля 2020

В стандартной библиотеке Julia есть модуль Markdown. Однако в документации не указано, как включить простой html в эту уценку. Например,

using Markdown
a = Markdown.parse("This is *important* text with <i>html</i> in it");
# parsed as
Markdown.Paragraph(Any["This is ", Markdown.Italic(Any["important"]), " text with <i>html</i> in it"])
# then exporting to html
Markdown.html(a)
# output below
"<p>This is <em>important</em> text with &lt;i&gt;html&lt;/i&gt; in it</p>\n"

Мы видим, что html был экранирован (на этапе экспорта). Вывод, который я хотел бы получить:

"<p>This is <em>important</em> text with <i>html</i> in it</p>"

Как мне этого добиться?

1 Ответ

0 голосов
/ 19 апреля 2020

Обходной путь , просто перезапишите функцию синтаксического анализа html, чтобы сделать то, что вам нужно:

julia> using Markdown

julia> Markdown.htmlesc(io::IO, s::AbstractString) = print(io,s)

julia> a = Markdown.parse("This is *important* text with <i>html</i> in it");

julia> Markdown.html(a)
"<p>This is <em>important</em> text with <i>html</i> in it</p>\n"
...