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

Make a custom Syntax #525

Open
logneh4 opened this issue Mar 24, 2023 · 2 comments
Open

Make a custom Syntax #525

logneh4 opened this issue Mar 24, 2023 · 2 comments

Comments

@logneh4
Copy link

logneh4 commented Mar 24, 2023

I'm trying to make a custom custom syntax and transform: --!text *strong* text!-- text and elements between --! and !--. I've tried using the DelimiterSyntax class to achieve this, but I'm having trouble getting it to work as expected. Its work only when start and end is the same.

@chenzhiguang
Copy link
Contributor

You are re right. The DelimiterSyntax only works when the start and end delimiters are the same. For this syntax, you need to create a syntax that extends from InlineSyntax.

@logneh4
Copy link
Author

logneh4 commented Mar 24, 2023

You are re right. The DelimiterSyntax only works when the start and end delimiters are the same. For this syntax, you need to create a syntax that extends from InlineSyntax.

I found the start and end positions of my custom syntax in the onMatch method, and I'm creating an Element and adding a Text element inside it with the content between the start and end positions. However, this approach doesn't parse and format other Markdown elements (such as test for emphasis) inside the custom syntax.

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