Skip to content

Commit 39ff504

Browse files
abap34artempyanykh
authored andcommitted
feat(parser): Enable Markdig Mathematics extension
1 parent eb43ccd commit 39ff504

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Marksman/Parser.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ module Markdown =
196196
MarkdownPipelineBuilder()
197197
.UsePreciseSourceLocation()
198198
.UseYamlFrontMatter()
199+
.UseMathematics()
199200

200201
pipelineBuilder.InlineParsers.Insert(0, MarkdigPatches.PatchedLinkInlineParser())
201202
pipelineBuilder.InlineParsers.Insert(0, WikiLinkParser())

Tests/ParserTests.fs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,36 @@ module RegressionTests =
465465
let content = "[][][]"
466466
let actual = scrapeString content
467467
checkInlineSnapshot actual []
468+
469+
module MathBlockTests =
470+
[<Fact>]
471+
let math_block_should_not_parse_wikilinks () =
472+
let content = """$$
473+
\begin{verbatim}
474+
[[nodiscard]]
475+
\end{verbatim}
476+
$$"""
477+
let actual = scrapeString content
478+
// Math block should not produce any wikilink elements
479+
checkInlineSnapshot actual []
480+
481+
[<Fact>]
482+
let inline_math_should_not_parse_wikilinks () =
483+
let content = "Inline math: $[[x]]$ in text"
484+
let actual = scrapeString content
485+
// Inline math should not produce any wikilink elements
486+
checkInlineSnapshot actual []
487+
488+
[<Fact>]
489+
let math_and_regular_wikilink () =
490+
let content = """$$
491+
[[in-math]]
492+
$$
493+
494+
Regular [[valid-link]]"""
495+
let actual = scrapeString content
496+
// Only the regular wikilink should be detected, not the one in math block
497+
checkInlineSnapshot actual [
498+
"WL: [[valid-link]]; (4,8)-(4,22)"
499+
" doc=valid-link; (4,10)-(4,20)"
500+
]

0 commit comments

Comments
 (0)