Note on bugs: See end of page for some errors in current implementation of this feature.

As explained in TaviReleaseNotes/RecognisingParagraphs TaviVersion 0.25 finally uses proper paragraph markings. This increases the need of operators to either insert line breaks or do line continuations. These changes are now made, and has made two side effect to the parsing of text. But first lets explain how to do line breaks and line continuation. See following code block and example paragraph.

Single backslash at this point \
  followed by a double backslash at this point \\
    results in this paragraph...

Single backslash at this point followed by a double backslash at this point
results in this paragraph...

Or more specifically,

<p>Single backslash at this point followed by a double backslash at this point <br />
results in this paragraph...</p>

Please note that this functionality does work within tables and enables users to add line breaks within a table cell. It may however break validation of page. See following example:

|| Does it work\\
inside tables?|| This also works\
within tables ||
Does it work
inside tables?
This also works within tables

Whilst dealing with the <code>-stuff necessary to work along this, the new structure of <phpcode> was included. See following code block and example.

<phpcode>
<?php
   echo "Hoorray! Finally php-code is highlighted!";
   if ($something == 'Nothing') {
     print_r($anything);
   }
 ?>
</phpcode>

results in:


<?php
   echo "Hoorray! Finally php-code is highlighted!";
   if ($something == 'Nothing') {
     print_r($anything);
   }
 ?>


Note: <phpcode>/<code> must not be at the start of the text. See fix, below

Technical notes on side effects

To achieve this functionality and still have <code>-sections, I moved some of the parsing into a pre-parse, which handles the line continuation and line breaks. And it also handles the <code>-sections (and the newly introduced <phpcode>-sections). (This might have broken the tavidoc.php, if so please let us know)

In addition, the stealing of lines from parse_indents() is now redundant and are therefore removed. Actually the whole function of parse_code() are removed, too.

Bugs in current implementation

Line continuation fails in the following case:

First line\

Second paragraph

First line Second paragraph

As can be seen (if I've not fixed this on the web site) the 'e' has been removed, and the two lines have been concatenated even though they should be two separate paragraphs. This is fixed in the mainstream code, and the change is done in the file parse/transforms.php in the function pre_parser. Change the following:


<?php
  // Parse the code sections, to escape them from the line control
  $text = preg_replace("/\n\s*<((?:php)?code)>\s*\n(.*\n)\s*<\\/\\1>\s*(?=\n|$)/Usei", 
                       "q1('\n').code_token('\\1',q1('\\2'))", $text); 
  
  // Concatenate lines ending in a single \
  $text = preg_replace("/([^\\\])\\\\\n\s*/s", " ", $text);

  // Insert page breaks to lines ending in a double \
  $text = preg_replace("/\\\\\\\\\n\s*/se", "new_entity(array('newline'))", 
                       $text);
 ?>


into this


<?php
  // Parse the code sections, to escape them from the line control
  $text = preg_replace("/(?:^|\n)\s*<((?:php)?code)>\s*\n(.*\n)\s*<\\/\\1>\s*(?=\n|$)/Usei", 
                       "q1('\n').code_token('\\1',q1('\\2'))", $text); 
  
  // Insert page breaks to lines ending in a double \
  $text = preg_replace("/\\\\\\\\\n\s*/se", "new_entity(array('newline'))", 
                       $text);
  
  // Concatenate lines ending in a single \
  $text = preg_replace("/\\\\\n[ \t]*/s", " ", $text);
 ?>


This will also fix the bug regarding <code> or <phpcode> not being detected when at the start of the text.

The discussion on what a single newline at end of a line actually means, is moved to TaviBugs/SingleNewline.