Code Monkey home page Code Monkey logo

highlight-loader's Issues

Allow highlighter to be swapped?

It might make sense to decouple the loader from highlight.js. Maybe it could still remain as default. Allowing it to be replaced with something else could be a good move.

Make hightlight.js a peer dependency

Please make highlight.js a peer dependency as recommended by webpack.

Peer Dependencies

If the loader you're working on is a simple wrapper around another package, then you should include the package as a peerDependency. This approach allows the application's developer to specify the exact version in the package.json if desired.

For instance, the sass-loader specifies node-sass as peer dependency like so:

{
  "peerDependencies": {
    "node-sass": "^4.0.0"
  }
}

https://webpack.js.org/contribute/writing-a-loader/#peer-dependencies

Option to receive both raw and highlighted code

I'd love to get both raw and highlighted code from the input file.

Right now my workaround is to require it twice: once with the raw-loader, once with the highlight-loader.

I'd love it if I could set an option on this loader to export an object instead of a string — an object with raw and highlighted properties.

What do you think? (Happy to work on a PR if you like the idea.)

Highlight raw files

I would like to be able to use this in combination with raw-loader to highlight raw files that do not contain the <code> tag (or any HTML).

For example, I'd like to:

var myCodeHighlighted = require('!!raw!highlight!myCode.js');

Any interest in adding this feature? If so, I could work on a PR for it.

Adding "Copy to Clipboard"

I would like to add a copy to clipboard option to the code section. I wonder how I can do it.

One option is to add the button using css :after and then listen to click events. However I still need to be able to get raw content from somewhere. Is it possible to add it as, for example, data-raw attribute to the code element?

Inline language declaration throws unknown language

I'm using this with the markdown and html loaders as shown in the examples here. However, if my markdown code block uses inline language declaration then it throws errors about an unknown language.

ERROR in ./src/components/switch/docs/readme.md
Module build failed: Error: Unknown language: "language-typescript"
    at highlight (C:\dev\WebCommon-HtmlShare\node_modules\highlight.js\lib\highlight.js:494:13)
    at highlightCode (C:\dev\WebCommon-HtmlShare\node_modules\highlight-loader\index.js:50:12)
    at Object.<anonymous> (C:\dev\WebCommon-HtmlShare\node_modules\highlight-loader\index.js:38:12)
    at initialize.<anonymous> (C:\dev\WebCommon-HtmlShare\node_modules\cheerio\lib\api\manipulation.js:275:74)
    at exports.domEach (C:\dev\WebCommon-HtmlShare\node_modules\cheerio\lib\utils.js:52:24)
    at initialize.exports.replaceWith (C:\dev\WebCommon-HtmlShare\node_modules\cheerio\lib\api\manipulation.js:268:3)
    at Object.module.exports (C:\dev\WebCommon-HtmlShare\node_modules\highlight-loader\index.js:25:13)
 @ ./src/components/switch/docs/index.ts 4:0-48 4:0-48
 @ ./src/docs.ts
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./src/docs.ts
i 「wdm」: Failed to compile.

the portion causing the problem in the md file:

```typescript
import { Switch } from '@salespad/html-share';
const switch = new Switch(document.getElementById('switch-example'));
/```

and the relevant portion of the config:

{
          test: /\.md$/,
          loader: 'html-loader!highlight-loader!markdown-loader'
}

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.