From e69f0d1f4fa43f5840391998a4eed4125df8c2f7 Mon Sep 17 00:00:00 2001 From: Leon Hunter Date: Tue, 30 Aug 2022 21:17:53 -0400 Subject: [PATCH 1/2] added the following languages to hljs language registry: bash, batch, java, javascript, typescript --- src/extensions/quizdownHighlight.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/extensions/quizdownHighlight.ts b/src/extensions/quizdownHighlight.ts index cd05225..31d12e9 100644 --- a/src/extensions/quizdownHighlight.ts +++ b/src/extensions/quizdownHighlight.ts @@ -1,7 +1,12 @@ import hljs from 'highlight.js/lib/core'; +import bash from 'highlight.js/lib/languages/bash'; +import batch from 'highlight.js/lib/languages/dos'; +import java from 'highlight.js/lib/languages/java'; +import javascript from 'highlight.js/lib/languages/javascript'; +import plaintext from 'highlight.js/lib/languages/plaintext'; import python from 'highlight.js/lib/languages/python'; +import typescript from 'highlight.js/lib/languages/typescript'; import xml from 'highlight.js/lib/languages/xml'; -import plaintext from 'highlight.js/lib/languages/plaintext'; import type { QuizdownExtension } from '../quizdown.js'; // this does not work.... @@ -10,9 +15,14 @@ import type { QuizdownExtension } from '../quizdown.js'; // hljs.registerLanguage(langName, langModule); // }); +hljs.registerLanguage('bash', bash); +hljs.registerLanguage('batch', batch); +hljs.registerLanguage('java', java); +hljs.registerLanguage('javascript', javascript); +hljs.registerLanguage('plaintext', plaintext); hljs.registerLanguage('python', python); +hljs.registerLanguage('typescript', typescript); hljs.registerLanguage('html', xml); -hljs.registerLanguage('plaintext', plaintext); function highlighter(code, language) { const validLanguage = hljs.getLanguage(language) ? language : 'plaintext'; From 844adb8895fd3233723aabea8298034db29ad278 Mon Sep 17 00:00:00 2001 From: bonartm <17472848+bonartm@users.noreply.github.com> Date: Wed, 7 Sep 2022 18:54:56 +0200 Subject: [PATCH 2/2] update docs --- docs/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/syntax.md b/docs/syntax.md index c4054b3..7fc7973 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -6,7 +6,7 @@ can therefore be easily inspected in common markdown editors like GitHub, Typora - Each quiz question begins with a header: `### How are you?`. The level of the headline has no influence on the appearance. - You can add images, code, bold text, links using markdown formatting. -- Quizdown uses `highlight.js` for syntax highlighting. Currently, only python and html code is highlighted. +- Quizdown uses `highlight.js` for syntax highlighting. - *Blockquotes* are used for rendering (hidden) hints and comments. Here is an example that shows many features (edit in the [🚀quizdown editor](https://bonartm.github.io/quizdown-live-editor/?code=%23%23%23%23%20Who%20is%20the%20person%20in%20the%20picture%3F%0A%0A!%5B%5D(https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F9%2F9d%2FSir_Tim_Berners-Lee.jpg%2F330px-Sir_Tim_Berners-Lee.jpg)%0A%0A%3E%20In%201990%2C%20he%20published%20the%20%5Bworlds%20first%20website%5D(http%3A%2F%2Finfo.cern.ch%2Fhypertext%2FWWW%2FTheProject.html).%0A%0A1.%20%5Bx%5D%20Tim%20Berners-Lee%0A%20%20%20%20%3E%20This%20is%20the%20correct%20answer!%0A1.%20%5B%20%5D%20Alan%20Turing%0A1.%20%5B%20%5D%20Barbara%20Liskov%0A1.%20%5B%20%5D%20Larry%20Page%0A%20%20%20%20%3E%20This%20is%20not%20Larry%20Page%20%3B)):