ewx: (Default)
[personal profile] ewx
# this is kind of painful using only BREs
nroff -man "$1" | sed 's/&/\&/g;
                       s/</\&lt;/g;
                       s/>/\&gt;/g;
                       s/@/\&#64;/g;
                       s!\(.\)^H\1!<b>\1</b>!g;
                       s!\(&[#0-9a-z][0-9a-z]*;\)^H\1!<b>\1</b>!g;
                       s!_^H\(.\)!<i>\1</i>!g;
                       s!_^H\(&[#0-9a-z][0-9a-z]*;\)!<i>\1</i>!g;
                       s!</\([bi]\)><\1>!!g'

(^H means a single character 8, not the two characters ^ and H.)

(no subject)

Date: 2004-05-24 08:10 am (UTC)
From: [identity profile] imc.livejournal.com
There's always man2html (http://www.oac.uci.edu/indiv/ehood/man2html.html)…

(Not that the scary sed script isn't cool and probably better written.)

(no subject)

Date: 2004-05-24 08:18 am (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com

There's any number of manpage-to-HTML scripts. In the context at hand though I didn't want to introduce any unnecessary build dependencies - so no Perl, no sed beyond POSIX sed (e.g. GNU sed can do alternation using \| which would save me some repetition). Hence the remark about BREs.

Although I notice that awk uses EREs (and the autoconfery introduces an awk dependency, and who the hell doesn't have awk anyway) so perhaps I could have used that.

(no subject)

Date: 2004-05-24 08:51 am (UTC)
pm215: (Default)
From: [personal profile] pm215
&#64; ?

(no subject)

Date: 2004-05-24 09:08 am (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com
@ is magical in the template language.

(no subject)

Date: 2004-05-24 09:19 am (UTC)
From: [identity profile] angoel.livejournal.com
Yes, but what does it do?

(no subject)

Date: 2004-05-24 09:47 am (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com
Turns formatted man pages, which use overprinting to implement bold and underlining, into a fragment of HTML.

January 2026

S M T W T F S
    123
45678910
111213141516 17
18192021222324
25262728293031

Most Popular Tags

Expand Cut Tags

No cut tags