1  About
 1.1  License & copyright
 1.2  Formatters
2  Usage
 2.1  Simple
 2.2  Modifying layout and style
 2.3  Modifying code logic
 2.4  Usage with non-English text
3  Other
 3.1  Changelog
 3.2  Support
 3.3  Donate
rTxt2htm_README.txt
rTxt2htm 1.0 documentation, 13 September 2007
Copyright Santosh Patnaik
GPLv3 license
A PHP Labware internal utility - http://www.bioinformatics.org/phplabware

Download latest original file from http://bioinformatics.org/phplabware/downloads/rTxt2htm.zip

1  About

(to top)

rTxt2htm creates standalone, XHTML 1-strict HTML files from text files with special but simple and unobtrusive markup. It is intended for generating HTML versions of plain-text documentation (like readme files that accompany software distributions; the r in rTxt2htm hints at readme).

Documentation files are often in plain-text format, which, while versatile, lacks the enhanced functionality of hyperlinks that allow one to jump between sections of the documentation or to resources outside it.

rTxt2htm parses text files written in a specific format for URLs, sections, code fragments, styled text, tables of content, etc., creating the necessary HTML elements for presentation in the HTML output.

1.1  License & copyright

(to top)

rTxt2htm is free software licensed under GPL license version 3 and copyrighted by Santosh Patnaik, MD, PhD. One may freely modify and use portions of the code.

1.2  Formatters

(to top)

rTxt2htm looks for specific white-spacing, characters, etc. (formatters) in the plain-text files for creating the necessary HTML elements.

The formatters that rTxt2htm uses are simple and unobtrusive, and yet meaningful inside plain-text files. A comparison of the HTML, and the plain-text versions of this readme documentation shows this clearly.

Formatters (processing done in the shown order) are:

*  A block of text with == Content ==(any number of) at top and two empty lines at bottom is considered a table of content (TOC); rest of formatters don't apply to its content.

*  A block of text flanked with /* style PHP comment markers will be shown in a subtle div element. Like:
 
  Some subtle text
  Like comments

*  Four or more spaces before a sentence lead to the sentence being shown as code (a tab is considered equal to 4 spaces). Like this:

  <this is some 'code'>

*  Flanking a word or phrase with ` italicizes it. Flanking a word or phrase with * makes it appear bold. Flanking a word or phrase with ' makes it rendered as a special span element, like this.

*  A word followed by :-, a space, and then another word is rendered as the first word hyperlinked to the location pointed out by the second one. E.g.:

  --  for rTxt2htm support, see section 3.2
  --  rTxt2htm was created for documenting htmLawed

*  Words with http:, https:, mailto:, ftp:, and sftp: are rendered with appropriate hyperlinks. Like, http://www.bioinformatics.org/phplabware.

*  Two = characters followed by a space and then text followed by more = characters indicate a section start. The text is shown as an h2 element. Any o's at the end are for div closures. If the text has a leading number like 1 and 3.2.1, the section gets an anchor named the same as the number but prefixed with s, like s1 and s3.2.1.

*  For sub-sections (rendered with an h3 element) and sub-sub-sections (rendered with an h4 element), instead of the = character, the characters - and . are respectively used.

*  Five or more underscores on a line by themselves are rendered as an hr element; any o's at the end are, like with the formatters for sections, etc., for div closures.

Note:

Empty spaces are preserved, so any indentation is preserved. For bold, italicized or otherwise stylized text, the characters [ and ( if at the beginning, and characters ?, ;, !, :, ,, ., ), and ] if at the end of a word/phrase are not stylized. Same is true for hyperlinking.

Formatters for HTML lists, tables, colored text, etc., are missing as such information either cannot be expressed in plain-text format or is adequately functional in it without a need for a formatter.

2  Usage

(to top)

rTxt2htm should work with PHP 4.3 and higher.

2.1  Simple

(to top)

It is assumed that the plain-text has the formatters in place as described in section 1.2, and that it has been placed on the server.

To generate an HTML version of it, edit the values for the variables $text_file, $meta_desc and $meta_kword at the beginning of the code in rTxt2htm.php. Place the rTxt2htm.php file on the server and browse to its location using a web browser. If you are satisfied with the output, save the web-page, appropriately renaming it. The HTML version can now be distributed to others.

Some browsers do not save web-pages as originally authored. In such a case, you may want to directly save the output of rTxt2htm. If so, set $direct at the beginning of the code in rTxt2htm.php to 1.

2.2  Modifying styles and layout

(to top)

Simple editing of the $css variable value in the code in rTxt2htm.php should generally be enough.

2.3  Modifying code logic

(to top)

Code inside rTxt2htm.php is reasonably documented with inline comments. You can edit regular expression patterns inside it, e.g., to implement customized formatters.

2.4  Usage with non-English text

(to top)

rTxt2htm should work well with non-English text. Ensure you have the proper values set for variables $enc and $lang at the beginning of the code in rTxt2htm.php.

3  Other

(to top)

3.1  Changelog

(to top)

v1.0 - released Sep 13, 2007

3.2  Support

(to top)

For possible updates, follow up at http://www.bioinformatics.org/phplabware (which also has a forum). For general PHP issues (not rTxt2htm-specific), check on the internet and at http://php.net.

3.3  Donate

(to top)

A donation in any currency and amount to appreciate or support this software can be sent by PayPal to this email address: drpatnaik at yahoo dot com.

Thank you!

HTM version of rTxt2htm_README.txt generated on 13 Sep, 2007 using rTxt2htm from PHP Labware