From d38c63da7e62b0bdab69f44bcc26abc9794b12ba Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 14 Oct 2020 02:19:36 +0200 Subject: [PATCH] Add a default language context --- src/components/Rendering/Code.js | 6 +++++- src/contexts/CodeDefaultLanguage.js | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/contexts/CodeDefaultLanguage.js diff --git a/src/components/Rendering/Code.js b/src/components/Rendering/Code.js index 772e9eb..759a9e4 100644 --- a/src/components/Rendering/Code.js +++ b/src/components/Rendering/Code.js @@ -1,10 +1,14 @@ import SyntaxHighlighter from 'react-syntax-highlighter' import {monokai} from "react-syntax-highlighter/dist/cjs/styles/hljs"; import stripTabs from "../../utils/stripTabs"; +import {useContext} from "preact/hooks"; +import CodeDefaultLanguage from "../../contexts/CodeDefaultLanguage"; export default function(props) { + const language = useContext(CodeDefaultLanguage) + return ( - + {stripTabs(String(props.children))} ) diff --git a/src/contexts/CodeDefaultLanguage.js b/src/contexts/CodeDefaultLanguage.js new file mode 100644 index 0000000..680fcae --- /dev/null +++ b/src/contexts/CodeDefaultLanguage.js @@ -0,0 +1,3 @@ +import {createContext} from "preact"; + +export default createContext("plaintext");