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
I'm trying to use comrak as a markdown parser and transformer and current goal is to extract headers along with their levels.
Finding headers is easy - pattern matching on values and taking NodeValue::Heading(_). Extracting the text is not. Header contents are stored in a private field content and to access it I have to do something like:
use format_commonmark to render the whole node to a vector of bytes (allocates)
use String::from_utf8 to get back a string (contains unwrap/expect that should never fire but it's still there)
trim # and \n and convert to owned string (allocates again)
Ideally I would like to be able to access content field directly.
The text was updated successfully, but these errors were encountered:
Header contents are not, strictly speaking, stored in a private field content. The field is private precisely because it is not a sensible user-facing value. See the last time this came up: #175 (comment).
I'm trying to use
comrak
as a markdown parser and transformer and current goal is to extract headers along with their levels.Finding headers is easy - pattern matching on values and taking
NodeValue::Heading(_)
. Extracting the text is not. Header contents are stored in a private fieldcontent
and to access it I have to do something like:format_commonmark
to render the whole node to a vector of bytes (allocates)String::from_utf8
to get back a string (contains unwrap/expect that should never fire but it's still there)#
and\n
and convert to owned string (allocates again)Ideally I would like to be able to access
content
field directly.The text was updated successfully, but these errors were encountered: