0.1.0: GFM syntax, opt-in LaTeX math, ~45% faster parser, full test suite + coverage - #23
Merged
Merged
Conversation
New syntax - GitHub alert blocks (> [!NOTE]/[!TIP]/[!IMPORTANT]/[!WARNING]/[!CAUTION]) via a new MD$Alert block, MD$AlertType, and BlockPainter$Alert. - Task-list items (- [ ] / - [x]) via MD$ListItem.checked/isTask, rendered with a checkbox. - Table column alignment (:---, :--:, ---:) captured on MD$Table.alignments and applied when rendering. - Guarded $...$ inline LaTeX-to-Unicode math (code-span/code-block safe; currency like $5 preserved). Reworks PR #21 into a robust form. Theme - Adopt linkStyle (PR #22) cleanly; add per-type alert colors (alertColors / alertColorFor). - Fix MarkdownThemeData.copyWith dropping builder and onLinkTap. Parser correctness fixes (from an adversarial bug hunt) - Emphasis no longer leaks to end-of-line for stray/unterminated markers (5 * 6 = 30, **oops) and no longer treats intraword _ as emphasis (snake_case, object_id) — CommonMark-inspired flanking + closer checks. - Thematic breaks support ***, ___ and spaced variants; --- no longer greedily swallows trailing text. - ATX headings require a space after #, reject 7+ #, and strip trailing #. - ~~~ fenced code blocks recognized alongside ```. - Emphasis surrounding a link/image is merged onto the link span. - Link/image targets support <url> and single-quoted titles. Tests - Add 153 tests across parser (inline, block, gfm, edge cases), theme, and widget rendering; total suite now 215 and green (was 62). BREAKING: MD$Block.map/maybeMap gain an `alert` branch for MD$Alert. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Introduced a golden characterization test to capture the exact structural output of the Markdown parser, ensuring stability against future changes. - Created a regression test suite targeting edge cases and performance-related changes in the parser, documenting specific behaviors and invariants. - Updated the unit test runner to include new test files for block parsing, inline parsing, GitHub Flavored Markdown (GFM), and edge cases. - Added a variety of test cases covering prose, emphasis, links, images, lists, tables, and more to ensure robust parsing behavior.
Inline `$...$` math is now DISABLED by default, so literal dollar signs
(prices like `$5`, shell variables like `$HOME`) are never altered. Enable it
with `MarkdownDecoder(inlineMath: true)` or
`Markdown.fromString(text, inlineMath: true)`.
Improvements to the math feature:
- Configurable command table via `mathReplacements`; the defaults are exported
as `kMarkdownMathCommands` so callers can extend rather than replace them.
- Superscript/subscript conversion: `x^2` -> x², `H_2O` -> H₂O, `x^{10}` -> x¹⁰,
`a_i` -> aᵢ. Unmappable runs are left literal.
- More commands (implies/iff, perp/parallel, oplus/otimes, hbar/ell, Re/Im,
therefore/because, extra arrows and relations).
- `\$` is now a recognized escape (literal dollar); an escaped opening `$`
never starts a math run, so `\$\alpha\$` stays literal `$\alpha$`.
Making math opt-in also speeds up the default parse path (it no longer calls
the math pass at all): escapes-heavy text is now ~68% faster than baseline.
Tests: new test/parser/math_test.dart (commands, super/subscripts, code
protection, escaping, configurability, span integrity). The golden snapshot is
regenerated to reflect the new default (only the two math entries changed).
Co-authored-by: Fazliddin <faz.ibragimovv@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 29, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bring parser.dart line coverage to 99.6% (the remaining two lines are an unreachable defensive branch in the list-traverse). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add nodes_test.dart (MD$Style helpers, block type/toString/maybeMap, MD$ListItem/MD$TableRow, Markdown facade), extend theme_test.dart (headingStyleFor, type/toString, MarkdownTheme.of/maybeOf), and add widget_test.dart (context theme fallback in create/updateRenderObject). nodes.dart, markdown.dart, theme.dart, widget.dart now at 100%; parser.dart 99.6%. render.dart left untouched pending its refactor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
….1.0 - README: document GitHub alerts, task lists, table alignment, thematic breaks and opt-in inline math; refresh feature list and performance section. - Add a Codecov coverage badge and a CI upload step (codecov-action). - Bump version 0.0.9 -> 0.1.0 and retitle the CHANGELOG section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A large 0.0.9 pass on the parser and its test/benchmark tooling. Adds popular GFM syntax, makes LaTeX math an opt-in feature, rewrites the parser hot path for a ~45% speedup, and turns the test suite into something CI actually runs end-to-end.
New syntax
> [!NOTE] / [!TIP] / [!IMPORTANT] / [!WARNING] / [!CAUTION]viaMD$Alert+MD$AlertType, with configurable accent colors (alertColors).- [ ]/- [x]viaMD$ListItem.checked/isTask, rendered with a checkbox.:---,:--:,---:captured onMD$Table.alignmentsand applied when rendering.***,___, and spaced variants (- - -); the greedy---data-loss is fixed.linkStyleonMarkdownThemeData(adapted from feat: add linkStyle to MarkdownThemeData for customizable link text s… #22).Inline LaTeX math — now opt-in
Disabled by default so literal dollars (
$5,$HOME) are never altered. Enable viaMarkdownDecoder(inlineMath: true)orMarkdown.fromString(text, inlineMath: true).\alpha,\rightarrow, …) and super/subscripts (x^2,H_2O,x^{10},a_i).\$is a literal dollar.mathReplacements(extend the exportedkMarkdownMathCommands).Performance (~45% faster default path)
Each change was verified by a benchmark and the golden test (output stays byte-identical). Measured per-op improvements vs. the pre-refactor parser:
Techniques: plain-text single-span fast path, first-code-unit guards keeping regexes off paragraph lines, hand-rolled list-line & link-target parsing (dropping per-line / per-call
RegExpallocation), lazy link extraction, range-copy escape rebuild, and math being opt-in.Tests & tooling
test/parser/golden_test.dart) freezes full-AST output for an 82-entry corpus.test/unit_test.dartwas running only ~31 tests; every test file is now wired in, so CI runs the full 327.benchmark/parser_benchmark.dart(benchmark_harness) +benchmark/compare.dart(low-noise before/after tool).Parser correctness fixes
Emphasis flanking/closer rules (stray/unterminated markers stay literal), intraword
_, ATX heading space requirement,~~~fences,<url>/ single-quoted link titles,copyWithdroppingbuilder/onLinkTap.PR housekeeping
copyWithfix andlerp/mergeThemethreading).Co-authored-by).🤖 Generated with Claude Code