Closed tlienart closed 3 years ago
Hey,
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
Thanks for the quick response! I think this does the job just fine :)
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!