xoofx / markdig

A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
BSD 2-Clause "Simplified" License
4.2k stars 441 forks source link

Translate position from rendered HTML to markdown #770

Open joshua211 opened 4 months ago

joshua211 commented 4 months ago

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 blocwith a span from 0-24.

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

xoofx commented 4 months ago

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.