[PR #481] [MERGED] Roundtrip implementation #1058

Open
opened 2026-01-29 14:49:10 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/481
Author: @generateui
Created: 10/3/2020
Status: Merged
Merged: 3/7/2021
Merged by: @xoofx

Base: masterHead: cst


📝 Commits (10+)

  • 2b07e9a add naive cst implementation
  • 147698d revert LinkInlineRenderer
  • c737853 implement cst for Paragraph
  • 30f670b fix NRE
  • cd18087 implement cst for header
  • 0234d60 fix broken whitespace calculation
  • f78b5c8 handle whitespace before and after paragraphs correctly
  • 0d86a93 fix block nodes
  • cadbc67 fix newline between blocks
  • acf2ba9 allow CodeInline with multiple delimiter characters

📊 Changes

112 files changed (+30724 additions, -301 deletions)

View changed files

📝 readme.md (+1 -0)
src/Markdig.Tests/RoundtripSpecs/CommonMark.generated.cs (+15266 -0)
src/Markdig.Tests/RoundtripSpecs/CommonMark.md (+9710 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestAutoLinkInline.cs (+23 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestBackslashEscapeInline.cs (+67 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestCodeInline.cs (+77 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestEmphasisInline.cs (+132 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestHtmlEntityInline.cs (+53 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestHtmlInline.cs (+27 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestImageInline.cs (+25 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestLineBreakInline.cs (+18 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestLinkInline.cs (+229 -0)
src/Markdig.Tests/RoundtripSpecs/Inlines/TestNullCharacterInline.cs (+37 -0)
src/Markdig.Tests/RoundtripSpecs/TestAtxHeading.cs (+55 -0)
src/Markdig.Tests/RoundtripSpecs/TestExample.cs (+54 -0)
src/Markdig.Tests/RoundtripSpecs/TestFencedCodeBlock.cs (+107 -0)
src/Markdig.Tests/RoundtripSpecs/TestHtmlBlock.cs (+20 -0)
src/Markdig.Tests/RoundtripSpecs/TestIndentedCodeBlock.cs (+86 -0)
src/Markdig.Tests/RoundtripSpecs/TestLinkReferenceDefinition.cs (+214 -0)
src/Markdig.Tests/RoundtripSpecs/TestNoBlocksFoundBlock.cs (+23 -0)

...and 80 more files

📄 Description

Implements a CST aka LST (Complete Syntax Tree aka Lossless Syntax Tree).
Please keep the following in mind:

  • some changes have broken Markdig parser
  • tabs not yet implemented
  • some hacky code here and there
  • performance not taken into consideration/no perf tests run on this

As such, this is a very modest first attempt to learn if a CST can be implemented in markdig while keeping the current focus on performance. I'd be happy to hear feedback about

  1. is having CST support desirable
  2. what are pain points currently in included changes
  3. any tips on moving forward

Any feedback is highly appreciated.

For context, the usecase for this is creating bots that automatically enhance and fix markdown documentation. Think creating links automatically, fixing links automatically, inserting generated blocks of markdown code, et cetera. This requires a markdown renderer that does not change any input markdown as much as possible in the output markdown.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/xoofx/markdig/pull/481 **Author:** [@generateui](https://github.com/generateui) **Created:** 10/3/2020 **Status:** ✅ Merged **Merged:** 3/7/2021 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `cst` --- ### 📝 Commits (10+) - [`2b07e9a`](https://github.com/xoofx/markdig/commit/2b07e9a5b9fb40ad3e6b98dcc4d5980ab2a737ef) add naive cst implementation - [`147698d`](https://github.com/xoofx/markdig/commit/147698daab7a55cd0257c65576cb07c4bb45376d) revert LinkInlineRenderer - [`c737853`](https://github.com/xoofx/markdig/commit/c73785372b29185c06255ac4ad42597d48b4ec3d) implement cst for Paragraph - [`30f670b`](https://github.com/xoofx/markdig/commit/30f670bf5fff84a2731968957d4e6e34189adb47) fix NRE - [`cd18087`](https://github.com/xoofx/markdig/commit/cd18087e2943daf4114fc1b04d43512ee130276b) implement cst for header - [`0234d60`](https://github.com/xoofx/markdig/commit/0234d60d74c5b2c7892d794a7447f25b7ccb2b50) fix broken whitespace calculation - [`f78b5c8`](https://github.com/xoofx/markdig/commit/f78b5c83cd95f52e4580bf5c5cc4454c42eb3c92) handle whitespace before and after paragraphs correctly - [`0d86a93`](https://github.com/xoofx/markdig/commit/0d86a9320003d7d595ebfdc2a3ad64bc7e691016) fix block nodes - [`cadbc67`](https://github.com/xoofx/markdig/commit/cadbc67825e9ad78f2bce5d02b8764ec276af773) fix newline between blocks - [`acf2ba9`](https://github.com/xoofx/markdig/commit/acf2ba950265d3c2f39449d5e96702db98bea52e) allow CodeInline with multiple delimiter characters ### 📊 Changes **112 files changed** (+30724 additions, -301 deletions) <details> <summary>View changed files</summary> 📝 `readme.md` (+1 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/CommonMark.generated.cs` (+15266 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/CommonMark.md` (+9710 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestAutoLinkInline.cs` (+23 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestBackslashEscapeInline.cs` (+67 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestCodeInline.cs` (+77 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestEmphasisInline.cs` (+132 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestHtmlEntityInline.cs` (+53 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestHtmlInline.cs` (+27 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestImageInline.cs` (+25 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestLineBreakInline.cs` (+18 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestLinkInline.cs` (+229 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/Inlines/TestNullCharacterInline.cs` (+37 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/TestAtxHeading.cs` (+55 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/TestExample.cs` (+54 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/TestFencedCodeBlock.cs` (+107 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/TestHtmlBlock.cs` (+20 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/TestIndentedCodeBlock.cs` (+86 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/TestLinkReferenceDefinition.cs` (+214 -0) ➕ `src/Markdig.Tests/RoundtripSpecs/TestNoBlocksFoundBlock.cs` (+23 -0) _...and 80 more files_ </details> ### 📄 Description Implements a CST aka LST (Complete Syntax Tree aka Lossless Syntax Tree). Please keep the following in mind: - some changes have broken Markdig parser - tabs not yet implemented - some hacky code here and there - performance not taken into consideration/no perf tests run on this As such, this is a very modest first attempt to learn if a CST can be implemented in markdig while keeping the current focus on performance. I'd be happy to hear feedback about 1. is having CST support desirable 2. what are pain points currently in included changes 3. any tips on moving forward Any feedback is highly appreciated. For context, the usecase for this is creating bots that automatically enhance and fix markdown documentation. Think creating links automatically, fixing links automatically, inserting generated blocks of markdown code, et cetera. This requires a markdown renderer that does not change any input markdown as much as possible in the output markdown. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 14:49:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#1058