-
-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #1235 [Site] Remove highlight.php (smnandre)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Site] Remove highlight.php | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | Issues | Fix [#683](#683) | License | MIT Remove highlight.php and use highlight.js directly. (highlight.php is in fact abandonned) Commits ------- 572d719 [Site] Remove highlight.php
- Loading branch information
Showing
9 changed files
with
87 additions
and
111 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
ux.symfony.com/assets/controllers/code-highlighter-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
import hljs from 'highlight.js/lib/core'; | ||
import hljs_javascript from 'highlight.js/lib/languages/javascript'; | ||
import hljs_php from 'highlight.js/lib/languages/php'; | ||
import hljs_xml from 'highlight.js/lib/languages/xml'; | ||
import hljs_twig from 'highlight.js/lib/languages/twig'; | ||
|
||
hljs.registerLanguage('javascript', hljs_javascript); | ||
hljs.registerLanguage('php', hljs_php); | ||
hljs.registerLanguage('twig', hljs_twig); | ||
// xml is the language used for HTML | ||
hljs.registerLanguage('xml', hljs_xml); | ||
|
||
export default class extends Controller { | ||
static targets = ['codeBlock']; | ||
|
||
codeBlockTargetConnected() { | ||
this.codeBlockTargets.forEach(this.#highlightCodeBlock) | ||
} | ||
|
||
#highlightCodeBlock(codeBlock) { | ||
if (codeBlock.dataset.highlighted) { | ||
return; | ||
} | ||
hljs.highlightElement(codeBlock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters