Giter VIP home page Giter VIP logo

Comments (5)

fortes avatar fortes commented on June 12, 2024

@MegaJ Yup, currently the plugin looks for all code elements ( https://github.com/fortes/metalsmith-code-highlight/blob/master/transform.js#L7 ). Wouldn't be too difficult to make this a parameter that we are able to pass into the plugin.

Your other option (and what I do on my site) is to pass in languages: [] to the plugin, which will turn off auto-detection of the language, and effectively disable the highlighting (this assumes that you are specifying language in your code blocks, which works like GitHub markdown).
screenshot 2018-01-29 at 09 38 59

from metalsmith-code-highlight.

MegaJ avatar MegaJ commented on June 12, 2024

Thanks for maintaining this repo!

I actually have the languages: [] set, and it still marks up my example DOM structure. This is in the latest version, 1.0.3. I think there's a distinction between highlighting and the metalsmith-code-highlight adding class markup to my html. I want the class markup to not appear.

The empty language setting is useful. I write html and write the class into the element like this: <pre><code class=lang-java> Without the lang-java there isn't syntax highlighting, but the hljs class is still added. This class then styles the element. This is expected because it's still pre > code.

The problem I have is when I just have li > code or p > code. The code is still marked up and styled by the hljs class, but there isn't "hightlighting" in the sense that I get colors. I mostly care about this because highlight makes .hljs elements display: block (and of course this depends on the theme, though I think most make it a block). Sure, I can override this with my own CSS, but that's more CSS architecture, and more markup in a plain <code> element, that should be by default, display: inline.

I modified the query selector to pre > code and it worked the way I wanted to. I am in favor of a parameter being added, as I don't want to maintain my own version of metalsmith-code-highlight.

If a parameter is being added, should we just allow the user to specify their own query selector? highlight.js has no setting to change selectors that I'm aware of, so the user should probably only put in some combination of pre and/or code with whatever combinators.

from metalsmith-code-highlight.

fortes avatar fortes commented on June 12, 2024

If a parameter is being added, should we just allow the user to specify their own query selector? highlight.js has no setting to change selectors that I'm aware of, so the user should probably only put in some combination of pre and/or code with whatever combinators.

My first attempt would be to have a parameter with a default value of code, then people can override and set whatever they want (pre > code in your case)

If you have time, feel free to send a PR! :)

from metalsmith-code-highlight.

MegaJ avatar MegaJ commented on June 12, 2024

@fortes Give me a little time. I think I have repetitive strain injury from the keyboard.

from metalsmith-code-highlight.

MegaJ avatar MegaJ commented on June 12, 2024

Yay, merged and happy.

from metalsmith-code-highlight.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.