asjqkkkk / markdown_widget

📖Rendering markdown by flutter!Welcome for pr and issue.
MIT License
312 stars 90 forks source link

Link that jumps to a section in the page #171

Open sapphire008 opened 4 months ago

sapphire008 commented 4 months ago

How do I create within-page relative links so that when a user clicks on one of the links, the app scrolls to the corresponding section of the document? I know TOC somewhat implements this functionality, but I wonder if we can also create inline links to link document sections.

Example of Inline TOC (but does not have to limit to TOC use case): Suppose I have the following markdown:

TOC

[Link 1](#ref1)
[Link 2](#ref2)
[Link 3](#ref3)

# Title 1{#ref1}

Lorem Ipsum ....

## Title 2{#ref2}

Lorem Ipsum ....

Text 1{#ref3}

Clicking on Link 1 should jump to Title 1 which is H1; Clicking on Link 2 should jump to Title 2, which is H2; and clicking Link 3 should jump to Text 1, which is an inline text.

asjqkkkk commented 4 months ago

Hi @sapphire008 , this is closer to a business requirement. You can try using the onTap of LinkConfig, combined with url, to achieve custom navigation.