jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.81k stars 3.39k forks source link

gfm doesn't render color in diff blocks #10364

Closed csm10495 closed 2 weeks ago

csm10495 commented 2 weeks ago

Explain the problem. Link: https://pandoc.org/try/?params=%7B%22text%22%3A%22%23+Comparing+%601.cfg%60+%26+%602.cfg%60%5Cn%5Cn+*+*Ordering+differences+only*%5Cn%5Cn%60%60%60diff%5Cn%40%40+-29612%2C20+%2B29612%2C20+%40%40%5Cn%2B++++apple+sauce%5Cn-++++tomatoes%5Cn%60%60%60%5Cn%5Cn%22%2C%22to%22%3A%22html5%22%2C%22from%22%3A%22markdown%22%2C%22standalone%22%3Afalse%2C%22embed-resources%22%3Afalse%2C%22table-of-contents%22%3Afalse%2C%22number-sections%22%3Afalse%2C%22citeproc%22%3Afalse%2C%22html-math-method%22%3A%22plain%22%2C%22wrap%22%3A%22auto%22%2C%22highlight-style%22%3Anull%2C%22files%22%3A%7B%7D%2C%22template%22%3Anull%7D

To locally reproduce, take 1.md : 1.md

then run it through pandoc like so:

pandoc -f gfm /tmp/1.md > /tmp/1b.html

open /tmp/1b.html and there won't be green for added lines and red for removed lines. Github markdown notices this pattern to render diffs.

For example:

@@ -29612,20 +29612,20 @@
+    apple sauce
-    tomatoes

Markdown preview in vscode also properly renders it: image

Pandoc version?

pandoc --version
pandoc 3.5
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /Users/cmachalo/.local/share/pandoc
Copyright (C) 2006-2024 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

On a M2 Macbook

jgm commented 2 weeks ago

You have "no highlighting" selected in try pandoc. If you don't select this, you'll get highlighting. https://pandoc.org/try/?params=%7B%22text%22%3A%22%23+Comparing+%601.cfg%60+%26+%602.cfg%60%5Cn%5Cn+*+*Ordering+differences+only*%5Cn%5Cn%60%60%60diff%5Cn%40%40+-29612%2C20+%2B29612%2C20+%40%40%5Cn%2B++++apple+sauce%5Cn-++++tomatoes%5Cn%60%60%60%5Cn%5Cn%22%2C%22to%22%3A%22html5%22%2C%22from%22%3A%22markdown%22%2C%22standalone%22%3Afalse%2C%22embed-resources%22%3Afalse%2C%22table-of-contents%22%3Afalse%2C%22number-sections%22%3Afalse%2C%22citeproc%22%3Afalse%2C%22html-math-method%22%3A%22plain%22%2C%22wrap%22%3A%22auto%22%2C%22highlight-style%22%3A%22pygments%22%2C%22files%22%3A%7B%7D%2C%22template%22%3Anull%7D

jgm commented 2 weeks ago

Using pandoc on the command line, you'll need to add -s (for "standalone" document) in order to get the necessary CSS definitions.

jgm commented 2 weeks ago
pandoc -f gfm /tmp/1.md -s -o /tmp/1b.html