LiteralWhiteSpace

(redirected from Cookbook.IntuitiveSpacing)

Summary: Preserve white spaces, tabs and extra lines
Version: 2024-03-17
Prerequisites: pmwiki 2
Status: beta
Maintainer: HansB
Categories: Markup Editing
Users: +3 (view / edit)

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.

 

  1. Download whitespace.phpΔ into your cookbook directory
  2. 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 &ensp; invisible characters to preserve the spacing. IE does not support  &ensp; so IE gets served &nbsp; 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.

 

 

Release Notes

  • 2024-03-17: Fixed bug which added extra empty line for new paragraphs if paragraph started with empty space(s). Updated for PHP 8.
  • 2007-03-16a: Added support for (:nolinebreaks:) and (:linebreaks:) directives.
  • 2007-03-16: Change from using &nbsp; to &ensp; for all browsers but IE.
  • 2007-03-15a: some fixes for space conversion and code/pre wrap style.
  • 2007-03-15: initial release.

 

If the recipe has multiple releases, then release notes can be placed here.  Note that it's often easier for people to work with "release dates" instead of "version numbers".

 

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

No there is no markup at present to disable all these markup rules, apart from the (: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
But then you are getting monospaced font. And if you paste in whole long paragraphs from a wordprocessor you get too wide lines and break the layout. HansB

 

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.

Can you demonstrate this here below in the Sandbox area? LiteralWhiteSpace is enabled on this page. HansB
Sure. I have included a sample in the sandbox.
Tabs are translated as a HTML span tag with class=indent. This is a fixed number of characters per tab, exactly what you see. Tabs fail when they are used not at the beginning of lines, but inside line text. I think the only way to achieve a tabular layout is to use tables. But the literal whitespace markups does not provide a translation into tables. This would be very difficult to achieve, if at all, I guess. HansB
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

 

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

 

The game offers fun to the beginner and has enough
complexity to keep the expert challenged.  One of the
most important aspects of the game is the interaction
between the players.  The players make this game.

 

The game is based on many "dungeon games" that have
come before it and adds many new ideas.  There is no
absolute goal to the game; the players generally make
their own goals.  You will probably pick and change
goals throughout your lifetime in the game.

 

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 B
    with more stuff below it. Several spaces

 

 

 

 

 

  • 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.