pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

Syntax highlight for CodeBlock of OpenDocument

Open niszet opened this issue 5 years ago • 6 comments

By #6711, syntax highlighting for inline Code has been implemented. Syntax highlighting for CodeBlock is also implemented based on Docx Writer.

  • Paragraph style of CodeBlock is changed from "Preformatted_20_Text" to "Source_Code".
  • As similar to docx writer, CodeBlock is decomposed to "Code + LineBreak" lines.
  • To do this, inlineToOpenDocument Code is updated again to treat multiple lines.
  • Styles will be incorporated by Writer/ODT.hs

Further discussion will be added to #6710.

niszet avatar Oct 04 '20 03:10 niszet

OK, now I understand better than I did in your comment on the other issue. I think this approach will work, yes!

jgm avatar Oct 04 '20 15:10 jgm

Thank you for reviewing. Basically, I will continue based on this concept. But, entire of my plan to implement highlight is changed. I will write that concept to original issue #6710 (maybe tomorrow or later).

niszet avatar Oct 06 '20 16:10 niszet

Several Items of progress,

  • I found a bug in this code. CodeBlock with \n is not converted to LineBreak correctly. This is fixed locally.
  • I tried to update a test by updating writer.opendocument. But original file cannot be opened by LibreOffice (LibreOffice says this xml has format error.). To check it, I placed this file into odt as a context.xml by my hand. I'm now checking grammatically incorrect portion and will update them together.

niszet avatar Oct 09 '20 15:10 niszet

Sorry for bothering. As I updated my comment above, original write.opendocument has no problem. My misunderstanding is caused by hand insertion to odt file. Filepath of figures are not same when I use --to odt and --to opendocument. (For odt output, filenames of figure are updated by odt writer and they are incorporated into its inside) This includes update of CodeBlock and writer.opendocument for updating test.

Latest commit is excluding unintentionally incorporated local code for my test...

I will rebase and clean these commits and notice again.

niszet avatar Oct 15 '20 09:10 niszet

Can you rebase against current master so I can try this out?

jgm avatar Nov 26 '20 20:11 jgm

I rebased this here and noted a small regression: it seems that code blocks that are nested in lists are no longer indented:

Current: orange-code-block

odt_highlight: orange-code-block-new

@niszet, could you take a look?

tarleb avatar May 21 '21 16:05 tarleb