Page 1 of 1

XML/Code formatting for PDF output

Posted: Mon May 04, 2015 11:35 am
by bboursaw
First off, I do realize this is not a new topic and there have been several posts through the forum as well as on the web regarding code formatting - but not much for PDF output. So based on all of my research and sifting, it appears that there still is no way to easily format XML or other code to have syntax highlighting within PDF output? Maybe I have missed something throughout all of the posts and if so, I am sincerely sorry, as I'm not trying to be, "That guy." Has anyone come up with a method for better handling how code can be included in PDF output? Any recommendations or suggestions would be greatly appreciated.

Re: XML/Code formatting for PDF output

Posted: Mon May 04, 2015 4:07 pm
by techwriter31
Yeah, unfortunately most of the options out there require JavaScript and thus aren't supported in PDF outputs. We use various "pre" tags to format our code. In Flare, you can select the "pre" style and paste the code into the topic. As soon as you paste the content, there is a small clipboard displayed at the end. Click the drop-down on the clipboard and select "Paste Inline Text".

Still not the easiest/most automated method, but it works.

Re: XML/Code formatting for PDF output

Posted: Tue May 05, 2015 4:27 am
by NorthEast
If you're talking about automatic syntax highlighting using javascript, such as Google prettify, then they'll only work for web-based outputs. The syntax highlighting isn't in the built output, it's applied at run-time by the browser using javascript, which is why it won't work for PDFs.

Presumably you require a tool that you can run on your local source topic files to apply the syntax highlighting before you build the project. I'm not aware of any tools that will do that, however I've never looked for one.

Re: XML/Code formatting for PDF output

Posted: Tue May 05, 2015 11:35 am
by doc_guy
If your code absolutely *must* be prettified in the PDF documents, the easiest way is probably to store the code in text-based documents that you might even include in your Flare project. Then make the changes to the code, and take a screen shot and insert the screen shot into Flare. If you change the code, you'd need to know to update the screen shot, which is a pain, but I have found no good solution for prettifying source code in PDF. Most of the time I just don't think it is worth it, and leave the code unprettified in my PDF output. In some cases, like in API docs, or whatever, I actually use inline styles to apply colors to various elements, but this is a completely manual process, and can be a big pain in the coccyx.

Re: XML/Code formatting for PDF output

Posted: Thu May 12, 2016 11:05 am
by LeeD
Our group has been using prettify, which was working fine, until now. As it turns out, the prettify developers decided to change their access url without notifying anyone. All is well again, however, with the updated url.

Nice, huh?

We're also investigating Prism: http://www.prismjs.com, which was recommended by Scott Deloach at MadWorld. It'd be nice to have another tool in my back pocket in the event this is a recurring theme with the prettify folks.

Good luck,
Leon

Re: XML/Code formatting for PDF output

Posted: Thu May 12, 2016 10:46 pm
by NorthEast
You are using prettify with PDF outputs?

Re: XML/Code formatting for PDF output

Posted: Fri May 13, 2016 7:41 am
by LeeD
No, sorry, it's for the online help, not PDF.

Re: XML/Code formatting for PDF output

Posted: Thu Jun 02, 2016 7:44 am
by stephjnca
Hey there, Leon

Do you mind providing the updated access URL for prettify? I just noticed that the syntax highlighting is no longer working in our output.

Thanks in advance!

Re: XML/Code formatting for PDF output

Posted: Mon Aug 14, 2017 1:05 pm
by Phlawm53
------
I created a separate thread that describes how I finally got syntax-highlighted code samples to appear in both online and PDF Flare Targets:

viewtopic.php?f=6&t=29397

The essential point is that one needs to use a syntax highlighter that wraps code in inline HTML formatting. That inline HTML appears in both online and PDF outputs.

HOWEVER, it's necessary to append <br/> tags to each line of code that is terminated by a SPAN tag.

AND Flare's execrable internal text editor doesn't make the job any easier.

Cheers & hope this helps,
Riley
SFO