@gridsome/remark-prismjs
Advanced tools
Comparing version 0.0.3 to 0.0.4
38
index.js
const Prism = require('prismjs') | ||
const escapeHtml = require('escape-html') | ||
const visit = require('unist-util-visit') | ||
const loadLanguages = require('prismjs/components/index') | ||
module.exports = options => { | ||
loadLanguages(['graphql']) | ||
// load all prismjs languages | ||
require('prismjs/components/index')() | ||
// highlight for graphql and static-query tags in html | ||
Prism.languages.html.graphql = { | ||
pattern: /(<(page|static)-query[\s\S]*?>)[\s\S]*?(?=<\/(page|static)-query>)/i, | ||
inside: Prism.languages.graphql, | ||
lookbehind: true, | ||
greedy: true | ||
} | ||
// highlight page-query and static-query in html | ||
Prism.languages.html.graphql = { | ||
pattern: /(<(page|static)-query[\s\S]*?>)[\s\S]*?(?=<\/(page|static)-query>)/i, | ||
inside: Prism.languages.graphql, | ||
lookbehind: true, | ||
greedy: true | ||
} | ||
return tree => { | ||
visit(tree, 'code', node => { | ||
node.type = 'html' | ||
node.value = highlight(node, 'pre') | ||
}) | ||
module.exports = () => tree => { | ||
visit(tree, 'code', node => { | ||
node.type = 'html' | ||
node.value = highlight(node, 'pre') | ||
}) | ||
visit(tree, 'inlineCode', node => { | ||
node.type = 'html' | ||
node.value = highlight(node, 'code') | ||
}) | ||
} | ||
visit(tree, 'inlineCode', node => { | ||
node.type = 'html' | ||
node.value = highlight(node, 'code') | ||
}) | ||
} | ||
@@ -29,0 +27,0 @@ |
{ | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"name": "@gridsome/remark-prismjs", | ||
@@ -25,3 +25,3 @@ "description": "Prism for Gridsome", | ||
}, | ||
"gitHead": "f096e39ab2b5eb3413dc9fe27cff3f48ed9ea033" | ||
"gitHead": "8232162038e7431cd0e02096bb73c02d99a90012" | ||
} |
@@ -5,2 +5,6 @@ # @gridsome/remark-prismjs | ||
## Install | ||
- `yarn add @gridsome/remark-prismjs` | ||
- `npm install @gridsome/remark-prismjs` | ||
## Usage | ||
@@ -7,0 +11,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4745
5
52
32