Qeole / Enlight

Firefox add-on providing syntax highlighting for raw code, based on the highlight.js project.
Mozilla Public License 2.0
42 stars 2 forks source link

Fix code block formatting issue by replacing `<br>` tags with newline characters #19

Closed yazpower closed 1 year ago

yazpower commented 1 year ago

This pull request (from issue 18 fixes an issue with code block formatting where <br> tags were causing the entire block to be displayed on a single line. To resolve this issue, I have modified the content.js file to replace all <br> tags inside <code></code> tags with newline characters. This ensures that the code block is formatted correctly and each line is displayed on a separate line.

I have tested this fix on Firefox and verified that it resolves the formatting issue without causing any regressions. Please review this pull request and let me know if there are any further changes or tests needed before merging.

I used the same example from the issue

before fix: image

<code class="language-markup">template &lt;typename T, typename F&gt;<br>std::vector&lt;T&gt; palter(std::vector&lt;T&gt; data, F&amp;&amp; f)<br>{<br>   ptransform(std::begin(data), std::end(data),<br>              std::forward&lt;F&gt;(f));<br>   return data;<br>}</code>

after fix: image

<code class="language-cpp hljs" style="padding: 0px; tab-size: 8;"><span class="hljs-keyword">template</span> &lt;<span class="hljs-keyword">typename</span> T, <span class="hljs-keyword">typename</span> F&gt;
<span class="hljs-function">std::vector&lt;T&gt; <span class="hljs-title">palter</span><span class="hljs-params">(std::vector&lt;T&gt; data, F&amp;&amp; f)</span>
</span>{
   <span class="hljs-built_in">ptransform</span>(std::<span class="hljs-built_in">begin</span>(data), std::<span class="hljs-built_in">end</span>(data),
              std::forward&lt;F&gt;(f));
   <span class="hljs-keyword">return</span> data;
}</code>
yazpower commented 1 year ago

Tell me when should I close the PR.

Qeole commented 1 year ago

Tell me when should I close the PR.

It will close by itself when I merge it.

Qeole commented 1 year ago

Congrats on being the first contributor to open a Pull Request for this project in its 9 years of existence! :tada: