Translate position from rendered HTML to markdown #654

Open
opened 2026-01-29 14:42:12 +00:00 by claunia · 1 comment
Owner

Originally created by @joshua211 on GitHub (Feb 12, 2024).

Hello, I have the following usecase:

I have an editor that can edit the rendered html (after parsing the markdown). I want to get the correct MarkdownObject for the rendered html in my editor. The cursor position from the editor is slighty off, due to missing characters from the original markdown, which are not rendered. Here is an example:

image

The cursor is at position 25, the Block that gets returned from FindBlockAtPosition returns the previous bloc with a span from 0-24.

How should i go about translating the UI position to the original markdown position?

Originally created by @joshua211 on GitHub (Feb 12, 2024). Hello, I have the following usecase: I have an editor that can edit the rendered html (after parsing the markdown). I want to get the correct `MarkdownObject` for the rendered html in my editor. The cursor position from the editor is slighty off, due to missing characters from the original markdown, which are not rendered. Here is an example: ![image](https://github.com/xoofx/markdig/assets/7515055/74f499b9-4e84-477d-8e8a-54cc3b4feb14) The cursor is at position 25, the `Block` that gets returned from `FindBlockAtPosition` returns the previous `bloc `with a span from 0-24. How should i go about translating the UI position to the original markdown position?
claunia added the question label 2026-01-29 14:42:12 +00:00
Author
Owner

@xoofx commented on GitHub (Feb 13, 2024):

Not sure it will be possible to do anything, but it would be better to have a simple Program.cs here that demonstrates the issue.

@xoofx commented on GitHub (Feb 13, 2024): Not sure it will be possible to do anything, but it would be better to have a simple `Program.cs` here that demonstrates the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#654