Code Monkey home page Code Monkey logo

remark-highlight.js's Introduction

remark-highlight.js

Stability: Legacy. This package is no longer recommended for use. It’s still covered by semantic-versioning guarantees and not yet deprecated, but use of this package should be avoided. Please use remark-rehype to move from remark (markdown) to rehype (HTML) and then replace remark-highlight.js with rehype-highlight.

Legacy documentation for this package is still available in Git.

License

MIT © Ben Briggs

remark-highlight.js's People

Contributors

ai avatar ben-eb avatar eush77 avatar greenkeeperio-bot avatar s0 avatar usulpro avatar wooorm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remark-highlight.js's Issues

Missing styles

I'm using it in my md-content module and seems its not worked properly. It's just setted up classes but don't add highlight.js and styles to the page, so code between these tags is not highlighted.

Support inline code highlighting

Markdown does not define a syntax for language-specific inline code.

But is it possible to handle this (maybe optionally):

  • <code class="css">{color: red;}</code>
  • <code class="js">console.log("!!!")</code>

highlight.js v11 support?

Subject of the issue

remark-highlight.js is using an old version of lowlight and subsequently, highlight.js.
when using "resolutions" to force lowlight and highlight.js to be the latest versions, I get this error:

Must use import to load ES Module: .../node_modules/lowlight/index.js
require() of ES modules is not supported.
require() of .../node_modules/lowlight/index.js from 
.../node_modules/remark-highlight.js/dist/index.js is an ES module file as it is a .js file whose nearest parent 
package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename .../node_modules/lowlight/index.js to end in .cjs, change the requiring code to use import(), 
or remove "type": "module" from .../node_modules/lowlight/package.json.

Lowlight is already type: module: https://github.com/wooorm/lowlight/blob/main/package.json#L28

Your environment

  • OS: Ubuntu 20.04
  • Packages: remark-highlight.js 6.0.0, highlight.js 11.0.1, lowlight 2.0.1
  • Env:
    node: 14.17.0
    yarn: 1.22.0

Steps to reproduce

in package.json

"resolutions": {
    "highlight.js": "11.0.1",
    "lowlight": "2.0.1",
}

// anywhere

require('remark-highlight.js');

Unknown language: `j` is not registered

Can't do live highlighting.

I'm working a project that allows user to write markdown and do a preview of it as they are writing.

To do the writing, I'm using monaco editor, the application gets the markdown output from there and passes it down to the ReactMarkdown like this:

    <ReactMarkdown plugins={[gfm, markdownHighlight]} skipHtml={true}>
       {content}
    </ReactMarkdown>

So the application does live preview as the user types.

So when the user trys to write a code block, first they do '```' and then they specify the language like this '```jsx'.

Here where the error occurs, as soon as the user types the word j to specify the language, the app crashes. Showing this error:

Unhandled Runtime Error
Error: Unknown language: j is not registered

Any help on that?

Not working with Next Js SSG

I created my blog by following the nextjs.org docs. Is it because of Typescript?

Here is my code

  const processedContent = await remark()
    .use(highlight)
    .use(html)
    .process(matterResult.content);

no error, no highlighting, nothing...

Use in Vue and Webpack

I try to run basic example:

        const unified = require('unified')
        const markdown = require('remark-parse')
        const html = require('remark-html')
        const highlight = require('remark-highlight.js')


        let css = `~~~css
        h1 {
            color: red;
        }
        `;

        unified()
            .use(markdown)
            .use(highlight)
            .use(html)
            .process(css, (err, file) => {
                console.log(String(file))
            })

But output is still:

<pre><code class="language-css">        h1 {
            color: red;
        }   
</code></pre>

so hljs classes are missing. Whats going wrong?
Testet in latest chrome.

Option to ignore unknown languages

Subject of the feature

Would it be possible to add an option for unknown languages to be ignored rather than raising an error? Alternatively, could such errors be recorded in the vfile output of remark rather than throwing an error?

Problem

I am parsing a number of markdown documents that I don't have direct control of. Some of the documents contain invalid or unknown langauges in their code blocks.

Expected behavior

Input:

```unknown
Hello, World!
```

Expected behavious: when remark-highlight.js is passed an option call something like { ignoreUnknown: true } it ignores the unknown lanugage rather than throwing an exception.

Alternatives

I'm using processSync(). I've considered wrapping it in a try catch.

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.