Repository navigation
Add spoiler span extension - #308
Conversation
Made-with: Cursor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #308 +/- ##
==========================================
+ Coverage 78.82% 78.94% +0.12%
==========================================
Files 5 5
Lines 3367 3401 +34
Branches 1121 1138 +17
==========================================
+ Hits 2654 2685 +31
+ Misses 276 275 -1
- Partials 437 441 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hmm, there seems to be something broken, as per the fuzzing action report. I was able to reproduce locally:
I'm getting an assertion, which I'm unable to reproduce on master branch and/or without the |
|
Minimized the testcase into this: Probably some stupid interaction between the table and spoiler parsing but I don't have time now to dig into it. |
Made-with: Cursor
@mity thanks for the minimized testcase. You were right, this was an interaction between table cell boundary detection and spoiler parsing. I updated the parser so that table boundary scanning only treats unresolved single I added your minimized case to |
mity
left a comment
There was a problem hiding this comment.
The code looks good to me, there are just few formal details.
| { 0, "fpermissive-email-autolinks", '@', 0 }, | ||
| { 0, "fpermissive-url-autolinks", 'U', 0 }, | ||
| { 0, "fpermissive-www-autolinks", '.', 0 }, | ||
| { 0, "fspoiler", 'P', 0 }, |
There was a problem hiding this comment.
Please change the option to plural, --fspoilers. Sadly we're not entirely consistent, but the plural dominates.
| #define MD_FLAG_WIKILINKS 0x2000 /* Enable wiki links extension. */ | ||
| #define MD_FLAG_UNDERLINE 0x4000 /* Enable underline extension (and disables '_' for normal emphasis). */ | ||
| #define MD_FLAG_HARD_SOFT_BREAKS 0x8000 /* Force all soft breaks to act as hard breaks. */ | ||
| #define MD_FLAG_SPOILER 0x10000 /* Enable ||hidden text|| spoiler spans. */ |
|
|
||
| ## Interaction with other extensions | ||
|
|
||
| ### Wiki links (requires MD_FLAG_WIKILINKS) |
There was a problem hiding this comment.
Put the flag into a code span, `MD_FLAG_WIKILINKS`
| @@ -0,0 +1,419 @@ | |||
|
|
|||
There was a problem hiding this comment.
Also pls rename the file to spec-spoilers.txt.
@mity thank you for the review! I've addressed all your comments. |
Summary
This PR adds an opt-in spoiler span extension to MD4C.
The new syntax is:
||hidden text||
When
MD_FLAG_SPOILERis enabled, MD4C emits a newMD_SPAN_SPOILERspan. The bundled HTML renderer outputs spoilers as:<x-spoiler>hidden text</x-spoiler>md2htmlalso gets a new--fspoileroption.Motivation
We use MD4C in the react-native-enriched-markdown library, where spoiler spans are already supported.
Since spoilers are a common Markdown extension in messaging-style products, including Telegram and Discord, it would be useful to have first-class support in MD4C itself instead of maintaining this behavior only in downstream forks.
The extension is fully opt-in and does not change default CommonMark behavior.