Skip to content

Adding a matcher with the same name as an existing tag does not overwrite it. #7

@DingleFlop

Description

@DingleFlop

Howdy!

Today I tried adding a matcher using the example syntax:

let quote_emitter: EmitScope = Arc::new(|open_capture, body, _| {
    let cite_with_post_id = open_capture.unwrap().name("cite").unwrap().as_str();
    
    let (cite, post_id) = cite_with_post_id.split_once(';')
        .expect("String couldn't be parsed");

    format!(r#"<blockquote{cite_with_post_id}><span class="citation" data-post-id="{post_id}">Posted by {cite}</span>{body}</blockquote>"#)
});

BBCode::add_tagmatcher(&mut matchers, "quote", ScopeInfo::basic(quote_emitter), None, None)
    .expect("Failed to add matcher");

But unfortunately the default handler is always used.
Perhaps, on add_tagmatcher, replace any existing matchers with the exact same "target", rather than appending them to the end?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions