Cimbali/markdown-viewer

Double slash in fenced code block rendered as JS comment

Closed this issue · 2 comments

Hi, I have a fenced code block containing a URL - the part after a double slash is rendered as a JS comment in the preview (class="hljs-comment").

Example:

```
Invoke-WebRequest -Method Get -Uri "https://dev.sn.com/api/test" -Authentication OAuth -Token ("Mxl22..." | ConvertTo-SecureString -AsPlainText -Force)
```

HTML generated from this:

<pre><code>Invoke-WebRequest -<span class="hljs-function"><span class="hljs-keyword">Method</span> <span class="hljs-title">Get</span> -<span class="hljs-title">Uri</span> "<span class="hljs-title">https</span>:</span><span class="hljs-comment">//dev.sn.com/api/test" -Authentication OAuth -Token ("Mxl22..." | ConvertTo-SecureString -AsPlainText -Force)</span>
</code></pre>

Hi @jampattern and thanks for reporting ! I think the problems is that the dependency we use, highlight-js, is maybe not that good at detecting powershell. You can specify the language to work around the issue as follows:

```ps
Invoke-WebRequest -Method Get -Uri "https://dev.sn.com/api/test" -Authentication OAuth -Token ("Mxl22..." | ConvertTo-SecureString -AsPlainText -Force)
```

Where ps stands for powershell, but you can use any language name or file extension to force the detection.

This fixes the display for me (top without, bottom with the ps):

image

Hi @Cimbali

It dawned on me that this was purely highlight related...I should have tried setting the language explicitely.
Thanks for looking into it anyway.