Skip to content

Commit

Permalink
Merge pull request bonartm#30 from bonartm/29_more_languages
Browse files Browse the repository at this point in the history
29 more syntax languages
  • Loading branch information
bonartm authored Sep 7, 2022
2 parents 493b15f + 844adb8 commit e6a4437
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
14 changes: 12 additions & 2 deletions src/extensions/quizdownHighlight.ts
Original file line number Diff line number Diff line change
@@ -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....
Expand All @@ -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';
Expand Down

0 comments on commit e6a4437

Please sign in to comment.