markdown icon indicating copy to clipboard operation
markdown copied to clipboard

Make a custom Syntax

Open logneh4 opened this issue 2 years ago • 2 comments

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.

logneh4 avatar Mar 24 '23 00:03 logneh4

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.

chenzhiguang avatar Mar 24 '23 04:03 chenzhiguang

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.

logneh4 avatar Mar 24 '23 16:03 logneh4