Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unreadable code blocks. #312

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

WetHat
Copy link

@WetHat WetHat commented Apr 2, 2024

This fixes issue #191, #272, and most likely #278

The ugly flattened rendering of code blocks is caused by the removal of the <code> element from its owning <pre>. code.innerText loses all spacings and linefeeds. In addition, a second fix was needed because all tab characters \t were stripped in the turndown function (background.js). This caused code blocks to lose all indents.

This part of the fix addresses the site:

The links to Medium articles are a different story. The code in these articles are not proper code blocks.
They look like this:

<pre>$ curl https://<span class="hljs-built_in">get</span>.docker.<span class="hljs-keyword">com</span> | <span class="hljs-keyword">sh</span></pre>

The code has been pre-processed, and then stuck directly under a <pre> tag. No <code> element present.

This is addressed by the second part of the fix which returns the content of <pre> elements as text rather than html. However, there is no syntax highlighting due to the missing <code> element.

This addresses:

#278 is most likely fixed too, but I were not able to test this.

… was ripped

out from its owning 'pre' and the code.innerText lost all spacings and linefeeds.
In addition a second fix was needed because all tabs where stripped in the
turndown function (bachground.js). This caused code to loose indent and look
unreadable.
…ich do not

contain a `<code>` cild element. This allows `<pre>` blocks to be rendered
as markdown fenced blocks.
@WetHat WetHat changed the title Fixed flattened code blocks. Fixed unreadable code blocks. Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant