# web.sed -- quick type html with simplified syntax # for headings, paragraphs, etc.. # To get css, have an "index.css" in same directory, or edit this file. # sed operates on one line of the source file at a time, and the # changes are almost all cumulative. After the making of tags below, # paragraphs are lines to sed, which affects the order in which # certain substitution commands can be given. # An awk routine replaces the @enumber and @tnumber with respective # numbers starting with "1". It may be separate script or # placed in the bash script or batch file that you use. # The last backslash at
\ is necessary to get space before # title. # Insert boilerplate before first line. Not cumulative. # This apparently has to be the first thing in file. No idea why. 1 i \ \ \ \ \/ s/^\.zpre/<\/pre><\/b>/ p d } # line break s/ \.nl/
/ # no tabs, trim ends (not starts), only single white lines s/\t/ /g s/ *// /./,/^$/!d # make sure blank at end of file now from book Sed&Awk:) # Append at end takes care of it. NOT! ${ /^S/!{ H s/.*// } } # Selective comments in source: # % = line appears only in html files, not latex(;) # The (first) symbol itself disappears. # Line comments must start at first byte of line. /^;/d # the following only deletes one "%" on a line. /^%/ s/// # :: these comments hold replacement data for the # products of this file. Not deleted by this file. # Removes trailing white, leading space s/^[ \t]*// s/[ \t]*$// # no footnotes in web.sed. Kill. /@foot/,/@zfoot/{ /@z*foot/! d # rm intermediate lines s/@foot.*@zfoot//g # rm tag to tags in one line s/@foot.*// # rm open tag and rest s/.*@zfoot// # rm close tag and before :done } # one line link for html only: .hlink url visible text # hlink, space, link, space, rest of line is visible text /^\.hlink/ s/^\.hlink \([^ ]*\) \(.*\)/\2<\/a>/ # End notes link: .en (nothing else on line) # set filename (@tname) at bottom of this script. # Notes can be the bottom of # the same file if you like, or in a separate file. /^\.en/ s/^\.en/[@enumber]<\/a>/ # Target for end notes link: .t (begins paragraph) # The rest of the same line will be boldface. # See above about numbering. /^\.t/{ s/^\.t\(.*\)/\&\#167;@tnumber \1<\/b>/ } # Image link. The image is named, then the alternative text. # Centering prevents it becoming inline. This is for long or large # pics, music PNGs. /^\.img/ s/^\.img *\(.*\)// # make paragraph tags. Center part from Sed&Awk. Apparently, # it holds all non-empty lines: /^$/!{ H d } /^$/{ x s/^\n// s/$/<\/p>/ G } # Headings: # Range: headings address only one line. Previous manipulations have # made paragraphs into one line with internal newlines! /
\.1/{ s/<\/p>/<\/h1>/ s/
\.1/
/ } # handle author html now. # #######s/@author:\(\.*\)/
@author\1/ s/^
.*/&\
@author<\/h4>\ / /
\.2/{ s/
\.2/
/ s/<\/p>/<\/h2>/1 } /
\.3/{ s/
\.3/
/ s/<\/p>/<\/h3>/1 } /
\.4/{ s/
\.4/
/ s/<\/p>/<\/h4>/1 } /
\.5/{ s/
\.5/
/ s/<\/p>/<\/h5>/1 } /
\.6/{ s/
\.6/
/ s/<\/p>/<\/h6>/1 } # Lists. .ol .zol .ul .zul /
\.ol/,/\.zol<\/p>/{ s/p>\.ol<\/p>/ol>/ s/
\.zol<\/p/<\/ol/ s/
/\/li>/g } /
\.ul/,/\.zul<\/p>/{ s/p>\.ul<\/p>/ul>/ s/
\.zul<\/p/<\/ul/ s/
/\/li>/g } # ```single''' ``double quotes'' s/```/\&\#145;/g s/'''/\&\#146;/g s/``/\&\#147;/g s/''/\&\#148;/g # ellipsis ... (add extra space to separate from word. One is swallowed) / \.\.\./ s//\&\#133/g # bold *__bold__* /\*__/,/__\*/{ s/\*__//g s/__\*/<\/b>/g } # italics *_italics_* /\*_/,/_\*/{ s/\*_//g s/_\*/<\/i>/g } # dashes en-- em--- /---/ s//\&\#151;/g /--/ s//\&\#150;/g # sharp, flat, and naturals &s &b &n s/\&b/\♭/g s/\&n/\♮/g s/\&s/\♯/g # dharma wheel--testing unicode support s/\&w/\/g # guitar strings &1 s/\&1/\➀/g s/\&2/\➁/g s/\&3/\➂/g s/\&4/\➃/g s/\&5/\➄/g s/\&6/\➅/g # blockquote or quote /\.quote/ s//
/ /\.zquote/ s//<\/blockquote>/ # The tnumbers and enumbers can't be done with sed easily. # Use an awk routine to do the numbering in your script. # Mine is qkt2htm, a bash shell script. # Append boilerplate. This should stay at end of script: $ a\
\ Home\©@copyright
\ \ \