-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from affinitic/language-config
feat: Add easy language list configuration
- Loading branch information
Showing
5 changed files
with
90 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,11 @@ | ||
// Languages: https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/src/languages/hljs/supported-languages.js | ||
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'; | ||
|
||
import bash from 'react-syntax-highlighter/dist/cjs/languages/hljs/bash'; | ||
import css from 'react-syntax-highlighter/dist/cjs/languages/hljs/css'; | ||
import dockerfile from 'react-syntax-highlighter/dist/cjs/languages/hljs/dockerfile'; | ||
import javascript from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript'; | ||
import json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json'; | ||
import less from 'react-syntax-highlighter/dist/cjs/languages/hljs/less'; | ||
import markdown from 'react-syntax-highlighter/dist/cjs/languages/hljs/markdown'; | ||
import nginx from 'react-syntax-highlighter/dist/cjs/languages/hljs/nginx'; | ||
import python from 'react-syntax-highlighter/dist/cjs/languages/hljs/python'; | ||
import scss from 'react-syntax-highlighter/dist/cjs/languages/hljs/scss'; | ||
import xml from 'react-syntax-highlighter/dist/cjs/languages/hljs/xml'; | ||
import yaml from 'react-syntax-highlighter/dist/cjs/languages/hljs/yaml'; | ||
|
||
SyntaxHighlighter.registerLanguage('bash', bash); | ||
SyntaxHighlighter.registerLanguage('css', css); | ||
SyntaxHighlighter.registerLanguage('dockerfile', dockerfile); | ||
SyntaxHighlighter.registerLanguage('javascript', javascript); | ||
SyntaxHighlighter.registerLanguage('json', json); | ||
SyntaxHighlighter.registerLanguage('less', less); | ||
SyntaxHighlighter.registerLanguage('markdown', markdown); | ||
SyntaxHighlighter.registerLanguage('nginx', nginx); | ||
SyntaxHighlighter.registerLanguage('python', python); | ||
SyntaxHighlighter.registerLanguage('scss', scss); | ||
SyntaxHighlighter.registerLanguage('xml', xml); | ||
SyntaxHighlighter.registerLanguage('yaml', yaml); | ||
|
||
const LANGUAGES = [ | ||
['bash', 'Bash'], | ||
['css', 'CSS'], | ||
['dockerfile', 'Dockerfile'], | ||
['javascript', 'Javascript'], | ||
['json', 'JSON'], | ||
['less', 'LESS'], | ||
['markdown', 'Markdown'], | ||
['nginx', 'nginx'], | ||
['python', 'Python'], | ||
['scss', 'SCSS'], | ||
['yaml', 'Yaml'], | ||
['xml', 'XML'], | ||
]; | ||
|
||
export { LANGUAGES, SyntaxHighlighter }; | ||
import config from '@plone/volto/registry'; | ||
|
||
export const SyntaxHighlighterConfig = () => { | ||
const languages = config.settings.codeBlock.languages || []; | ||
languages.forEach(async (element, i) => { | ||
SyntaxHighlighter.registerLanguage(element[0], element[2]); | ||
}); | ||
return SyntaxHighlighter; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters