Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
feat(Prism addon): Add prisom addon for syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Feb 19, 2020
1 parent 5f2a4bc commit 967fe53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/addons/prism/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Prism addon

Syntax highlighting for `CodeFragment` and `CodeBlock` nodes using [Prism](https://prismjs.com/). You can also use this addon to style executable node types like `CodeExpression` and `CodeChunk` if you do not use the `stencila-components` addon.

## Notes

- Currently this addon renders syntax highlighting in the browser. In the future, we may take a similar approach as for MathJax and pre-render HTML in Encoda. See "Usage with Node" on https://prismjs.com/.

- Currently, syntax highlighting is only enabled for a limited number of languages. There is a https://prismjs.com/plugins/autoloader/ plugin but that would not be usable with are Parcel bundling approach. That is one reason in favor of doing pre-rending in Encoda - a reader would not have to load the Javascript to every language.

- There are many [plugins](https://prismjs.com/plugins) that may be appropriate to either add here, or as other addons e.g. `prism-line-numbers`.
3 changes: 3 additions & 0 deletions src/addons/prism/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'prismjs'
import 'prismjs/components/prism-python'
import 'prismjs/components/prism-r'
1 change: 1 addition & 0 deletions src/addons/prism/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'prismjs/themes/prism.css';

0 comments on commit 967fe53

Please sign in to comment.