Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier access to parsed headers #335

Closed
pacak opened this issue Aug 20, 2023 · 1 comment
Closed

Easier access to parsed headers #335

pacak opened this issue Aug 20, 2023 · 1 comment

Comments

@pacak
Copy link

pacak commented Aug 20, 2023

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:

  1. use format_commonmark to render the whole node to a vector of bytes (allocates)
  2. use String::from_utf8 to get back a string (contains unwrap/expect that should never fire but it's still there)
  3. trim # and \n and convert to owned string (allocates again)

Ideally I would like to be able to access content field directly.

@kivikakk
Copy link
Owner

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).

@kivikakk kivikakk closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants