Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ignore config to ignore langs from other plugins #29

Merged
merged 4 commits into from
Aug 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ Support non-standard syntax prefixes by aliasing existing prefixes.
}
```

### `ignore`
Due to other plugins using code block notion to denote other functionality, you can ignore certain langs

```json
"pluginsConfig": {
"prism": {
"ignore": [
"mermaid",
"eval-js"
]
}
}
```

### Prism Themes

[https://github.com/PrismJS/prism](https://github.com/PrismJS/)
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ module.exports = {

var highlighted = '';
var userDefined = getConfig(this, 'pluginsConfig.prism.lang', {});
var userIgnored = getConfig(this, 'pluginsConfig.prism.ignore', []);

// Normalize language id
var lang = block.kwargs.language || DEFAULT_LANGUAGE;
lang = userDefined[lang] || MAP_LANGUAGES[lang] || lang;

// Check to see if the lang is ignored
if (userIgnored.indexOf(lang) > -1) {
return block.body
}

// Try and find the language definition in components folder
if (!languages[lang]) {
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "gitbook-plugin-prism",
"description": "Prism highlighting for gitbook",
"main": "index.js",
"version": "2.2.1",
"version": "2.3.1",
"scripts": {
"lint": "eslint index.js test.js",
"test": "npm run lint && tape test.js"
Expand Down