Skip to content

Is code syntax highlighting available as an extension? #12403

Answered by cscheid
rossbowen asked this question in Q&A
Discussion options

You must be logged in to vote

It's done by Pandoc automatically, and happens even with theme: none and minimal: true. Inspect your resulting HTML to see it.

---
format: 
  html:
    theme: none
    minimal: true
---

```python
print("hello world")
```

Relevant output:

<body>





<div class="sourceCode" id="cb1"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb1-1"><a href="[#cb1-1](view-source:http://localhost:6853/#cb1-1)" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="st">"hello world"</span>)</span></code></pre></div>





</body>

All you need is to provide CSS rules for bu, st, etc. See https://pandoc.org/chunkedhtml-demo/13-syntax-highlighting.html

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rossbowen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
themes Related to HTML theming or any other style related issue (like highlight-style)
2 participants