Convert indented plain text into properly formated HTML
I like to use indented plain text for project planning, as I feel it allows me to easily express hierarchical relationships between different elements without all the troubles associated with other file formats.
In order to be able to later present these documents in the web, I’m looking for somebody with an excellent grasp of regular expression to code for me, in PHP, a conversor from plain text to properly formated HTML.
The conversor has to do the following:
Step 1: Collect information
Ask for a document title
Ask for the plain text that needs to be converted into HTML
Step 2: Transform text into properly formated HTML
2-1) Include the header file (header.html), replacing $$title$$ by the document title specified in the previous step
2-2) Do the following transformations to the plain text
a) Based on the indentations expressed in the source plain text, properly open and close blockquote tags, in order to obtain the appropriate indentation level in the resulting HTML. Also indent blockquotes tags in the HTML file itself, so it is easier to read the resulting HTML.
b) When a doble carriage return is detected in the plain text file (blank line), replace it by opening and closing p tags
c) Surround text starting with * with the h1 tag
d) Surrond text starting with ** with the h2 tag
e) Surround text starting with *** with the h3 tag
2-3) Include the footer file (footer.html)
Step 3: Show the resulting HTML file in a textarea, from which it can easily be copied.
I have included 4 files in this project description
header.html
Contains the header that needs to be added at the top of the resulting HTML file
footer.html
Contains the footer that needs to be added at the bottom of the resulting HTML file
SampleText.txt
A sample plain text file for testing purposes
ResultingHTML.html
The resulting HTML file that is expected after the conversion process, taking SampleText.txt as source