Page 1 of 1

Formatting the element content if preserving of white spaces

Posted: Wed Apr 29, 2009 5:34 pm
by honyk
Hello Everyone,

if there are used literal elements in my DocBook document I would expect their content untouched if Format and Indent button is pressed. If content is too long and contains spaces, it is wrapped. As in the next processing of literal element content the white spaces are preserved, there are unwanted spaces in the output.

Can be such behaviour changed somehow or I must avoid using Format button?

The following change of default docbook.css style to

Code: Select all

literal {
font-family:monospace;
white-space:pre; // this line was added
}
doesn't automatically wrap literal content if it is edited in visual mode (so it could be default docbook setting I think), but there is no influence on the result of Format and Indent button.

Is there any solution. Do I something wrong?
Thanks in advance.

Jan

Re: Formatting the element content if preserving of white spaces

Posted: Wed Apr 29, 2009 5:39 pm
by Radu
Hi Jan,

This should do it:

Code: Select all


literal {
font-family:monospace;
white-space:pre-wrap; // wraps visually but does not format and indent
}
Regards,
Radu

Re: Formatting the element content if preserving of white spaces

Posted: Wed Apr 29, 2009 5:53 pm
by honyk
Thanks for quick reply. I've tested it but without success - it seems like the same bahaviour as using 'pre' value. Switching from visual to source mode keeps line not wrapped, but after Format function it still gets wrapped. I hope we understand one to another.

Re: Formatting the element content if preserving of white spaces

Posted: Thu Apr 30, 2009 8:26 am
by Radu
Hi,

Sorry for the misunderstanding.
So you are pressing the "Format and Indent" button and want the "literal" tag content to be preserved.
Just go to the Options->Preferences->Format->XML page. There is a list of "Preserve space elements" and you can add "literal" or any other Docbook tag name as an entry there. After that, "Format and Indent" should not touch "literal" anymore.

Regards,
Radu

Re: Formatting the element content if preserving of white spaces

Posted: Thu Apr 30, 2009 5:16 pm
by honyk
Yes, it worked perfectly. Thanks a lot.