rocket icon indicating copy to clipboard operation
rocket copied to clipboard

Rocket: post headings should process inline markdown

Open sujato opened this issue 4 years ago • 4 comments

So, I want to add italics to a word in my heading. Sorry, no can do!

This creates several bugs. In the post heading itself (simplified):

<h1 id="bhikkhu-sujato--is-there-such-a-word-as-velāmikā">

This should be:

<h1 id="is-there-such-a-word-as-velāmikā">

Then:

<a class="anchor" href="#bhikkhu-sujato--is-there-such-a-word-as-velāmikā"></a>

Which should be:

<a class="anchor" href="#bhikkhu-sujato-is-there-such-a-word-as-velāmikā"></a>

Then the h1 content itself:

Bhikkhu Sujato &gt;&gt; Is there such a word as <em>velāmikā</em>?

which should be:

Bhikkhu Sujato: Is there such a word as <em>velāmikā</em>?

Then in the menu we find:

<li class="menu-item">
<a href="/essays/sujato/is-there-such-a-word-as-velamika/">Is there such a word as _velāmikā_?</a>
</li>

Which should be:

<li class="menu-item">
<a href="/essays/sujato/is-there-such-a-word-as-velamika/">Is there such a word as <em>velāmikā</em>?</a>
</li>

So these should be either processed properly, or at least, throw an error message.

sujato avatar Aug 14 '21 23:08 sujato

that should certainly be supported... sadly the current menu system is rather "complex" as it creates a separate nav tree via eleventy data and adds metadata to the headline/title itself... which later needs to be removed/adjusted 😅

this process means multiple html parsers, data page dependency trees, and post-processing to the actual html...

supporting html entities in there should certainly be possible... however as I'm currently working on reducing the overall complexity via https://github.com/modernweb-dev/rocket/issues/201 which should make it way easier to support such a feature... (I will make sure to add a test for it already)

in short - if you need that now (in the current system) then I would like to ask - if you could contribute... in the long run it will be fixed (although via a breaking change)

daKmoR avatar Aug 15 '21 06:08 daKmoR

hey,

now with Rocket using the @rocket/engine this already works better - but not yet perfect - so I wanna do some more improvements...

as far as I understand this is what we want right? It works for h1-h6 (h2-h6 is for in-page navigation [typically on the right])

<!-- our source is -->
<h1>Bhikkhu Sujato: Is there such a word as <em>velāmikā</em>?</h1>
<!-- In the menu it should be shown like this (e.g. get all text nodes but strip html) -->
<a href="...">Bhikkhu Sujato: Is there such a word as velāmikā</a>

<!-- if you want you can override it -->
<h1 link-text="velāmikā">Bhikkhu Sujato: Is there such a word as <em>velāmikā</em>?</h1>
<!--  would become -->
<a href="...">velāmikā</a>

<!-- it will also accept html -->
<h1 link-text="Word as <em>velāmikā</em>">Bhikkhu Sujato: Is there such a word as <em>velāmikā</em>?</h1>
<!--  would become -->
<a href="...">Word as <em>velāmikā</em></a>

Markdown

If we are in markdown and it's the top level h1 then you can also use menuLinkText

```js server
// ...
export const menuLinkText = 'Docs';
```

# Learning Rocket

Becomes

<a href="">Docs</a>

For h2-h6 only the html version, as shown above, can be used to adjust the text

Does this make sense? 🤔

daKmoR avatar Aug 14 '22 21:08 daKmoR

another related issue is that if you put a & in a headline it will be captured "strange"...

# Fun Errors & Feedback
// becomes
<a href="">Fun Errors &#x26; Feedback</a>

daKmoR avatar Aug 14 '22 22:08 daKmoR

Another related issue is

# &lt;some-button&gt;
// becomes
<a href="">&#x3C;some-button></a>

daKmoR avatar Aug 14 '22 22:08 daKmoR

I think I got all the features via https://github.com/modernweb-dev/rocket/pull/404... and is release via @rocket/[email protected]

if it did not get all feel free to reopen or create a new issue 🤗

daKmoR avatar Aug 15 '22 21:08 daKmoR