Skip to main content
Known Participant
March 12, 2011
Question

unable to get well-formatted code extracts

  • March 12, 2011
  • 2 replies
  • 379 views

I have created a DITA file which contains XML code extracts.

Which is the most appropriate element to get them well formatted? I have tried <codeblock>, <codeph>, but these do not seem to work. Here is the result:

Thanks

This topic has been closed for replies.

2 replies

ScottPrentice
Inspiring
March 13, 2011

codeph is for inline code references (code phrase) within a regular paragraph, and would not contain line breaks.

codeblock is for multi-line code chunks (probably what you're looking for). At the end of each line you'll need to press SHIFT+ENTER to get the line break (don't just press enter, this will break the codeblock in two). You'll want to turn off "smart spaces" in order to add multiple spaces at the beginning of a line (or anywhere often found in code). (DITA-FMx automatically switches smart spaces and smart quotes on and off when in a codeblock element.)

If you try to paste multiple lines of code into a codeblock, it may initially look right, but when you save, close, and reopen the file, it'll be all mashed up. THis is because it's pastign in EOPs (end of paragraph) instead of EOLs (line breaks) .. if you turn on text symbols, you'll see what I mean. Here's a procedure for pasting in code and fixing it up ..

http://kb.leximation.com/dfm/?kbid=39

Cheers,

...scott

Michael_Müller-Hillebrand
Legend
March 12, 2011

AL,

I see two paragraphs (most probably <codeblock>) each filled with a string of characters.

What do you expect to see?

- Michael