Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Allow Using CSS Classes Instead of Inline Styles #46

Open
@javiereguiluz

Description

@javiereguiluz

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;">&quot;</span><spanclass="token"style="color: #9ecbff;">Hello, world!</span><spanclass="token"style="color: #9ecbff;">&quot;</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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp