[PR #301] [MERGED] Improved emphasis parser #927

Closed
opened 2026-01-29 14:47:21 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/301
Author: @MihaZupan
Created: 1/29/2019
Status: Merged
Merged: 2/9/2019
Merged by: @xoofx

Base: masterHead: improved-emphasis-parser


📝 Commits (8)

  • 6b1b516 Add HasFlag enum support
  • 1b5d9d4 Emit correct warning message in tests
  • d232e84 Allow different min/max emphasis delimiter counts
  • 42b201d Update internals to renewed Emphasis parser
  • 5266ae9 Add extended emphasis tests
  • 035ce17 Add generic TEnum constraint to HasFlag
  • 20bd561 Avoid a possible Null Reference Ex.
  • 6488315 Remove HasFlag helper

📊 Changes

17 files changed (+328 additions, -145 deletions)

View changed files

📝 src/Markdig.Tests/Markdig.Tests.csproj (+1 -0)
src/Markdig.Tests/TestEmphasisExtended.cs (+168 -0)
📝 src/Markdig.Tests/TestEmphasisPlus.cs (+1 -3)
📝 src/Markdig.Tests/TextAssert.cs (+2 -2)
📝 src/Markdig/Extensions/Citations/CitationExtension.cs (+6 -5)
📝 src/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs (+13 -15)
📝 src/Markdig/Extensions/CustomContainers/HtmlCustomContainerInlineRenderer.cs (+1 -1)
📝 src/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs (+7 -6)
📝 src/Markdig/Extensions/SmartyPants/SmartyPantsInlineParser.cs (+7 -7)
📝 src/Markdig/Helpers/CharHelper.cs (+2 -6)
📝 src/Markdig/Markdig.csproj (+1 -0)
📝 src/Markdig/Parsers/Inlines/EmphasisDescriptor.cs (+1 -2)
📝 src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs (+80 -86)
📝 src/Markdig/Renderers/Html/Inlines/EmphasisInlineRenderer.cs (+5 -3)
📝 src/Markdig/Renderers/Normalize/Inlines/EmphasisInlineRenderer.cs (+2 -2)
📝 src/Markdig/Syntax/Inlines/EmphasisDelimiterInline.cs (+16 -4)
📝 src/Markdig/Syntax/Inlines/EmphasisInline.cs (+15 -3)

📄 Description

This allows for emphasis parsing with min/max above 2 characters.

I marked IsDouble on EmphasisInline as Obsolete as described below. This should not be a breaking change for existing parsers/renderers.
d232e847dd/src/Markdig/Syntax/Inlines/EmphasisInline.cs (L24-L36)

I also changed the way adding a CreateEmphasisInline works (since there can no longer be a bool isStrong identifier), so now there's no need to save the previous one, attempt the new one and revert to the old one on callsites, instead adding the delegate to the list, returning null if not providing an emphasis. CreateEmphasisInlineDelegate is marked as obsolete in favour of TryCreateEmphasisInlineDelegate. Note that this shouldn't be a breaking change, since for now the parser will attempt to use the old delegate first.
42b201d8c2/src/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs (L29-L36)


🔄 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/301 **Author:** [@MihaZupan](https://github.com/MihaZupan) **Created:** 1/29/2019 **Status:** ✅ Merged **Merged:** 2/9/2019 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `improved-emphasis-parser` --- ### 📝 Commits (8) - [`6b1b516`](https://github.com/xoofx/markdig/commit/6b1b5165ca6a4e1bc2d0e53f48776a1646096d91) Add HasFlag enum support - [`1b5d9d4`](https://github.com/xoofx/markdig/commit/1b5d9d46fc01c4604735ff8fd68201a16ac3de22) Emit correct warning message in tests - [`d232e84`](https://github.com/xoofx/markdig/commit/d232e847dd1a6822d72cb09740511ee84729100a) Allow different min/max emphasis delimiter counts - [`42b201d`](https://github.com/xoofx/markdig/commit/42b201d8c2f599b9f3a2f4ba6f89a412be45d745) Update internals to renewed Emphasis parser - [`5266ae9`](https://github.com/xoofx/markdig/commit/5266ae965bb3034b5ce0d628481b77eb68a8a0a3) Add extended emphasis tests - [`035ce17`](https://github.com/xoofx/markdig/commit/035ce1738689b632dc173b04949252245f4489fd) Add generic TEnum constraint to HasFlag - [`20bd561`](https://github.com/xoofx/markdig/commit/20bd561062c17c7848e739b273ab45207e995c89) Avoid a possible Null Reference Ex. - [`6488315`](https://github.com/xoofx/markdig/commit/64883152c9e662dc3d46295f5339eee974132753) Remove HasFlag helper ### 📊 Changes **17 files changed** (+328 additions, -145 deletions) <details> <summary>View changed files</summary> 📝 `src/Markdig.Tests/Markdig.Tests.csproj` (+1 -0) ➕ `src/Markdig.Tests/TestEmphasisExtended.cs` (+168 -0) 📝 `src/Markdig.Tests/TestEmphasisPlus.cs` (+1 -3) 📝 `src/Markdig.Tests/TextAssert.cs` (+2 -2) 📝 `src/Markdig/Extensions/Citations/CitationExtension.cs` (+6 -5) 📝 `src/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs` (+13 -15) 📝 `src/Markdig/Extensions/CustomContainers/HtmlCustomContainerInlineRenderer.cs` (+1 -1) 📝 `src/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs` (+7 -6) 📝 `src/Markdig/Extensions/SmartyPants/SmartyPantsInlineParser.cs` (+7 -7) 📝 `src/Markdig/Helpers/CharHelper.cs` (+2 -6) 📝 `src/Markdig/Markdig.csproj` (+1 -0) 📝 `src/Markdig/Parsers/Inlines/EmphasisDescriptor.cs` (+1 -2) 📝 `src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs` (+80 -86) 📝 `src/Markdig/Renderers/Html/Inlines/EmphasisInlineRenderer.cs` (+5 -3) 📝 `src/Markdig/Renderers/Normalize/Inlines/EmphasisInlineRenderer.cs` (+2 -2) 📝 `src/Markdig/Syntax/Inlines/EmphasisDelimiterInline.cs` (+16 -4) 📝 `src/Markdig/Syntax/Inlines/EmphasisInline.cs` (+15 -3) </details> ### 📄 Description This allows for emphasis parsing with min/max above 2 characters. I marked `IsDouble` on `EmphasisInline` as Obsolete as described below. This should not be a breaking change for existing parsers/renderers. https://github.com/lunet-io/markdig/blob/d232e847dd1a6822d72cb09740511ee84729100a/src/Markdig/Syntax/Inlines/EmphasisInline.cs#L24-L36 I also [changed](https://github.com/lunet-io/markdig/pull/301/files#diff-b5d0fcbc89fb349b18e37bbef25bdeb4L29) the way adding a `CreateEmphasisInline` works (since there can no longer be a `bool isStrong` identifier), so now there's no need to save the previous one, attempt the new one and revert to the old one on callsites, instead adding the delegate to the list, returning null if not providing an emphasis. `CreateEmphasisInlineDelegate` is marked as obsolete in favour of `TryCreateEmphasisInlineDelegate`. Note that this **shouldn't** be a breaking change, since for now the parser will attempt to use the old delegate first. https://github.com/lunet-io/markdig/blob/42b201d8c2f599b9f3a2f4ba6f89a412be45d745/src/Markdig/Extensions/CustomContainers/CustomContainerExtension.cs#L29-L36 --- <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:47:21 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#927