[PR #829] [MERGED] Fix incorrect emphasis span calculation. #1236

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

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/829
Author: @snnz
Created: 12/9/2024
Status: Merged
Merged: 12/17/2024
Merged by: @xoofx

Base: masterHead: fix-emphasis-span


📝 Commits (1)

  • a11899a Fixes emphasis span calculation. A test is added.

📊 Changes

2 files changed (+15 additions, -5 deletions)

View changed files

📝 src/Markdig.Tests/TestSourcePosition.cs (+11 -0)
📝 src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs (+4 -5)

📄 Description

EmphasisInlineParser did not take into account the case of extra delimiter characters before the emphasis. For example:

**foo*

The supplied test produces the following result in the current version:

**foo*
```````````````````Result
paragraph    ( 0, 0)  0-5
literal      ( 0, 1)  1-1
emphasis     ( 0, 0)  0-5
literal      ( 0, 2)  2-4
```````````````````Expected
paragraph    ( 0, 0)  0-5
literal      ( 0, 0)  0-0
emphasis     ( 0, 1)  1-5
literal      ( 0, 2)  2-4

The emphasis intersects with the literal before it - obviously wrong. The effect of this can be seen in the Visual Studio editor: it displays the first asterisk as italics.


🔄 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/829 **Author:** [@snnz](https://github.com/snnz) **Created:** 12/9/2024 **Status:** ✅ Merged **Merged:** 12/17/2024 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `fix-emphasis-span` --- ### 📝 Commits (1) - [`a11899a`](https://github.com/xoofx/markdig/commit/a11899a350d8cdccc746361183342ae5c56f7148) Fixes emphasis span calculation. A test is added. ### 📊 Changes **2 files changed** (+15 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/Markdig.Tests/TestSourcePosition.cs` (+11 -0) 📝 `src/Markdig/Parsers/Inlines/EmphasisInlineParser.cs` (+4 -5) </details> ### 📄 Description `EmphasisInlineParser` did not take into account the case of extra delimiter characters before the emphasis. For example: `**foo*` The supplied test produces the following result in the current version: ```````````````````Source **foo* ```````````````````Result paragraph ( 0, 0) 0-5 literal ( 0, 1) 1-1 emphasis ( 0, 0) 0-5 literal ( 0, 2) 2-4 ```````````````````Expected paragraph ( 0, 0) 0-5 literal ( 0, 0) 0-0 emphasis ( 0, 1) 1-5 literal ( 0, 2) 2-4 ``````````````````` The emphasis intersects with the literal before it - obviously wrong. The effect of this can be seen in the Visual Studio editor: it displays the first asterisk as italics. --- <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:51:48 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#1236