8000 How to avoid delimiter conflict with other nodes? · Issue #371 · commonmark/commonmark-java · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to avoid delimiter conflict with other nodes? #371

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

Open
le-tyang opened this issue Mar 31, 2025 · 1 comment
Open

How to avoid delimiter conflict with other nodes? #371

le-tyang opened this issue Mar 31, 2025 · 1 comment

Comments

@le-tyang
Copy link

Background

We have a custom format for providing extra attributes to a piece of content.

Example format as

^[CONTENT](Attributes go here)

The reason behind using this format is because it is supported out-of-box from iOS which we do understand it is NOT part of commonmark.

After few attempts, we got there, like 90%.

Problem

We found out that when the content is in certain format, the parser takes Link parsing as higher priority and render it as

Image

content as

This is considered as a LINK somehow
 ^[NoAttributes]( 'u': 'underline' ) suffix

I believe this is cause by Link parse runs first?

Help needed

Would like to get some help on this issue to see either we can:

  1. Change priority of parsing
  2. Configure Link parser to ignore ^[]() format.

Any suggestion would be helpful.

Snippet

    class AttributesDelimiterProcessor: DelimiterProcessor {
        override fun getOpeningCharacter(): Char = '^'
        override fun getClosingCharacter(): Char = ')'
        override fun getMinLength(): Int = 1

        override fun process(
            openingRun: DelimiterRun?,
            closingRun: DelimiterRun?
        ): Int {
           // Seems like doesn't matter how you'd process it.
        }
    }
@nealhippo
Copy link

The class that may help LinkProcessor. As mentioned the markdown is being processed before it gets to the DelimiterProcessor.

You may be able to implement a LinkProcessor check the LinkInfo.marker() and see if the marker is a ^, you can then use LinkResult to ignore or move the logic from DelimiterProcessor and wrap or replace the node.

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
0