Yep, I finished the most draining part so far yesterday morning.
Now I have just four files
Diseases.html 586,302 kb
Effects.html 138,709
Problems.html 753,148
Techniques.html 519,271
Total.........1,997,430
That's nearly 2 Mb... a whole lot of typing!
It was great to have this over. Pretty boring and repetitive, so will probably be riddled with mistakes.
Thanks Steve and other LOGIN folks for the suggestion of HTML Tidy to fix these mistakes. It sounds great but isn't in the Vector repositories. Maybe I'll package it up as I will have to do most of it to install anyway It looks like a fairly straight-forward thing, not too many dependencies.
Next steps in Traditional Hydrotherapy:
1. Getting a valid sample page up.
2. Installing (packaging?) HTML tidy
3. Working out how to quickly create web pages - no doubt it will be those Vim macros again.
4. Seeing how to integrate Vim and HTML tidy (I've got a Vim addon - never used one for Vim).
5. That' enough for now.
Monday, March 22, 2010
Sunday, March 7, 2010
Vim Keyboard Macros for HTML Lists
Traditional Hydrotherapy is mainly lists. To complete marking up these lists I am using a few macros:
@r to replace the "/li" at the start of a list with "ul" on the first line of the list and thus start an unordered list. (From a previous post you will know that the dash (-) bulleted lists now have "</li><li>" instead of the dash.)
:s+/li+ul+ - on this line substitute "ul" for "/li"
^Mj - <Enter> and move the cursor down a line
@e To end the unordered list, on the line after the last list item:
^[j - <Escape> to Normal mode and move the cursor down a line, to where it was.
@b - for a one-line unordered list
The two macros, "@r" and "@e", were all I needed to finish marking up lists that had the list-items marked. But there are still lists without any markup, many of them the big Section indexes. For these unmarked lists I used "@e" from above and:
@u start an unordered list, called on the first item of the list:
^[j - Escape back to normal mode and move down a line
@l To put "</li><li>" at the beginning of lines:
@o - unordered list with a single list item. (start on line)
@d - for a two-list item unordered list (which I seem to have lots of):
@c to markup comma separated lists. I'm dealing with a lot of these in Techniques.
I have a question out of this, maybe you can answer. Is there any way of simply pushing the remainder of a line down onto a new line the way that <Enter> does in Insert mode?
And finally today, before I get back to work.
@m - To delete a number and fullstop (or dash and space), and put in regular list-item markup:
This moves the cursor to the first character of the line, deletes 2 characters and calls @l, the list-item macro.
@r to replace the "/li" at the start of a list with "ul" on the first line of the list and thus start an unordered list. (From a previous post you will know that the dash (-) bulleted lists now have "</li><li>" instead of the dash.)
:s+/li+ul+^Mj
This is a simple substitution and I used "+" to delimit it as the usual "/" is used in the "from" string. It means::s+/li+ul+ - on this line substitute "ul" for "/li"
^Mj - <Enter> and move the cursor down a line
@e To end the unordered list, on the line after the last list item:
O</li></ul>^[j
O</li></ul> - open a line above the cursor, change to Insert mode and insert "</li></ul>" ^[j - <Escape> to Normal mode and move the cursor down a line, to where it was.
@b - for a one-line unordered list
@r@e
Simply a combination of the two previously shown macros.The two macros, "@r" and "@e", were all I needed to finish marking up lists that had the list-items marked. But there are still lists without any markup, many of them the big Section indexes. For these unmarked lists I used "@e" from above and:
@u start an unordered list, called on the first item of the list:
I<ul><li>^[j
I<ul><li> - Open insert mode at the beginning of the line and insert the markup that starts an unordered list and the first list item^[j - Escape back to normal mode and move down a line
@l To put "</li><li>" at the beginning of lines:
I</li><li>^[j
I can repeat this for all the remaining list item lines by typing, for instance "10@l" for a list with ten more list items.@o - unordered list with a single list item. (start on line)
@u@e
This simply calls two previously mentioned macros, one starts the list the other ends it.@d - for a two-list item unordered list (which I seem to have lots of):
@u@l@e
In the same vein as "@o" and "@b", above, this macro calls three previous macros@c to markup comma separated lists. I'm dealing with a lot of these in Techniques.
f,2xi^M</li><li>^[
This finds the next comma, deletes it and the following space, start Insert mode and <Enter> to move the remainder of the line down one line and mark it up as a list item, then escape back to Normal modeI have a question out of this, maybe you can answer. Is there any way of simply pushing the remainder of a line down onto a new line the way that <Enter> does in Insert mode?
And finally today, before I get back to work.
@m - To delete a number and fullstop (or dash and space), and put in regular list-item markup:
^2x@l
This moves the cursor to the first character of the line, deletes 2 characters and calls @l, the list-item macro.
HTML Markup with Vim Macros
So after the last post I had four files:
They had all their links marked up in html and all the bullet points converted to html list items. Now I had the daunting task of marking up the rest of the html.
To make markup easier I turned on Vim's syntax highlighting by simply changing the filenames to .html like this:
My present job is going through each of these files and manually marking up the html. Once again Vim macros have come to the fore. As I found previously the edits were quite slow on the bigger files, so split them into smaller ones. At present I am making good progress having completed Diseases, Effects and Problems in the last month and must be about halfway through Techniques.
So here is how I'm using the macros for general html tags:
@h - To make subheadings "H3"
A</h3>^[j - start Insert mode after the last character on the line, Insert "</h3>" to end the heading, <Escape> to Normal mode and move the cursor down a line (to begin the next macro)
@p for a one-line paragraph
@t - inserts treatment heading - often missing in Diseases
I use other substitutions to make headings as well, like:
- Diseases.txt
- Effects.txt
- Problems.txt
- Techniques.txt
They had all their links marked up in html and all the bullet points converted to html list items. Now I had the daunting task of marking up the rest of the html.
To make markup easier I turned on Vim's syntax highlighting by simply changing the filenames to .html like this:
- Diseases.html
- Effects.html
- Problems.html
- Techniques.html
My present job is going through each of these files and manually marking up the html. Once again Vim macros have come to the fore. As I found previously the edits were quite slow on the bigger files, so split them into smaller ones. At present I am making good progress having completed Diseases, Effects and Problems in the last month and must be about halfway through Techniques.
So here is how I'm using the macros for general html tags:
@h - To make subheadings "H3"
I<h3>^[A</h3>^[j
I<h3>^[ - move to beginning of line, change to Insert mode, insert "<h3>" to begin the heading, then <Escape> to Normal modeA</h3>^[j - start Insert mode after the last character on the line, Insert "</h3>" to end the heading, <Escape> to Normal mode and move the cursor down a line (to begin the next macro)
@p for a one-line paragraph
I<p>^[A</p>^[j
This is the same as "@h" above, except the paragraph markup is inserted. To ensure that paragraphs are one-line, I use "J", which appends the next line to the end of the present line with a space between.@t - inserts treatment heading - often missing in Diseases
O<h3>Treatment:</h3>^[j
This opens a line above the cursor into Insert mode and insert the treatment heading then <Esc> back to Normal mode and move the cursor down a line.I use other substitutions to make headings as well, like:
:%s+^Prevention:+<h3>Prevention<\/h3>+
and:%s+Indications:+<h3>Indications:-</h3>+
And to get rid of redundancy in the links in the Diseases.html file::%s+../Diseases/++g
Subscribe to:
Posts (Atom)