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

Add text generation via text feature. #801

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

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.

None yet

2 participants