dart-lang / markdown

A Dart markdown library

Home Page:https://pub.dev/packages/markdown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make a custom Syntax

logneh4 opened this issue · 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.

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.

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.