You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the context of dealing with RSS (not the most fun thing to figure out), it'd be useful to have a way to go from "markdown" to "plaintext". The reason is that in RSS the <description> field, if given along with a <content:encoded> one, should be plain text (no markup). You can write <[CDATA... stuff but in theory you shouldn't, the encoding should go in the content encoded.
As a result the useful thing to have is a way for people to write:
+++
abstract = "This is a description of the blog post with **markup** and [links](https://juliacon.org)"
+++
{{insert abstract}}
... Rest of the blog post ...
and have the {{insert abstract}} do two things:
insert the markup-ed text in the blog post as standard, where it would eventually be converted to HTML (standard path MD -> X)
add an RSS item entry where the <description> gets plaintext(abstract), in the above case:
This is a description of the blog post with markup and links.
so that would use a "reverse" path: MD -> text. Is that doable easily with common mark?
Thanks!
The text was updated successfully, but these errors were encountered:
Kind of depends on how feature complete you'd want the plaintext to be I guess. Something like the following already does an alright job of downgrading to plaintext:
julia> using CommonMark
julia> ast = cm"This is a description of the blog post with **markup** and [links](https://juliacon.org)";
julia> function plaintext(io, ast)
for (node, enter) in ast
isa(node.t, CommonMark.Text) && print(io, node.literal)
end
end
plaintext (generic function with 1 method)
julia> plaintext(stdout, ast)
This is a description of the blog post with markup and links
Hello Mike,
In the context of dealing with RSS (not the most fun thing to figure out), it'd be useful to have a way to go from "markdown" to "plaintext". The reason is that in RSS the
<description>
field, if given along with a<content:encoded>
one, should be plain text (no markup). You can write<[CDATA...
stuff but in theory you shouldn't, the encoding should go in the content encoded.As a result the useful thing to have is a way for people to write:
and have the
{{insert abstract}}
do two things:<description>
getsplaintext(abstract)
, in the above case:so that would use a "reverse" path: MD -> text. Is that doable easily with common mark?
Thanks!
The text was updated successfully, but these errors were encountered: