Markdown heading HTML IDs (or better text
/ id
implementation)
#203
-
Dear SQLPagers, I'm wondering if there's a way to add HTML ids to markdown headings, etc -- particularly helpful for inner document links (ie, mysite.xyz#my_subheading) For instance, one might do the following: <!-- traditional approach -->
<h2 id='my_subheading'>My subheading here</h2>
<!-- some markdown parsers support this -->
## My subheading {#subheading} SQLPage doesn't seem to support either as the traditional tag approach escapes the HTML characters, and the custom syntax is not supported by the SQLPage markdown parser. NOTE: I initially thought the select 'text' as component,
'about' as id,
sqlpage.read_file_as_text('info/about.md') as contents_md; renders something like the following: <!-- markdown gets rendered as HTML first -->
<h2>My subheading</h2>
<p>My content . . .</p>
<p id="about"></p> <!-- then SQLPage kicks in with the `text` container --> ☝️ That being said, there is a workaround: calling the select 'text' as component,
'about' as id;
select sqlpage.read_file_as_text('assets/info/about.md') as contents_md; This puts a blank paragraph with the <p id="about"></p> <!-- SQLPage kicks in with the `text` container first -->
<!-- markdown gets rendered as HTML subsequently -->
<h2>My subheading</h2>
<p>My content . . .</p> This does work, albeit a little hacky (as the markdown content is not given the id -- some rando paragraph prior gets it 😄). Although the paragraph does provide some nice margin on top the content when you do scroll to it ...👏 Still, I think allowing markdown headings IDs could be a more elegant solution. Any ideas? 🤔 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The id coming after the rendered markdown was an oversight. This should be fixed. Can you test the latest build ? |
Beta Was this translation helpful? Give feedback.
-
Concerning new markdown syntax options, you can propose them / open pull requests on https://github.com/wooorm/markdown-rs |
Beta Was this translation helpful? Give feedback.
The id coming after the rendered markdown was an oversight. This should be fixed. Can you test the latest build ?