Style(s) for an xml sample

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
Greg
Sr. Propeller Head
Posts: 130
Joined: Thu Mar 29, 2012 12:01 am

Style(s) for an xml sample

Post by Greg »

I want to include an example of a configuration in an xml file.

What is the easiest way to do this without manual formatting since many lines have different indents?
techwriter31
Propellus Maximus
Posts: 551
Joined: Wed Mar 05, 2008 10:50 am

Re: Style(s) for an xml sample

Post by techwriter31 »

We encountered this same problem a few months back and couldn't come up with a good/quick solution and ended up inserting them as screenshots. This only worked for us because the samples weren't intended to be copied/pasted into other applications.
Kellie
crdmerge
Sr. Propeller Head
Posts: 248
Joined: Tue Dec 16, 2008 5:37 am

Re: Style(s) for an xml sample

Post by crdmerge »

There's no easy way, but this one works.

Create a pre (preserve white space) style in your style sheet, such as:

Code: Select all

pre.codeblock 
{
	font-family: "Courier New", monospace;
	font-size: 8pt; 
	line-height: 1.1em;
	margin-left: 10px;
	padding-left: 10px;
	margin-top: 10px;
	margin-bottom: 10px;
	padding-top: 10px;
	padding-bottom: 10px;
}
1. In Notepad, copy the code content, format your indents with tabs and/or spaces, and remove extra line spaces that might have been imported.
2. If there are tags, replace all left brackets (<) with < and right brackets (>) with >
3. Select All, and Copy.
4. In Flare (at the desired location), press Shift+space.
5. Select the line (click the P block), press Ctrl+Shift+H, select pre.codeblock, and press Enter.
6. In the Flare Text Editor, go to the location, select the space ( ), and Paste the code.
7. Click Save.
8. In the Flare XML Editor (or Text Editor), perform any edits needed for indents.
9. Click Save.

The beauty of this is that you can adjust indents at will (tabs and/or spaces) in either the UI Xml Editor or the Text Editor. That is, you're dealing with a single pre block, which accepts the Tab character, instead of multiple p lines, which do not.


Good luck,
Leon
techwriter31
Propellus Maximus
Posts: 551
Joined: Wed Mar 05, 2008 10:50 am

Re: Style(s) for an xml sample

Post by techwriter31 »

Another problem we encountered was that the lines of code were in different colors (I believe green, blue and red). Is there a way to accomplish this without local formatting?

Thanks!
Kellie
crdmerge
Sr. Propeller Head
Posts: 248
Joined: Tue Dec 16, 2008 5:37 am

Re: Style(s) for an xml sample

Post by crdmerge »

Not that I know of, except for the already discussed screenshot solution.


Good luck,
Leon
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Style(s) for an xml sample

Post by NorthEast »

There are a number of free tools that automate colour formatting for code samples.
One I would suggest is Google prettify: http://code.google.com/p/google-code-prettify/
You just need to put the plain code in a pre tag, and all the formatting is done for you.
Post Reply