LiteralWhiteSpace
Questions answered by this recipe
How can Pmwiki preserve the empty (white) spaces and empty lines users enter "intuitively" to format the layout of content?
How can I paste content into a page, which originates from emails and word processors, where text spacing is achieved by using spaces, tabs and empty lines?
How can I force overly wide lines to wrap?
How can I force line wrapping for code and pre (pre-formatted) text?
Description
PmWiki has a number of markup rules which enforce a standardised layout of content, by removing empty spaces, empty lines and line breaks.
The recipe script contains a number of changes to some PmWiki markup definitions, which will override PmWiki's defaults for handling white spaces and empty lines.
- Download whitespace.phpΔ into your
cookbook
directory- for PHP 5.5, 7, or newer, please get whitespace-php7.phpΔ instead.
- place the following line into your
local/config.php
file
include_once("$FarmD/cookbook/whitespace.php");
This recipe is enabled for this page. See Sandbox below for some tests.
With this recipe
- line breaks are honoured.
- empty lines are honoured as extra vertical space.
- a half height empty line can be created by inserting new markup
>>-<<
- empty spaces at the beginning of lines are treated as such, not as a change to preformatted text.
- empty spaces at the beginning which are aligned with previous list elements will be treated as continuing the list element on the next line.
- pasting in of tab characters are supported.
- PmWiki's tab markup
->
etc is not changed. (:linebreaks:)
and(:nolinebreaks:)
markup is supported, so parts of content can be excluded from the new whitespace treatment.- pasting in of email content or content from word processors where empty spaces were used for layout will look decent and not break the skin layout.
- white spaces in HTML tags and in wiki style markup are left unchanged.
- optionally PmWiki's code and escape markup can be forced to line wrap with
$EnableCodeWrap = 1;
.
Notes
White space treatment
The new markup will add many  
invisible characters to preserve the spacing. IE does not support  
so IE gets served
instead, plus an additional space to allow wrapping of lines.
Forcing code and pre lines to wrap
The css rules above are non-standard, browser specific rules.
Internet Explorer has a problem with its own word-wrap rule, I could not find a solution other than giving IE the rule to treat white space as normal. This means that IE will wrap lines, but also swallow more than a single space in the lines. Not too good. Otherwise take the white-space:normal
out and let IE have too wide lines occasionally.
You may wish to add the css rules to your local css file (pub/css/local.css, or a group or page custom css file in that directory), rather than having them inserted into the page HTML head as the recipe script does by using $HTMLStylesFmt
.
Limitations
There is an as yet unresolved bug which adds an extra empty line if a new paragraph after an empty line starts with empty spaces at the beginning of the line.
Release Notes
- 2007-03-16a: Added support for
(:nolinebreaks:)
and(:linebreaks:)
directives. - 2007-03-16: Change from using
to 
for all browsers but IE. - 2007-03-15a: some fixes for space conversion and code/pre wrap style.
- 2007-03-15: initial release.
Comments
It would be really nice if this recipe defined a new markups to turn itself on and off for pages or sections of pages. Or does it does do this already, and I'm just missing it? Francis
(:nolinebreaks:)
markup. Perhaps I can create one. HansB
How can I paste content into a page, which originates from emails and word processors, where text spacing is achieved by using spaces, tabs and empty lines?
- Well, you can also use [@preformatted text block@] markup if this is all you want to do - you don't need this recipe. See the text formatting rules. Francis
Is there any way to use this recipe (or any other recipe for that matter) on certain pages only? I love the recipe and have been waiting for something like that for a long time, but I only need it on specific pages.
- See GroupCustomizations. It also explains per page customisations. You would need to include the recipe on a local Group.PageName.php file. HansB
--- Thanks.
Also, I tried pasting a formatted, tabbed text from a word document and the formatting was not even close to the original. Am I missing something ?? G.
- Thanks. Yes I've been using tables for this layout, but unfortunately, there's lots of entries on the page and it takes forever to load with tables. I was looking for a better way to lay it out, w/o tables but I guess the only feasible solution would be that or monospaced text, which really doesn't do it for me ;)
See Discussion at LiteralWhiteSpace-Talk
See Also
- PmWiki.TextFormattingRules#EscapeSequence
- Text2Tbl - Provide a way to convert arbitrarily structured text to table markup and provide conversion of simple tables to advanced.
Sandbox to try it out
This is a sample text from a text file with tabs in between the different info (<tab> indicates a tabbed spacing in the original file).
ADAM Smith (info) <tab><tab> Office: 555-565-5656
Data Production, NY <tab><tab> Cell #: 555-858-5852
adams@company.com <tab><tab> Yahoo! IM: -----
when pasted to PmWiki the text looks like that:
ADAM Smith (info)Office: 555-565-5656
Data Production, NYCell #: 555-858-5852
adams@company.comYahoo! IM: -----
So, I guess what happens is, the spacing is recognized, but the text is not aligned as it should be if <tab>'s are used.
Any suggestions?
Use simple table markup. There is no other way to achieve line to line tab alignments. HansB
Try Text2Tbl -- it has capabilities of making tables based on tab placement. Peter Bowers
Normal text
mmmmmmmmmm
1234567890
M-10 spaces
.....this is a test line
5 spaces before
+ 4 spaces before
++ 3 spaces before 2 spaces more more ---
--- --- ---
monospaced text:
mmmmmmmmmm
1234567890
M-10spaces
.....this is a test line
5 spaces before
+ 4 spaces before
++ 3 spaces before 2 spaces more more ---
--- --- ---
Escaped <pre> code wrapping
- The long version would be:
$feralsimplecalendar_dayname = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
first line
next line
one space at start
two spaces at start
three spaces at start
four spaces four spaces gap.
line normal space
line with half line following
line abcdefg hijklmnop
line normal space
- one
- two
- Subpoint A
with more than one line
below it
- Subpoint A
- Subpoint B
with more stuff below it. Several spaces
- Subpoint B
- three
pasting text works like a charm!!!
Αρχεία CUE, ΒΙΝ και ISO
Αν έχεις ένα «εικονικό αρχείο CD», μπορείς να το χρησιμοποιήσεις
(για αναπαραγωγή, εγκατάσταση κλπ), απλά προσαρτώντας το,
χωρίς να χρειαστεί να το γράψεις σε CD.
Μόνη απαίτηση, το πρόγραμμα " bchunk ",
αν και άλλα προγράμματα, ίσως, να μπορούν να κάνουν τη δουλειά.
Τρόπος δοκιμασμένος και αξιόπιστος. .!.
Σημ.: Δεν χρησιμοποιούμε κενά στα ονόματα των φακέλων και των αρχείων.
Σαν υπερχρήστες...
α. ...δημιουργούμε το φάκελο όπου θα προσαρτήσουμε το αρχείο ISO:
mkdir /mnt/iso
β. ...κατευθύνουμε την κονσόλα στο φάκελο όπου βρίσκεται το αρχείο ISO ή CUE, πχ:
cd /home/όνομα_χρήστη/
γ. ...αν είναι αρχείο CUE, το μετατρέπουμε πρώτα σε ISO:
bchunk όνομα.bin όνομα.cue όνομα.iso
γ2 ...αν το αποτέλεσμα είναι «όνομα.iso01.iso» και «όνομα.iso02.iso»,
τότε τη βάψαμε.
Το bchunk δεν υποστηρίζει αρχεία CUE,
που αποτελούνται από 2 εικονικούς δίσκους.
Σε αυτή την περίπτωση θα πρέπει να χρησιμοποιήσουμε
είτε το Acetoniso (που είναι πιο φιλικό προς το χρήστη)
είτε το CDemu (που είναι αρκετά πιο πολύπλοκο).
δ. ...προσαρτούμε το αρχείο ISO:
mount -t iso9660 -o loop όνομα.iso /mnt/iso
Τα περιεχόμενά του εικονικού CD,
είναι, τώρα, διαθέσιμα στο φάκελο "[i]/mnt/iso [/i]".
ε. ...για αποπροσάρτηση, πάλι σαν υπερχρήστες, κάνουμε (umount):
umount /mnt/iso
User notes +3: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.