syntax.mdx 1015 B

1234567891011121314151617181920212223242526272829303132
  1. ---
  2. title: Syntax Highlighter Module
  3. ---
  4. The Syntax Module enhances the Code Block format by automatically detecting and applying syntax highlighting. The excellent [highlight.js](https://highlightjs.org/) library is used as a dependency to parse and tokenize code blocks.
  5. In general, you may [configure](https://highlightjs.readthedocs.io/en/latest/api.html#configure-options) highlight.js as needed. However, Quill expects and requires the `useBR` option to be `false`.
  6. ### Example
  7. ```html
  8. <!-- Include your favorite highlight.js stylesheet -->
  9. <link href="highlight.js/monokai-sublime.min.css" rel="stylesheet">
  10. <!-- Include the highlight.js library -->
  11. <script href="highlight.js"></script>
  12. <script>
  13. hljs.configure({ // optionally configure hljs
  14. languages: ['javascript', 'ruby', 'python']
  15. });
  16. const quill = new Quill('#editor', {
  17. modules: {
  18. syntax: true, // Include syntax module
  19. toolbar: [['code-block']] // Include button in toolbar
  20. },
  21. theme: 'snow'
  22. });
  23. </script>
  24. ```