LiteralWhiteSpace

(redirected from Cookbook.IntuitiveSpacing)

Summary: Preserve white spaces, tabs and extra lines
Version: 2024-04-25
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.

 

Installation

Download whitespace.phpΔ into your cookbook directory,
place the following line into your local/config.php file

include_once("cookbook/whitespace.php");

 

Configuration

Line spacing can be adjusted by adding a variable LineHeight above the include line in config, setting it to a different factor than the default 1.3. Note that this is a factor, without unit like em or % or px. The browser will calculate the line spacing from this and the font size. Examples:

$LineHeight = 1.3; is the default.
$LineHeight = 1.5; for one-and-a-half line spacing.
$LineHeight = 2.0; for double line spacing.
$LineHeight = 1.0; for tight line spacing

 

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. [See LiteralWhiteSpace-Talk for discussion on this]
  • 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-04-25: removed parts of code aimed at old obsolete Internet Explorer.
  • 2024-04-24: changed markup definition for vspace and halfvspace to use HTML <p> tags, instead of <div>.
  • 2024-04-23: Fixed empty lined vertical spacing. Added variable $LineHeight to set factor for line height and empty line height.
  • 2024-04-12: Small fix to remove a debugging code snippet.
  • 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

See Discussion at LiteralWhiteSpace-Talk

 

See Also

 

Sandbox to try it out

 

vspace test

Using table with two cells. There should be line alignment.

1
2
3
4
5
6
7
8
9
10
11

1. first line
2. second line

 


   4. third, indented, empty line above

 

 

7. two empty lines above

9. half height empty line above

10. half height empty line above

 

 

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.