8000 Add text generation via `text` feature. by trojanfoe · Pull Request #801 · pulldown-cmark/pulldown-cmark · GitHub
[go: up one dir, main page]

Skip to content

Conversation

trojanfoe
Copy link

This PR provides basic plain-text generation via a new text feature, which is disabled by default.

I added this as I needed to send e-mail content which is best sent as a multipart message containing both HTML and plain text and markdown seemed like the best format for this.

One issue with generating multiple strings from the same markdown input is that it's necessary to duplicate the parser as the iterator consumes the input:

let text_content = {
    let pulldown_parser = Parser::new(&markdown_content);
    let mut text_content = String::new();
    text::push_text(&mut text_content, pulldown_parser);
    text_content
};

let html_content = {
    let pulldown_parser = Parser::new(&markdown_content);
    let mut html_content = String::new();
    html::push_html(&mut html_content, pulldown_parser);
    html_content
};

@Martin1887
Copy link
Collaborator

Interesting, but I have to dig more into it before merging. What do you think about this feature, @raphlinus?

Thanks!

@trojanfoe
Copy link
Author
trojanfoe commented Jan 7, 2024

I will say it’s not particularly well implemented. It works for my use-case but it needs a decent review and probably more work. My use-case is for sending e-mail, which needs to be generated in both HTML and plain text and markdown is the ideal medium to use as the source of the e-mail content.

@rimutaka
Copy link
Contributor
rimutaka commented Jan 11, 2025

Additional use cases:

  • extracting the content to generate a summary
  • generating excerpts
  • supplying context to LLMs

I could make use of it right now if available.

@trojanfoe , I added a few comments in the code, but I may be off the mark there.
Would you like to open an issue to continue the discussion there?

Happy to help with this lot of work if the maintainers think it's worth adding to the library.

@Martin1887
Copy link
Collaborator

It could be useful, for sure. but we need a good implementation before merging.

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

Successfully merging this pull request may close these issues.

3 participants

0