Fast way to tidy / prettify Java, XML, HTML code samples?
-
Phlawm53
- Sr. Propeller Head
- Posts: 442
- Joined: Tue Mar 16, 2010 10:58 am
- Location: San Francisco, CA
- Contact:
Fast way to tidy / prettify Java, XML, HTML code samples?
My hope is that someone has figured out a quick and more or less repetitively automated way to get code samples into Flare topic files so that the samples look good. Right now I have a big mess on my hands -- I need to figure out how to efficiently format imported Java, XML, and HTML code samples.
I have a word document that itself is not very well formatted. The document contains *many* XML, as well as some Java and HTML samples. I can't figure out an automated way to format these in Flare so that they're properly indented, etc.
The samples haven't imported very nicely. And attempts to work with them either in Flare or outside of Flare then copy the samples back in (to a single-cell table with a light-gray background, for what that's worth) aren't working.
Right now I'm manually going through the samples, finding tags and so on, then manually applying prettifying keystrokes. But I have NOT had much luck with the following:
- Copying the samples to a structure-savvy text editor, using the text editor's Tidy or Pretty plug-in to clean the stuff up, then copy-and-pasting that input into Flare. Flare, ignores the text editor's EOL characters and indentation, so the pasted-in samples remain a mess.
- In Flare's source-editor (versus WYSIWYG topic editor), using Find-Replace to try and insert <br> notations and the like. Flare isn't doing this quite right and even when I can make it work, it doesn't handle indentations properly.
Any ideas? I've got a *bunch* of this to do and I'm not making much progress.
Cheers & thanks,
Riley
I have a word document that itself is not very well formatted. The document contains *many* XML, as well as some Java and HTML samples. I can't figure out an automated way to format these in Flare so that they're properly indented, etc.
The samples haven't imported very nicely. And attempts to work with them either in Flare or outside of Flare then copy the samples back in (to a single-cell table with a light-gray background, for what that's worth) aren't working.
Right now I'm manually going through the samples, finding tags and so on, then manually applying prettifying keystrokes. But I have NOT had much luck with the following:
- Copying the samples to a structure-savvy text editor, using the text editor's Tidy or Pretty plug-in to clean the stuff up, then copy-and-pasting that input into Flare. Flare, ignores the text editor's EOL characters and indentation, so the pasted-in samples remain a mess.
- In Flare's source-editor (versus WYSIWYG topic editor), using Find-Replace to try and insert <br> notations and the like. Flare isn't doing this quite right and even when I can make it work, it doesn't handle indentations properly.
Any ideas? I've got a *bunch* of this to do and I'm not making much progress.
Cheers & thanks,
Riley
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
I think what you're looking for is the <pre></pre> style class. If you select a paragraph one of the options is "pre". When you mark up a section of text with pre, it tells the browser to respect the tabs, spaces, breaks, and other whitespace characters of the text.
Edit: whoops, edited to reflect that this is a block-level class, not character-level.
Edit: whoops, edited to reflect that this is a block-level class, not character-level.
Flare v6.1 | Capture 4.0.0
-
Phlawm53
- Sr. Propeller Head
- Posts: 442
- Joined: Tue Mar 16, 2010 10:58 am
- Location: San Francisco, CA
- Contact:
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
Andrew:
Thanks much! -- *pre* is a BIG help. At least I get my line breaks.
Next step for me is to figure out how to preserve the indentation.
Cheers & thanks 'gain,
Riley
Thanks much! -- *pre* is a BIG help. At least I get my line breaks.
Next step for me is to figure out how to preserve the indentation.
Cheers & thanks 'gain,
Riley
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
pre should preserve indentation (assuming it is tabs).Phlawm53 wrote:Andrew:
Thanks much! -- *pre* is a BIG help. At least I get my line breaks.
Next step for me is to figure out how to preserve the indentation.
Cheers & thanks 'gain,
Riley
Edit: looked it up...should be tabs, spaces, and carriage returns.
Flare v6.1 | Capture 4.0.0
-
Phlawm53
- Sr. Propeller Head
- Posts: 442
- Joined: Tue Mar 16, 2010 10:58 am
- Location: San Francisco, CA
- Contact:
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
I believe from past experience that I need to replace tabs with hard / non-breaking spaces.pre should preserve indentation (assuming it is tabs).
In the past, attempts to use tabs in online outputs (such as WebHelp) produced unpredictable results. So I learned to use hard spaces instead of tabs.
To be continued.
Cheers & thanks 'gain,
Last edited by Phlawm53 on Mon May 28, 2012 6:35 pm, edited 2 times in total.
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
Have you used them before in pre elements? It should work quite reliably -- it's used on many webpage around the Internet for code samples.Phlawm53 wrote:I believe from past experience that I need to replace tabs with hard / non-breaking spaces.pre should preserve indentation (assuming it is tabs).
In the past, attempts to use tabs in online outputs (such as WebHelp) produced unpredictable results. So I learned to use hard spaces instead of tabs.
To be continued.
Cheers & thanks 'gain,
Flare v6.1 | Capture 4.0.0
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
FWIW, I solved this by taking screen captures of the properly formatted code & inserting them as images where I needed them...
-
GregStenhouse
- Sr. Propeller Head
- Posts: 330
- Joined: Tue May 13, 2008 3:27 pm
- Location: Christchurch, New Zealand
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
careful though, your users might want to copy and paste the code to use for themselves?
See http://forums.madcapsoftware.com/viewto ... &sk=t&sd=a for info on other things to try, including a link to a syntax coloring site
Cheers
Greg
See http://forums.madcapsoftware.com/viewto ... &sk=t&sd=a for info on other things to try, including a link to a syntax coloring site
Cheers
Greg
-
alienwriter
- Propeller Head
- Posts: 11
- Joined: Tue Jul 13, 2010 2:36 pm
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
Did anyone try using "Syntax Highlighter"?
This site has step-by-step instructions on how to use it with Flare:
http://kungfuwit.wordpress.com/2009/06/ ... cap-flare/
I am in the process of testing it - keeping my fingers crossed.
This site has step-by-step instructions on how to use it with Flare:
http://kungfuwit.wordpress.com/2009/06/ ... cap-flare/
I am in the process of testing it - keeping my fingers crossed.
-
Phlawm53
- Sr. Propeller Head
- Posts: 442
- Joined: Tue Mar 16, 2010 10:58 am
- Location: San Francisco, CA
- Contact:
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
I haven't tried it yet (and am enjoying a bit of downtime at the moment), but intend to experiment with it on my next Flare project…Did anyone try using "Syntax Highlighter"?
Last edited by Phlawm53 on Mon May 28, 2012 6:35 pm, edited 1 time in total.
-
alienwriter
- Propeller Head
- Posts: 11
- Joined: Tue Jul 13, 2010 2:36 pm
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
I tried Syntax Highlighter. Didn't work for me. However, I did find one that is based on Google's Prettify!
http://www.balupton.com/sandbox/jquery- ... hter/demo/
It works great! You can even customize the look and feel of it. Better yet, their forum/support site is very good.
http://www.balupton.com/sandbox/jquery- ... hter/demo/
It works great! You can even customize the look and feel of it. Better yet, their forum/support site is very good.
-
Phlawm53
- Sr. Propeller Head
- Posts: 442
- Joined: Tue Mar 16, 2010 10:58 am
- Location: San Francisco, CA
- Contact:
Re: Fast way to tidy / prettify Java, XML, HTML code samples?
There is now also this great How To article posted 14 August, 2012 on the Madcap.com Web site:
http://www.madcapsoftware.com/blog/2012 ... y-google/#
Cheers & hope this helps,
Riley
SFO
http://www.madcapsoftware.com/blog/2012 ... y-google/#
Cheers & hope this helps,
Riley
SFO