Reasonable OpeningCharacters for Extensions #720

Closed
opened 2026-01-29 14:43:51 +00:00 by claunia · 2 comments
Owner

Originally created by @rhjoerg on GitHub (Feb 2, 2025).

Introduction

I am currently working on some MarkDig extensions. Something like:

---
Author: "My Name"
Published: 2025-02-02
Summary: "Some summary"
---
<h1>Title</h1>
!frontmatter{Author, Published}

where !frontmatter{Author, Published} will insert a table showing the requested values. Still a long way to go.

The Question

What would be a reasonable OpeningCharacters for such extensions to not clash with other/existing extensions?.

  • An exclamation mark as shown above?
  • A question mark (unlikely)?
  • Some other weird character easily accessible on a keyboard (§, %, &)?
  • Some non-ascii character (greek or cyrillic alphabeth)?
Originally created by @rhjoerg on GitHub (Feb 2, 2025). ## Introduction I am currently working on some MarkDig extensions. Something like: ``` --- Author: "My Name" Published: 2025-02-02 Summary: "Some summary" --- <h1>Title</h1> !frontmatter{Author, Published} ``` where `!frontmatter{Author, Published}` will insert a table showing the requested values. Still a long way to go. ## The Question What would be a reasonable OpeningCharacters for such extensions to not clash with other/existing extensions?. - An exclamation mark as shown above? - A question mark (unlikely)? - Some other weird character easily accessible on a keyboard (§, %, &)? - Some non-ascii character (greek or cyrillic alphabeth)?
claunia added the question label 2026-01-29 14:43:51 +00:00
Author
Owner

@xoofx commented on GitHub (Feb 2, 2025):

What would be a reasonable OpeningCharacters for such extensions to not clash with other/existing extensions?.

The OpeningCharacters can clash with other existing extensions, as long as you match the following (e.g. frontmatter{ in your parser and discard if it is not matched.

OpeningCharacters is an optimization for the parser to quickly select which parser it might try instead of trying all of them.

See for example AlertInlineParser that is matching [ but then validating that it is e.g. [!NOTE] and discarding if not.

@xoofx commented on GitHub (Feb 2, 2025): > What would be a reasonable OpeningCharacters for such extensions to not clash with other/existing extensions?. The OpeningCharacters can clash with other existing extensions, as long as you match the following (e.g. `frontmatter{` in your parser and discard if it is not matched. `OpeningCharacters` is an optimization for the parser to quickly select which parser it might try instead of trying all of them. See for example [AlertInlineParser](https://github.com/xoofx/markdig/blob/master/src/Markdig/Extensions/Alerts/AlertInlineParser.cs) that is matching `[` but then validating that it is e.g. `[!NOTE]` and discarding if not.
Author
Owner

@rhjoerg commented on GitHub (Feb 3, 2025):

Thanks for your fast response.

@rhjoerg commented on GitHub (Feb 3, 2025): Thanks for your fast response.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#720