Repository navigation
Finish the move to cmark-gfm: remove hoedown and PEG Markdown Highlight - #8
Merged
Merged
Conversation
Before the C libraries go, their outputs that the port must match are recorded in engine-snapshots.json: hoedown's HTML for the renderer's byte-for-byte cases, front matter, TOC, hard wrap, math, autolink, smart punctuation, highlight/superscript and Prism languages; its escaping; and pmh_styleparser.c's parse of every bundled theme and a malformed stylesheet. HTMLRendererTests, HTMLEscapingTests, PrismLanguageTests and ThemeStyleParserTests now compare with these instead of calling the C code. swift test 386 passed; app build succeeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The HTML and highlight harnesses compared the two engines over the corpus; with hoedown going, their reviewed differences stay as the summary in docs/MACDOWN-PORT.md. The HTML normalizer and hunk splitting, which the paste round trip and renderer tests use, move to HTMLDiff.swift with their tests. swift test 380 passed (the 6 harness tests are gone); app build succeeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmark-gfm is the only Markdown engine: - the hidden markdownEngine setting, MarkdownParser (the hoedown bridge) and the renderer's hoedown branch are gone; ParseSettings holds named options (autolink, math, smart punctuation, …) instead of hoedown flags - the editor is always highlighted from the document model: the highlighter's PEG parse, extensions and usesExternalElements are gone, a Swift HighlightElement enum (PEG's element order) replaces the pmh_ constants, and spans are kept across deactivate/activate so settings changes restyle without a parse of its own - scroll sync anchors are source lines only: ScrollAnchors.scan (hoedown's block rules), the header/image kinds and the preview's mirroring script are gone Tests drop their hoedown arguments and hoedown-pinned scroll tests; the benchmark compares against PEG's recorded time. Checked in a running Debug build launched with -markdownEngine hoedown: the stale value is ignored, and the editor and preview render and highlight. swift test 373 passed twice; app build succeeded. The C targets are removed next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sources/CHoedown (hoedown 3.0.7 with MacDown's patches) and Sources/CPegMarkdown (PEG Markdown Highlight, with the generated pmh_parser.c) and their package targets go; nothing uses them since the previous commit. The package has no C targets left. swift test 373 passed; app build succeeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hoedown.txt and hoextdown.txt are removed with hoedown. The PEG Markdown Highlight license stays, with a note that the library isn't used: the editor highlighter and theme parser are Swift ports of its code, kept so .style themes work. Licenses/README.md says what each license covers (cmark-gfm.txt is swift-cmark's COPYING; there's no swift-markdown dependency to license). In the About panel's credits, every language lists LeVous (Rusty Zarse) as a contributor, replaces Hoedown and Hoextdown with cmark-gfm, and notes the PEG ports. The localization import script applies these to the original's credits, so re-running it keeps them. swift test 373 passed; app build succeeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLAUDE.md, ARCHITECTURE.md and MACDOWN-PORT.md describe cmark-gfm as the only engine: no C targets or hidden engine setting, source-line scroll anchors, the highlighter and theme parser as Swift ports of PEG Markdown Highlight, renderer tests against hoedown's recorded output, and the retired diff harnesses (their findings stay in MACDOWN-PORT.md). The parser-regeneration section goes. The migration intent records the removal as Decision 11 and is marked done. swift test 373 passed; app build succeeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude code review a04bfd4No issues found. Checked for bugs and CLAUDE.md compliance. |
Claude code review ad66810This PR removes the two C libraries (hoedown and PEG Markdown Highlight), so cmark-gfm is the only engine. Highlighting now always comes from the document model. The removal looks clean, and the recorded hoedown and PEG outputs keep the renderer and theme guarantees under test. No blocking or should-fix findings. What I checked:
Not verified: I didn't build the package or run the test suite. Ready to merge: the removal is coherent, behavior is preserved by recorded snapshots, and I found no correctness or concurrency problems. |
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.
Removes the original's two C Markdown libraries, hoedown and PEG Markdown Highlight, so cmark-gfm (swift-cmark) is the only engine and the package has no C code left. Also updates licenses and credits, adds LeVous (Rusty Zarse) to contributors, and cleaned change spec references from code comments.
Stacked on #7 (
feature/paste-formatted), so this diff shows only this work. Retarget tomainonce #7 merges.What's removed
Sources/CHoedownandSources/CPegMarkdown, with their package targets.markdownEnginesetting andMarkdownParser, the hoedown wrapper.ParseSettingsnow has named options instead of hoedown's flag bits.HighlightElementenum, in PEG's element order, replaces the C constants.ScrollAnchors.scanand the preview script that mirrored it). Anchors are now only source lines.Keeping the guarantees
Before deleting the C code, its outputs were recorded in
Tests/MacDownKitTests/Resources/engine-snapshots.json:The renderer and theme tests now compare against those recordings. The highlighting benchmark compares against PEG's recorded time.
One fix came out of this. With PEG gone, turning the highlighter off and on again for a settings change would have left the editor unhighlighted until the next edit. It now keeps its highlight data and restyles straight away, and a test covers it.
Licenses and credits
hoedown.txtandhoextdown.txtare removed.peg-markdown-highlight.txtstays, with a note at the top: the library isn't used, butMarkdownHighlighterandThemeStyleare Swift ports of its code, kept so.stylethemes keep working. Both files point to the license.Licenses/README.mdsays what each license covers.cmark-gfm.txt, which matches its license file exactly. There's no swift-markdown dependency.Tools/import_localizations.pyapplies these to the original's credits, so re-running it keeps them.Also
Testing
swift test: 373 passed (run twice where scroll sync and the live tests changed).-markdownEngine hoedownsetting ignores it, and the editor highlights and the preview renders as before.🤖 Generated with Claude Code