1875 Commits

Author SHA1 Message Date
Yang Bai
6a410393ba Fix FindClosestBlock/FindBlockAtPosition with definition groups (#677) (#962)
LinkReferenceDefinitionGroup and FootnoteGroup are added to the document
by the parsers with Line 0 and a span starting at 0, at a position that
does not follow the source order (the footnote group is even moved to
the end of the document). The binary searches in FindClosestBlock and
FindBlockAtPosition expect children ordered by line/position, so they
could return the group, a definition, or the document itself instead
of the block at the requested line/position.

When a binary search on a document probes one of these groups, compare
the nearest other block within the search range instead, so the search
stays logarithmic and does not allocate. The definitions collected by
the groups are only considered when nothing else matches; the groups
are then taken from the document data (link reference definitions) and
from the last child of the document (footnotes) instead of scanning the
document.

Co-authored-by: ybai08 <271969568+ybai08@users.noreply.github.com>
1.4.2
2026-10-19 20:57:06 +02:00
Stefan Greve
55e9ec7a7a Add IsAotCompatible for net8.0 and later targets (#963)
* Add IsAotCompatible for net8.0 and later targets

* Enable the trim, AOT and single-file analyzers in Markdig's own build, so
  CI catches an AOT regression before it ships to consumers
* Limit the property to net8.0+, since the analyzers do not run on
  netstandard and net462 targets
* Test the assembly metadata, asserting IsAotCompatible only on net10.0,
  because the ILLink 8 build tasks used for net8.0 emit just IsTrimmable

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Fix test by verifying the AOT marking with an IL3058 build check

* Replace the assembly metadata unit tests, which failed in the netstandard
  workflow because it builds Markdig for netstandard2.x only
* Add Markdig.AotTests with VerifyReferenceAotCompatibility and IL3058 as an
  error, so the CI solution build fails if Markdig loses the AOT marking
* Leave PublishAot unset, so the check restores no package beyond the
  ILLink.Tasks package the IsAotCompatible property already requires

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 20:56:50 +02:00
Wahid Rizka Fathurrohman
f1381b61f3 Fix setext underlines in block quotes and list items (#965)
ParagraphBlockParser and ThematicBreakParser decided whether an
underline line was a lazy continuation by comparing the column of the
paragraph with the column of the line. Inside a block quote or list
item, a paragraph indented further than its container then never got
its underline, and a lazy line at the paragraph's column became a
heading outside the block quote. Use HasUnmatchedBlocks, which tells
whether the line continued every container, in both places.
2026-10-19 20:56:38 +02:00
Wahid Rizka Fathurrohman
78d68077bd Fix setext heading line breaks and indented lazy quote lines (#964)
* Fix line breaks inside setext headings

LineBreakInlineParser only created line breaks in paragraphs, and when
trivia is not tracked the setext heading parser trimmed both ends of
every line. So a hard line break with two trailing spaces inside a
setext heading was lost, and in a block quote the roundtrip output
dropped the quote markers of the heading's later lines. Allow line
breaks in setext headings and trim their lines like a paragraph does.

* Fix roundtrip of indented lazy lines in block quotes

QuoteBlockParser.TryContinue returned early for a line indented by 4
or more spaces without recording a QuoteBlockLine, while a lazy line
without a quote marker gets one. When such a line continued a
paragraph lazily, the quote markers of the following lines moved up by
one line in the roundtrip output. Record the line in both cases.
2026-10-19 20:56:17 +02:00
Alexandre Mutel
ccb9d8593f Fix concurrent spec generation in parallel builds
Each target framework of Markdig.Tests runs SpecFileGen and parallel
builds ran them concurrently, failing with an IOException on the shared
generated files. Serialize the generators with a named mutex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.4.1
2026-10-16 06:35:49 +02:00
Alexandre Mutel
b58e83b427 Update doc for definition-list continuation rules
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 06:34:26 +02:00
Alexandre Mutel
a998839f54 Fix definition paragraphs inside tight lists
Complex definitions inherited the implicit-paragraph state of an
enclosing tight list, so their paragraphs were rendered without <p> and
concatenated. Only a simple single-paragraph definition omits <p> now,
regardless of the enclosing list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 06:34:19 +02:00
Alexandre Mutel
d33c703de0 Fix CommonMark inline HTML declarations
An inline declaration is `<!`, an ASCII letter, any characters other than
`>`, and `>` (CommonMark 0.31.2). Lowercase names such as
`<!doctype html>` and declarations without whitespace such as `<!x>` were
escaped as text, unlike the matching declaration blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 06:33:14 +02:00
Alexandre Mutel
2fec208589 Fix empty list items with trailing marker whitespace
A list marker followed only by spaces or tabs now starts the item with a
blank line exactly like a bare marker: the item requires the marker width
plus one column and ends at the first blank line (CommonMark example 280).
More than four trailing spaces no longer let an empty item interrupt a
paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 06:32:23 +02:00
Alexandre Mutel
05e638f908 Fix CommonMark closing-tag block starts and whitespace 2026-10-15 21:59:19 +02:00
Alexandre Mutel
d5462ae54f Fix CommonMark HTML block start character classes 2026-10-15 21:48:26 +02:00
Michał "DualFroz" Fox
e068f060a4 Fix definition-list marker whitespace requirements (#959)
* Fix definition lists requiring 3 spaces after the marker (#384)

* Update doc for definition-list marker whitespace rules

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-10-15 21:42:10 +02:00
Wahid Rizka Fathurrohman
76afbbfc42 Fix empty list items after closed paragraphs (#961)
* Fix empty list items being parsed as text after a paragraph

An empty list item cannot interrupt a paragraph, but TryParseListItem
rejected it whenever the last block was a paragraph, even one already
closed by a blank line or inside a block quote that the line does not
continue, so the line was read as paragraph text. The check for an
ordered list not starting at 1 already requires an open paragraph and
matched containers, so apply the same condition to empty items.

TestSetextHeading used "A\n\n-\n-", which CommonMark parses as a list,
so it now uses "A\n\nB\n-", a setext heading with the same positions.

* Update doc for empty-list paragraph interruption rules

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-10-15 21:36:23 +02:00
Wahid Rizka Fathurrohman
cdf8aedd83 Fix HTML block whitespace terminators and roundtripping (#960)
* Fix HTML blocks not ending at a line with only spaces or tabs

A blank line ends HTML blocks of type 6 and 7, and CommonMark counts a
line with only spaces or tabs as blank. MatchEnd checked IsBlankLine
after going back over the indent, which made such a line non-empty, so
the HTML block went on and the Markdown after it was output as raw
text. Check the line before going back.

* Fix HTML block terminator trivia and add roundtrip coverage

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-10-15 21:36:18 +02:00
Michał "DualFroz" Fox
55edc078e6 Fix grid-table open last-cell boundaries (#958)
* Fix grid table open last cell taking a `|` from the next line (#494)

To find a closing `|` at the end of the last column, GridTableParser used
PeekCharExtra, which ignores the end of the slice. When the line was
shorter than the table, it could read the next line instead, and a `|`
there made the cell run past the end of the line, so the next line's
leading `|` ended up in the cell. Use PeekChar, which stays within the
current line.

* Fix test coverage for grid-table line endings (#494)

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-10-15 21:36:12 +02:00
SparkUiX
1211a1ac7f Fix definition-list continuation markers and source locations (#957)
* Fix definition list continuation marker (#956)

* Fix test spec generated output (#956)

* Fix indented definition marker rollback and source locations

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-10-15 21:35:49 +02:00
Alexandre Mutel
56e9c23858 Use NuGet Trusted Publishing via dotnet-releaser 1.4.0 2026-09-20 09:52:24 +02:00
Alexandre Mutel
c6b186b4ce Bump deps 2026-09-20 09:46:49 +02:00
Alexandre Mutel
96b024c2d6 Fix tests warnings 2026-09-20 09:46:41 +02:00
Benny Tordrup
237ef72a0f Reject emoji-parsing if the slice ends with ** (#947)
* Reject emoji-parsing if the slice ends with `**`

* Still some emoji false positives

* Cleanup and reduced the number of emojis checked.

* Review comment resolved

* Fix emoji and emphasis precedence (#946)

Resolve trailing emphasis delimiters before converting ambiguous emoji matches. Reuse the existing emphasis parser rather than guessing whether an opener remains active or rejecting only double asterisks.

Cover italics, strong/nested emphasis, custom delimiters, links, images, tables, source positions, renderers, all default mappings, and 2688 emphasis-structure comparisons. Document emphasis and generic-attribute precedence and the named-shortcode escape hatch.

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-09-20 09:36:57 +02:00
Alexandre Mutel
86866b919c Fix strict GFM tables against native cmark-gfm 2026-09-19 15:20:49 +02:00
Alexandre Mutel
14cd25c744 Add strict GFM pipe table parsing mode 2026-09-19 12:58:58 +02:00
Liangying.Wei
ad7cc00ac3 Fix partially empty pipe table separator regression (#955)
* Fix partially empty pipe table separator regression

Restore historical acceptance of empty separator cells while retaining the row-wide dash requirement introduced for #927. Cover partial and entirely empty rows, alignment, optional pipes, and inferred widths.

Refs: dotnet/docfx#11147

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Fix normalization of empty inferred table separators (#955)

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-09-19 12:42:55 +02:00
boxofyellow
6168275c3f Add Normalization Support for PipeTables (GFM) (#954)
* Add Support for PipeTables (GFM)

* Add additional tests. First two work, later three do not.

* Fix bad merge

* Update to follow style

* Address problem with trailing new lines after the table

* Fix pipe table normalization alignment and separators (#954)

---------

Co-authored-by: T. Thiery <thomas.thiery+git@gmail.com>
Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-09-19 12:24:10 +02:00
boxofyellow
209b347ac2 Fix indent on first list item (#482) (#953)
* Fix indent on first list item (#482)

* Fix normalization of empty quotes in list items (#953)

* Fix null validation for line-specific indents (#953)

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-09-19 12:09:15 +02:00
Michał "DualFroz" Fox
27b8c9eb56 Fix: keep trailing content out of an unmatched emphasis closer (#743) (#950)
* fix: keep trailing content out of unmatched emphasis closer (#743)

When EnableTrackTrivia() is enabled, an emphasis closer whose delimiter
run is only partially consumed (its leftover dropping below the minimum
count) kept the inlines that follow it nested inside the emphasis. The
roundtrip renderer then emitted the closing delimiters after that
trailing content, corrupting the output, for example a grid table
separator row using the "marked" (==) delimiter from EmphasisExtras.

Move the trailing content out to the outermost enclosing emphasis when
the closer can no longer be matched, mirroring the existing handling for
a fully consumed opener. The leftover closer keeps its position, so
cases without trailing content are unaffected. Adds a regression test.

* Fix unmatched emphasis closer cleanup order (#743)

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-09-19 11:52:40 +02:00
Michał "DualFroz" Fox
baa95a9ca3 Fix heading auto-link hijacking nested link labels (#668) (#949)
* Fix heading auto-link hijacking nested link labels (#668)

* Refactor heading reference resolution to init-only state (#949)

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
2026-09-19 11:41:48 +02:00
Nicolas Musset
b07b98e1b7 Update 3rd party extensions (#945)
Remove markdig.wpf which is archived and obsolete.
Add MarkView.Avalonia
2026-08-18 18:02:42 +02:00
Alexandre Mutel
fc705234fa Fix emoji table alignment regression (#943) 1.3.2 2026-06-18 18:49:25 +02:00
Alexandre Mutel
25506f20d9 Fix plus superscript parsing (#791) 1.3.1 2026-06-17 08:35:40 +02:00
Alexandre Mutel
50061841a4 Fix LinkHelper non-ASCII urilize (#942) 2026-06-17 08:25:56 +02:00
Alexandre Mutel
bc4e399087 Fix blockquote ordered list parsing (#887) 1.3.0 2026-06-13 14:38:30 +02:00
Alexandre Mutel
9dffce52b6 Fix NormalizeRenderer auto identifiers output (#930) 2026-06-13 14:21:54 +02:00
Alexandre Mutel
d7f13b03cf Fix configurable nesting depth limit (#892) 2026-06-13 14:20:14 +02:00
Alexandre Mutel
b83641351f Fix roundtrip autolink URLs (#919) 2026-06-13 14:03:45 +02:00
Alexandre Mutel
0f98267a85 Fix pipe table cells with unmatched subscript (#932) 2026-06-13 08:47:21 +02:00
Alexandre Mutel
fcbf817063 Fix CJK emphasis after HTML entity newlines (#941) 2026-06-13 08:12:54 +02:00
Alexandre Mutel
5dca4149a5 Update AGENTS.md 2026-06-13 08:12:54 +02:00
Andrew White
31c2baadd0 Update readme with Alert extension details (#940)
* Update readme with Alert extension details

* Update readme.md

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>

---------

Co-authored-by: Alexandre Mutel <alexandre_mutel@live.com>
Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
2026-06-04 07:48:11 +02:00
Simon Cropp
d72da576ea add InferColumnWidthsFromSeparator docs (#939) 2026-05-19 08:19:48 +02:00
Alexandre Mutel
be4da8b42d Remove old changelog.md 1.2.0 2026-05-12 08:06:25 +02:00
kapsiR
7dceff2130 Add opt-in support for nested alert blocks (#938)
Introduces AllowNestedAlerts on AlertExtension and AlertInlineParser
(default: false) to allow alert blocks inside blockquotes or list items.

The UseAlertBlocks() pipeline extension method exposes the new option
via an allowNestedAlerts parameter.

Resolves #853

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 23:13:34 +02:00
Simon Cropp
3d69933205 Attribute with StringSyntax (#937) 1.1.3 2026-04-20 08:11:09 +02:00
Nicolas Musset
5365879a23 Fix AbbreviationExtension corrupting emphasis/bold/italic resolution (#935) (#936)
* test: add failing regression tests for issue #935 (abbreviation + emphasis)

* fix: AbbreviationParser now substitutes post-inline-parse, fixes emphasis corruption (#935)

The PostMatch hook approach (running mid-parse) produced a ContainerInline
with IsClosed=false that disrupted FindLastContainer(), causing emphasis
delimiters to be appended as children of the abbreviation container instead
of as root siblings. It also had an off-by-one (i != 0 vs i != content.Start)
that caused abbreviations to be missed when the literal started inside emphasis.

Replace with a document.ProcessInlinesEnd handler that walks the fully resolved
inline tree (after EmphasisInlineParser and LinkInlineParser have run), inserting
AbbreviationInline/LiteralInline siblings directly into parent containers without
any wrapper ContainerInline.

Also update TestSourcePosition.TestAbbreviations to reflect the new tree shape
(no container wrapper; empty leading literals at word boundaries are pruned).

Fixes #935
2026-04-20 08:09:26 +02:00
prozolic
a9bd7c6a5e Fix to calculate LinkReferenceDefinition span positions from StringLineGroup.Lines (#931)
* Fix to calculate LinkReferenceDefinition span positions from StringLineGroup.Lines

* Add test case in TestMultilineInBlockquote

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Change from startPosition + span.End - span.Start to GetAbsolutePosition(lines, span.End)

* Move ConvertToAbsoluteSpan and GetAbsolutePosition to StringLineGroup

* Remove '\r' check in Write(ReadOnlySpan<char>)

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1.1.2
2026-03-24 21:21:12 +01:00
prozolic
7cb7583fd7 Fix emoji not rendering in table cells (#928)
* Fix emoji not rendering in table cells

* Update EmojiSpecs.md

* Update src/Markdig/Extensions/Emoji/EmojiParser.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1.1.1
2026-03-04 21:20:18 +01:00
Alexandre Mutel
bddaa55da1 docs(site): document CJK friendly emphasis extension 1.1.0 2026-03-01 13:57:39 +01:00
Tatsunori Uchino
6d5a124863 Add CJK-friendly Emphasis Extension (#921)
* Add CJK-friendly Emphasis Extension

* Add auto-generated test file

* Add name for configuration

* Remove useless default value assignments

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>

* Make `CheckOpenCloseDelimiterCjkFriendly` internal only

* Remove `CjkFriendlyEmphasisExtension` class

* Add some comments including links

* Add direct tests on `CharHelper.CheckOpenCloseDelimiterCjkFriendly`

* Fix generated tests

* Add `#if NET`

* Skip Rune-dependent tests in .NET Standard tests

* Add missing XML Documentation Comments

* Fix URL

* Change test condition

* Add test in .NET Framework 4.8.1

* Add netstandard2.0 to SpecFileGen

* Add fallback for netstandard2.0

* Fix

* Revert "Fix"

This reverts commit 42e998b085.

* Revert "Add fallback for netstandard2.0"

This reverts commit 7400a7bb0b.

* Revert "Add netstandard2.0 to SpecFileGen"

This reverts commit f9aa8e1e8d.

* Revert "Add test in .NET Framework 4.8.1"

This reverts commit d8d6d516ed.

* Fix missing indent

---------

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
2026-03-01 13:47:54 +01:00
Alexandre Mutel
7959e3b912 Reject pipe-only rows as pipe table separators (Fixes #927) 1.0.1 2026-02-28 06:51:42 +01:00
Alexandre Mutel
391e03b8d0 Update readme 2026-02-22 19:17:58 +01:00