Translations of this page?:

Pre section with wrapping

<pre> (pre-formatted) section is the xhtml translation of <code> of <file> dokuwiki elements.
It means the format of the content will be unchanged (spaces and end-of-line are respected)

Problem

For very long line (even with spaces in it), the <pre> element will be displayed as a very large section on the html page.
Since the rest of this html page is not within the preformatted section, its content will wrap itself and take the full width of the html page, (width wich is very very large due to the very long line within a <pre> section)
That makes the reading of such a page quite unpractical, with the constant use of horizontal scrollbar to read the full content of the page…

See also Feature Request #370Daniel Chaffiol 2005/06/03

Quick fix

Add a wrap mode for <pre> css element:
add after all css pre rules fo the design.css file in your favorite dokuwiki\template directory :

pre {
  white-space: pre-wrap;       /* css-3 */
  white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
  white-space: -pre-wrap;      /* Opera 4-6 */
  white-space: -o-pre-wrap;    /* Opera 7 */
  word-wrap: break-word;       /* Internet Explorer 5.5+ */
}
For this to work on Internet Explorer, the width of the code box needs to be fixed. -franliu [at] adelphia [dot] net 14/09/05

Suggestion

Even if such a 'feature' (no wrap for <pre> content) might be usefull, it should be given the choice to the writer to choose between wrap and no wrap for the content of a pre-formatted text.
One could use the multiple class on a css element, and use the previous css rule with a 'pre.wrap'.
That rule will add its 'wrap effect' to the previous 'pre.code' or 'pre.file' rules, provided that the xhtml code takes into account the wrap option and generates a <pre class="code,wrap">... xhtml code.

Question

What form should take that wrap option ?

  • a global option in a local.php file ?
  • a global option within the page (~~WRAP~~ for a wrap mode) ?
  • a local option for each pre-formatted sections ?
  • a combination of the above ?

What is your feedbacks on that issue ?

Daniel Chaffiol 31/05/2005


I would think it is best implemented as a template which contains a modified CSS containing your quick fix.
Chris 2005-05-31
If the quick fix was the only solution, then yes, you are right, a dedicated templated should be created.

But with multiple class on a css element, I would rather modify design.css of the default template, and add a pre.wrap rule:

if no <pre class="...[code or file or...],wrap"> is ever generated, then this rule would never apply.

if, because of a “wrap mode”, a <pre class="...[code or file or...],wrap"> is generated, then this “pre” section would be wrapped.

That rule can be then safely copied from template to template, and has nothing to do with a dedicated template, since it is linked with a generic “wrap mode” from the dokuwiki php engine. Daniel Chaffiol 31/05/2005
 
wiki/tips/prewithwrap.txt · Last modified: 2005/10/05 09:55 (external edit)
 
Imprint Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate