- Notifications
You must be signed in to change notification settings - Fork7
Description
First, thanks a lot for creating and maintaining this project.
We developed a tool to build the Symfony Docs (https://github.com/symfony-tools/docs-builder) and, given that our docs contain tons of code samples in many languages, highlighting code is one of the most critical parts of it.
Currently, we usehttps://github.com/scrivo/highlight.php, a PHP port ofhttps://highlightjs.org/ While it works, the project does not appear to be actively maintained, and we frequently need to apply manual tweaks to support the latest PHP features. Because of this, we are interested in switching to this project.
However, during our tests, we noticed that highlighted elements use inline styles:
echo"Hello, world!";
<preclass="phiki language-php github-dark"data-language="php"style="background-color: #24292e;color: #e1e4e8;"><code><spanclass="line"><spanclass="token"style="color: #79b8ff;">echo</span><spanclass="token"></span><spanclass="token"style="color: #9ecbff;">"</span><spanclass="token"style="color: #9ecbff;">Hello, world!</span><spanclass="token"style="color: #9ecbff;">"</span><spanclass="token">;</span><spanclass="token"></span></span></code></pre>
We'd need CSS classes instead of inline styles. Our current highlighter produces output like this for the same code:
<!-- Wrapping elements removed for clarity: --><code><spanclass="hljs-keyword">echo</span><spanclass="hljs-string">'Hello, world!'</span>;</code>
To apply styles consistently across all examples, we use the following CSS classes:
.hljs-comment.hljs-keyword.hljs-title.hljs-variable-other-marker.hljs-function.hljs-string.hljs-meta.hljs-tag.hljs-name.hljs-attr.hljs-addition.hljs-deletion
The main advantages of CSS classes in our case are:
- We manage multiple versions of the documentation, including legacy versions that are no longer rebuilt. Using CSS classes allows us to update styles globally for all versions
- With CSS classes, we can customize styles dynamically based on parent elements or programming languages
Would you consider adding an option to use CSS classes instead of inline styles in this library? Thanks!