rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.84k stars 969 forks source link

[FR] Syntax highlighting for odt_document (and bookdown::odt_document2) #2440

Open naikymen opened 1 year ago

naikymen commented 1 year ago

Hello!

As a LibreOffice user, I would like to have Knitted ODT documents with syntax-highlighted code chunks.

The word_document has this feature, but the odt_document output does not seem to have it.

Here is a reprex, I've knitted to DOCX and ODT, using rmakrdown and bookdown: reprex.zip

DOCX shot:

image

ODT shot:

image

I'm not certain if this is a feature request or a bug.

It may be a bug, according to this Bookdown issue: https://github.com/rstudio/bookdown/issues/1394#issuecomment-1370134795

I'd like to stick to ODT, since using DOCX as an intermediary is nightmarish.

Is highlighting possible with odt_document or odt_document2? Are there workarounds?

Thanks!

cderv commented 1 year ago

Thanks for opening the new issue. It makes things clearer to track for us.

I checked with Pandoc as the highlighting feature comes from it, and it seems it does not support highlighting for ODT. From: https://pandoc.org/MANUAL.html#syntax-highlighting

Currently highlighting is supported only for HTML, EPUB, Docx, Ms, and LaTeX/PDF output.

This mean you can't use the standard highlighting mechanism provided by Pandoc, that most of the document rely on.

I don't think we have a solution for that... Not sure there is an external tool to highlight code for ODT document. I'll do some research.

cderv commented 1 year ago

For context on the Pandoc side

It seems it is still an open feature request:

with already only inline code highlighted

But code block is still not

It seems it needs to be reactivated and it is stale 🤔