How to get the raw text after converting?
sulunemre opened this issue · comments
Emre Sülün commented
Hey, I am trying to parse a Markdown string as a raw text. For example: ## A title
should be A title
.
I've tried:
from marko.ext.gfm import gfm
element = gfm.parse("## A title").children[0]
gfm.render(element)
But, it returns '<h2>A title</h2>\n'
and I am not interested in HTML tags but only the text.
My first thought was using Beautiful Soup for parsing the output HTML but it is probably an overkill. Is there a better way?
Thanks!
Frost Ming commented
gfm.parse("## A title").children[0]
is a Heading element.
Get the raw text by gfm.parse("## A title").children[0].children[0].children