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

Support for Classes on All Tag Types #984

Open
aretrosen opened this issue Nov 14, 2024 · 0 comments
Open

Support for Classes on All Tag Types #984

aretrosen opened this issue Nov 14, 2024 · 0 comments

Comments

@aretrosen
Copy link

Can we add classes to tags other than Heading? I couldn't find a solution for this. It might be useful to do so in cases like adding dir=auto to the classes of Tag::Paragraph or Tag::List. I might be missing a better approach.

Currently, I am achieving this for Tag::Heading using the following code:

let parser = Parser::new_ext(markdown_input, options).map(|event| match event {
    Event::Start(mut tag) => {
        if let Tag::Heading { classes, .. } = &mut tag {
            classes.push("dir=auto".into());
        }
        Event::Start(tag)
    }
    _ => event,
});

Can we do this in other ways that I might not be aware of, which might be applicable to Tag::Paragraph and others too?

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

1 participant