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

Fix escape character #2468

Merged
merged 1 commit into from
Nov 18, 2021
Merged

Fix escape character #2468

merged 1 commit into from
Nov 18, 2021

Conversation

Kevan-Y
Copy link
Contributor

@Kevan-Y Kevan-Y commented Nov 15, 2021

Issue This PR Addresses

Fixes #2457

Type of Change

  • Modified our highlight syntax function
  • Adjust test case
  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

The current way of doing it causing some weird bug.
highlightAuto() seems to run an encode to change value to escape character. And when we have our data with preset syntax-highlight span. It is converting weirding.

For example:

<pre class="hljs language-bash"><code><span class="o">&amp;&amp;</span></code></pre>

Will convert to

<pre class="hljs language-bash xml"><code class="hljs language-bash"><span class="hljs-symbol">&amp;</span>amp;<span class="hljs-symbol">&amp;</span>amp;</code></pre>

I upgraded to the latest version, it kind of fixed itself but some didn't.
Finally solution was to change to use this https://highlightjs.readthedocs.io/en/latest/api.html#highlightelement
That will highlight the syntax+ add class (for language) in code tag instead of pre tag.

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@Kevan-Y Kevan-Y requested review from humphd and manekenpix November 15, 2021 03:09
@gitpod-io
Copy link

gitpod-io bot commented Nov 15, 2021

humphd
humphd previously approved these changes Nov 16, 2021
Copy link
Contributor

@mkim219 mkim219 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kevan-Y I have question for you. What if language has not been detected on the syntax-highlight.js?

@Kevan-Y
Copy link
Contributor Author

Kevan-Y commented Nov 18, 2021

@Kevan-Y I have question for you. What if language has not been detected on the syntax-highlight.js?

highlight.js library, have an auto-detect language. This is the [languages support] (https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md), but can also set what language to be used

@Kevan-Y
Copy link
Contributor Author

Kevan-Y commented Nov 18, 2021

Rebased to master.

@mkim219 mkim219 self-requested a review November 18, 2021 15:59
Copy link
Contributor

@mkim219 mkim219 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: our front-end uses the CSS for this, do we need to do an update in src/web/* as well?

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it's already updated,

"highlight.js": "11.3.1",
. This should be good to go.

@humphd humphd merged commit 2a35380 into Seneca-CDOT:master Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - && not displaying correctly in post
4 participants