bebraw / highlight-loader Goto Github PK
View Code? Open in Web Editor NEWApplies highlight.js to given HTML (MIT)
Home Page: https://www.npmjs.org/package/highlight-loader
License: MIT License
Applies highlight.js to given HTML (MIT)
Home Page: https://www.npmjs.org/package/highlight-loader
License: MIT License
When parsing markdown (the suggested use for this loader) the hljs
class does not get applied to the pre element, causing all built in themes to not render the container correctly.
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.
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 thepackage.json
if desired.For instance, the
sass-loader
specifiesnode-sass
as peer dependency like so:{ "peerDependencies": { "node-sass": "^4.0.0" } }
https://webpack.js.org/contribute/writing-a-loader/#peer-dependencies
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.)
I'm trying to use this module server-side on my NodeJS app.
this.cacheable()
is not there.
Since markdown-loader
3.0.0, as it follows marked
0.4.0, language prefix is changed from lang
to language
, but this loader only accepts lang
.
I know highlight.js don't support line number. Whether we can add this feature?
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.
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?
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'
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.