XML/Code formatting for PDF output
XML/Code formatting for PDF output
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.
-
- Propellus Maximus
- Posts: 551
- Joined: Wed Mar 05, 2008 10:50 am
Re: XML/Code formatting for PDF output
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.
Still not the easiest/most automated method, but it works.
Kellie
Re: XML/Code formatting for PDF output
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.
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.
-
- Propellus Maximus
- Posts: 1979
- Joined: Tue Nov 28, 2006 11:18 am
- Location: Crossroads of the West
- Contact:
Re: XML/Code formatting for PDF output
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
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
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
You are using prettify with PDF outputs?
Re: XML/Code formatting for PDF output
No, sorry, it's for the online help, not PDF.
Re: XML/Code formatting for PDF output
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!
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!
-
- Sr. Propeller Head
- Posts: 442
- Joined: Tue Mar 16, 2010 10:58 am
- Location: San Francisco, CA
- Contact:
Re: XML/Code formatting for PDF output
------
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
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