SOLVED: Best way to display code listings

This forum is for all Flare issues not related to any of the other categories.
Post Reply
ajpeck123
Propeller Head
Posts: 37
Joined: Tue Mar 07, 2017 6:01 am

SOLVED: Best way to display code listings

Post by ajpeck123 »

Hi,

I'm new to Flare and am converting legacy FrameMaker documents. In the FrameMaker document are a lot of tables, used to hold computer code listings (all formatted with fixed-width font) and all with captions (using FrameMakers "table caption" facility). Images are also in borderless tables for the same reason.

To save a LOT of trial and error:
* What is the best way to keep images and captions together? Two separate paragraphs then group them into a DIV?
* How would anyone recommend managing code samples? (Currently they tend to wrap themselves, but have leading space... which I can only do with <pre> (I believe) in CSS... does anyone use text boxes?

Thanks in advance,

Alison
Alison
Lone technical author - Flare user since March 2017
Currently using Flare 2020
ajpeck123
Propeller Head
Posts: 37
Joined: Tue Mar 07, 2017 6:01 am

Re: SOLVED: Best way to display code listings

Post by ajpeck123 »

This will be very obvious to any experienced Flare users.
It may not be the 'best' way, but after the trial and error I was hoping to avoid :D I have a solution that works for me. Sharing in the interests of helping out other newbies.
If figures/screenshots are not in steps, they are numbered and have captions. The same is true for listings. They are both classed as "figures" from a numbering perspective. Tables are numbered using a separate numbering sequence.

So to meet my requirements, I created 3 snippets:
  • Figure, containing <figure>(image goes here)<figcaption>Figure N: Caption goes here</figcaption></figure>. Figcaption uses autonumbering.
  • Listing, containing a div called "Listing" that has a border and a maximum width. Use <pre> tags within it to lay out the code... but I have found I'm better to do that in the text editor than the XML editor.
  • Example, which is basically the Figure snippet but with the image replaced by the Listing div. (<figure><div class="Listing"><pre>Code sample</pre></div><figcaption>Figure N: Caption goes here</figcaption></figure>
In all cases, insert the snippet and convert to text... works a treat.
Alison
Lone technical author - Flare user since March 2017
Currently using Flare 2020
Post Reply