Skip to main content
October 22, 2012
Question

Is there a RH standard for formatting code samples?

  • October 22, 2012
  • 1 reply
  • 853 views

In the RH default style sheet, I do not see a pre HTML tag or other tag that will display code samples in a monospaced font.

I created custom styles for a single line code sample and another style for multiline samples.

We want our code samples to be shaded. If I shade multiple lines, each line being separated with a paragraph, there is a small amount of

white space between each line. We do not like this either.

I then created a custom table style with a single shaded cell. I add my multiline sample code, then I apply the custom paragraph style to get

the font and spacing between lines that I want.

Is there a different best practice for this, so that the code sample would be rendered correctly if viewed from other devices that read the HTML and

may look for the pre HTML tag?

I am using RoboHelp 9 and I provide the output as Eclipse help. Our help files are integrated into Eclipse help in the Eclipse IDE.

Thank you.

Cynthia

This topic has been closed for replies.

1 reply

Captiv8r
Legend
October 22, 2012

Hi Cynthia

As much as it pains me to say it, this is one case where using a Form element might be your best bet. I say this because often code samples are used or presented with the intent of copying and pasting into something like Windows Notepad. And if you used the TextArea form element, you can place the code there and make it pretty easy for folks to copy it for use elsewhere.

I stand to be corrected on this because I am not a "power CSS" person. (meaning I am aware there are complete two and three day classes one might attend on all the nuances of CSS) But RoboHelp won't really do anything to help you a great deal in formatting things. But it might be possible, somehow, to configure CSS to accomplish your goal of making the code look as you want.

Cheers... Rick

Willam van Weelden
Inspiring
October 23, 2012

Hi,

I use the SyntaxHighlighter script by Alex Gorbatchev for code samples. See alexgorbatchev.com/SyntaxHighlighter.

Greet,

Willam

October 31, 2012

I will also pass this information to the person who will be assuming responsibility for my project. Thanks much!