mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-09 21:42:15 +00:00
Inconvenient Content StringSlice for emphasis delimiter literal inlines #623
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zickb on GitHub (Aug 30, 2023).
When an open emphasis delimiter is found but no closing emphasis delimiter, then the delimiter will be converted to an
LiteralInline.This
LiteralInlinehave a content Property which contains only the delimiter string literal as text.A regular
LiteralInlinehas a content Property containing the whole text and an appropriate start and end index instead.E.g.:
Test input:
test*test=> Paragraph
|-----------Container Inline
|----------------Literal Inline (Content: test*test, Start: 0, End: 3)
|----------------Literal Inline (Content: , Start: 0, End: 0)
|----------------Literal Inline (Content: testtest, Start: 5, End: 8)
This structure is in my opinion very inconvenient and make thinks like text search above multiple literal inlines unnecessary "hard".
(But thats just my opinion and maybe I'm wrong. In that case please feel free to discard the pull request #736 and this issue.)
@MihaZupan commented on GitHub (Aug 30, 2023):
The offset of a
StringSliceshould be an implementation detail. We may or may not point to the original source text as a performance optimization to avoid allocating substrings.If you care about locations in the original text, you should enable
UsePreciseSourceLocationand then look at theSpan/Line/Columnproperties of theMarkdownObjects in the syntax tree.@xoofx commented on GitHub (Aug 30, 2023):
I agree with the problem of the delimiter and the fix from PR #736 is merged, thanks!
Otherwise regarding:
I agree with @MihaZupan here:
For the reason that we don't guarantee always keeping a link to the original string for StringSlice. Afair, there are cases where we generate a new string because we make the expansion of it, so a
StringSlicewould not always point to the original string (but in the delimiter case above, it was indeed better to keep a reference to the original StringSlice than to recreate a string)