-
-
Notifications
You must be signed in to change notification settings - Fork 365
[Site] switch from highlight.js
to tempest/highlight
#1808
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,74 @@ | ||
.hljs-comment, .hljs-prompt { | ||
color: #8b949e; | ||
user-select: none; | ||
-webkit-user-select: none | ||
/** tempest/highlight theme (https://github.com/tempestphp/highlight/blob/main/src/Themes/Css/dracula.css) */ | ||
.hl-keyword { | ||
color: #FF79C6; | ||
} | ||
|
||
.codeblock-terminal .hljs-keyword { | ||
color: #6a737d; | ||
.hl-property { | ||
color: #50FA7B; | ||
} | ||
|
||
.codeblock-terminal .hljs-prompt { | ||
color: #8b949e; | ||
user-select: none; | ||
-webkit-user-select: none | ||
.hl-attribute { | ||
font-style: italic; | ||
} | ||
|
||
.codeblock-terminal .hljs-string { | ||
color: #a5d6ff | ||
.hl-type { | ||
color: #8BE9FD; | ||
} | ||
|
||
.hljs-keyword { | ||
color: #ff7b72 | ||
.hl-generic { | ||
color: #9d3af6; | ||
} | ||
|
||
.hljs-title { | ||
color: #ffa657 | ||
.hl-value { | ||
color: #F1FA8C; | ||
} | ||
|
||
.hljs-variable-other-marker { | ||
color: #79c0ff | ||
.hl-variable { | ||
color: #F8F8F2; | ||
} | ||
|
||
.hljs-function .hljs-title { | ||
color: #d2a8ff | ||
.hl-comment { | ||
color: #6272A4; | ||
} | ||
|
||
.hljs-string { | ||
color: #a5d6ff | ||
.hl-blur { | ||
filter: blur(2px); | ||
} | ||
|
||
.hljs-attr, .hljs-tag .hljs-name { | ||
color: #7ee787 | ||
.hl-strong { | ||
font-weight: bold; | ||
} | ||
|
||
.hljs-tag .hljs-attr { | ||
color: #d2a8ff | ||
.hl-em { | ||
font-style: italic; | ||
} | ||
|
||
.hl-addition { | ||
display: inline-block; | ||
min-width: 100%; | ||
background-color: #00FF0022; | ||
} | ||
|
||
.hl-deletion { | ||
display: inline-block; | ||
min-width: 100%; | ||
background-color: #FF000011; | ||
} | ||
|
||
.hl-gutter { | ||
display: inline-block; | ||
font-size: 0.9em; | ||
color: #555; | ||
padding: 0 1ch; | ||
user-select: none; | ||
} | ||
|
||
.hljs-addition { | ||
background: rgba(46, 160, 67, .3); | ||
outline: 3px solid rgba(46, 160, 67, .3) | ||
.hl-gutter-addition { | ||
background-color: #34A853; | ||
color: #fff; | ||
} | ||
|
||
.hljs-deletion { | ||
background: rgba(218, 54, 51, .3); | ||
outline: 3px solid rgba(218, 54, 51, .3) | ||
.hl-gutter-deletion { | ||
background-color: #EA4334; | ||
color: #fff; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,10 @@ | |
namespace App\Service\CommonMark; | ||
|
||
use League\CommonMark\CommonMarkConverter; | ||
use League\CommonMark\Extension\CommonMark\Node\Block\FencedCode; | ||
use League\CommonMark\Extension\ExternalLink\ExternalLinkExtension; | ||
use League\CommonMark\Extension\Mention\MentionExtension; | ||
use Symfony\Component\DependencyInjection\Attribute\AsDecorator; | ||
use Tempest\Highlight\CommonMark\HighlightExtension; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
|
@@ -44,9 +44,9 @@ public function __invoke(): CommonMarkConverter | |
]); | ||
|
||
$converter->getEnvironment() | ||
->addRenderer(FencedCode::class, new CodeRenderer(), 10) | ||
->addExtension(new ExternalLinkExtension()) | ||
->addExtension(new MentionExtension()) | ||
->addExtension(new HighlightExtension()) | ||
; | ||
|
||
return $converter; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace App\Twig; | ||
|
||
use Tempest\Highlight\Highlighter; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
final class HighlightExtension extends AbstractExtension | ||
{ | ||
public function getFilters(): array | ||
{ | ||
return [ | ||
new TwigFilter('highlight', [Highlighter::class, 'parse'], ['is_safe' => ['html']]), | ||
]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{% props highlight = false, code = '', height = null %} | ||
{% props code = '', height = null %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I broke highlighting here and was unsure on how to fix. @smnandre, what do you think about merging this component with |
||
|
||
<div | ||
class="IconModal__code" | ||
data-controller="clipboarder {% if highlight %} code-highlighter{% endif %}" | ||
data-controller="clipboarder" | ||
> | ||
{% set __code -%} | ||
{% block content -%} | ||
|
@@ -13,7 +13,7 @@ | |
<pre | ||
{% if height %} style="--height: {{ height }}" {% endif %} | ||
data-clipboarder-target="source" | ||
><code {% if highlight %} data-code-highlighter-target="codeBlock" {% endif %}>{{ __code ? __code|trim|raw : code }}</code></pre> | ||
><code>{{ __code ? __code|trim|raw : code }}</code></pre> | ||
|
||
<button class="btn btn-sm IconModal__copy" data-action="clipboarder#copy" data-clipboarder-target="button"> | ||
<twig:Icon name="copy" /> | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smnandre, perhaps you can create a follow-up PR to adjust the styles/theme (I may have broken some stuff (ie
.codeblock-terminal .hljs-keyword
).BTW, I just randomly picked a dark theme here.