Re: Code block syntax highlighting

Klaus Malorny <[email protected]>
Newsgroups gmane.text.xml.fop.user
Message-ID <[email protected]>
On 16.09.22 14:44, Andreas Reichel wrote:
> Greetings and compliments of the day.
> 
> We use FOP successfully to generate nice PDF files for our technical 
> documentation.
> Although there is one more requirement: printing formatted code blocks 
> with syntax highlighting (e. g. SQL or Java code snippets). What would 
> be the best way to achieve that?
> 
> I have tried to convert the SQL/Java code to SVG via Pygments and to 
> insert it as EXTERNAL_GRAPHICS. This works in general, but I cant 
> control the sizing. Each EXTERNAL_GRAPHICS will have a different size of 
> characters based on the size of the graphics.
> 
> Does anyone know a better way or has done something similar already? I 
> would appreciate any idea or hint.
> Thank you in advance and best regards
> 
> Andreas
> 

Hi Andreas,

I haven't had such a problem yet, so I don't know tools that perform the 
actual syntax highlighting. But what I do not understand is why you are 
using SVG and external graphics. FO is capable of doing preformatted 
text and also of colorizing text. So no need to go that path. Since you 
using scripts anyway (as far as I understand), it shouldn't be too 
complicated to generated XML fragments to be inserted into you document.

Regards,

Klaus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.