groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] mmhtml.tmac with Werner's fixes


From: Chuck Robey
Subject: Re: [Groff] mmhtml.tmac with Werner's fixes
Date: Mon, 11 Jan 2010 16:47:58 -0500
User-agent: Thunderbird 2.0.0.19 (X11/20090121)

Mike Bishop wrote:
> On Tue, Jan 05, 2010 at 02:38:55PM -0500, Chuck Robey wrote:
>> This has the fixes suggested by Werner, mostly formatting changes (attached
>> file).  I'm hoping for someone with some old mm sources with lists in them to
>> give it a try in -Thtml, see what it looks like.  If I get benign neglect,
>> this'll probably disappear, because it won't get committed to your archive.
> 
> Well, I tried with two documents, one a set of race rules, the other
> minutes.  Lists used were .VL, .BL, .AL and formatted correctly
> except, in each case, for the first list entry.
> 
> The first entry prints the list symbol (bullet, 1, var-text), followed
> by a blank line, followed by the list text correctly indented.
> 
> Looking at the html, in each case the first <LI> is followed by
> a <br>.  The <br> probably needs to follow the <UL ...> statement?

Mike, I had a local computer emergency, had to rebuild a bunch of stuff (which I
like doing anyhow) so I didn't get down to fixing this until today.  I found
that I only needed to replace every instance of .HTML with the no-spacing
version, .HTML-NS, and that seems to have fixed it.  I've attached it here, feel
like testing again?  Anyone?

Though, I'll admit, my original version, which didn't have all of the extra
spacing to prettify the .if lines, didn't show this problem either.  I'm still a
bit distracted rebuilding stuff, so as long as I *think* I have it fixed, I
think I'll just be happy with that.
.\"     Adapting the mm list macros for HTML output.
.\"
.\"     Wrap EVERYTHING in a check for html.  Everything below activates
.\"     ONLY if in html mode, where the regular mm list macros are heavily
.\"     modified for html output.  This requires the use of the www macros.
.\"     Author: Chuck Robey (address@hidden), January 2010.
.\"     Best to copy the address@hidden list, it's a goldmine of help.
.\"
.\"     Want to give the whole groff list credit, but especially Werner,
.\"     Gaius, and Larry, very knowledgeable and helpful, and I stole
.\"     code wholesale from the m and www tmac macros.  License: Give
.\"     me credit in any sources derived from this, use the rest as
.\"     you see fit.  If the informal license language bothers you, go
.\"     see a lawyer, thank you.
.\"=================================================================
.\"     Error code, wraps everything.
.\"-----------------------------------------------------------------
.\" Below used to force single-inclusion logic
.do .if d address@hidden \
.    nx
.\" and use this only if output type is html
.do .if '\*[.T]'html' \
.    nx
.if !\n(.g \
.    ab These mm macros require groff.
.if \n(.C \
.    ab The groff mm macros do not work in compatibility mode.
.\"     one new stack macro to read stack top value
.\"=================================================================
.\"     LOCAL UTILITIES
.\"
.\"     address@hidden is meant to read the top item of the mm stack macros,
.\"     non-destructively.  This set of macros contemplates using 3
.\"     stacks: mm*html-list-stack, mm*html-li-status-stack
.\"-----------------------------------------------------------------
.de address@hidden
.    ds \\$1 \\$2
..
.\"=================================================================
.\"     Autoincrement list.
.\"
.\"     mm's AL template is "AL [type [text-indent [1]]]"
.\"     Use the html "OL" tag, attributes type, start, compact
.\"     ignoring the html start value, no public way to do that in mm
.\"     here if argc=3 and arg3=1 then set compact on (as COMPACT) ($3)
.\"     Remember, push new level to the list and list status stacks.
.\"-----------------------------------------------------------------
.de AL
.    rm mm*html-compact
.    if \\n(.$=3&\\$3=1 \
.        ds mm*html-compact COMPACT
.    \" don't handle text-indent for html ($2)
.    \" But, default list mark to 1 ($1)
.    ie \\n(.$>0 \
.        ds mm*html-list-mark \\$1
.    el .rm mm*html-list-mark
.    nr mm*html-list-depth  +1
.    \" push AL onto the list stack
.    address@hidden mm*html-list-stack AL
.    \" push CLOSED onto the list status stack because no item open yet
.    address@hidden mm*html-li-status-stack CLOSED
.    \" finally, output the HTML
.    ie d mm*html-list-mark \
.        HTML-NS <OL type=\\*[mm*html-list-mark] \\*[mm*html-compact] >
.    el .HTML-NS <OL \\*[mm*html-compact] >
..
.\"=================================================================
.\"     Bullet list.
.\"
.\"     for BL, just call ML with a default mark of disc
.\"     mm's BL template is "BL [text-indent [1]]"
.\"-----------------------------------------------------------------
.de BL
.    ML \(bu \\$1 \\$2
..
.\"=================================================================
.\"     Marked list.
.\"
.\"     mm's ML template is "ML mark [text-indent [1]]"
.\"     This implementation is the same as BL, but where BL defaults
.\"     the mark, here we use the first macro parameter.  NOTE,
.\"     the list mark setting (type=circle) goes into the LI nodes.
.\"-----------------------------------------------------------------
.de ML
.    rm mm*html-compact
.    if \\n(.$=3&\\$3=1 \
.        ds mm*html-compact COMPACT
.    \" increment the list depth
.    nr mm*html-list-depth  +1
.    \" push the stack type
.    address@hidden mm*html-list-stack ML
.    \" push CLOSED onto the list status stack because no item open yet
.    address@hidden mm*html-li-status-stack CLOSED
.    rm mm*html-list-mark
.    if '\\$1'\\(sq' \
.        ds mm*html-list-mark type=square
.    if '\\$1'\\(ci' \
.        ds mm*html-list-mark type=circle
.    if '\\$1'\\(bu' \
.        ds mm*html-list-mark type=disc
.    HTML-NS <UL \\*[mm*html-list-mark]>
..
.\"=================================================================
.\"     Variable List
.\"     mm macro template: "VL text-indent [mark-indent [1]]"
.\"     Maps to the html definition list (DL), which gives a term
.\"     in a hanging indent (given in a parameter in VL's LI), and
.\"     a following paragraph to define that term.
.\"     I can't yet find any html way to handle VL's fist 2 params,
.\"     but suggestions are quite welcome (see my email on top).
.\"     Default text-indent=36p, mark-indent=0p
.\"
.\"     <DL STYLE="margin-left: 1in margin-right: 1in" > in,pt,cm,px,pc (pct)
.\"     pt=points 
.\"
.\"-----------------------------------------------------------------
.de VL
.    rm mm*html-compact
.    if \\n(.$=3&\\$3=1 \
.        ds mm*html-compact COMPACT
.    nr mm*html-list-depth  +1
.    \" push VL onto the list stack
.    address@hidden mm*html-list-stack VL
.    \" push CLOSED onto the list status stack
.    address@hidden mm*html-li-status-stack CLOSED
.    \" finally, output the HTML
.    HTML-NS <DL \\*[mm*html-compact] >
..
.\"=================================================================
.\"     List Item
.\"
.\"     This basically comes as two variants (both in this macro), one
.\"     that uses the HTML <LI> tag (for ordered and unordered lists)
.\"     and the other (for HTML definition lists), to use the <DT> tag
.\"     for the definition term, and <DD> for the following data term.
.\"     The only mm macro list type to use the definition lists is the
.\"     VL list, all others use the html <LI> item type.  VL mm lists
.\"     use DT to define the term, then DD for the data.
.\"-----------------------------------------------------------------
.de LI
.    if \\n[mm*html-list-depth]<1 \
.        ab "No open list for LI request"
.    \" read the tops of the 2 stacks (but don't pop them!)
.    address@hidden mm*html-list \\*[misc*st-mm*html-list-stack]
.    address@hidden mm*html-li-status \\*[misc*st-mm*html-li-status-stack]
.    \" if a list is open, appropriately close it, then send another open
.    if '\\*[mm*html-list]'AL' \
.        if '\\*[mm*html-li-status]'OPEN' \
.            HTML-NS </LI><LI>
.    if '\\*[mm*html-list]'AL' \
.        if '\\*[mm*html-li-status]'CLOSED' \
.            HTML-NS <LI>
.    if '\\*[mm*html-list]'ML' \
.        if '\\*[mm*html-li-status]'OPEN' \
.            HTML-NS </LI><LI>
.    if '\\*[mm*html-list]'ML' \
.        if '\\*[mm*html-li-status]'CLOSED' \
.            HTML-NS <LI>
.    if '\\*[mm*html-list]'VL' \
.        if '\\*[mm*html-li-status]'OPEN' \
.            HTML-NS </DD><DT>\\$1</DT><DD>
.    if '\\*[mm*html-list]'VL' \
.        if '\\*[mm*html-li-status]'CLOSED' \
.            HTML-NS <DT>\\$1</DT><DD>
.    \" if item status CLOSED, pop it and push OPEN, else leave it OPEN
.    if '\\*[mm*html-li-status]'CLOSED' \{\
.        address@hidden mm*html-li-status-stack
.        address@hidden mm*html-li-status-stack OPEN
    \}
.    nr mm*html-list-depth  +1
..
.\"=================================================================
.\"     List End
.\"     List termination, detect what kind of list is open and write
.\"     the correct HTML closing tag.  Make sure to close any open
.\"     list items, also.
.\"-----------------------------------------------------------------
.de LE
.    if \\n[mm*html-list-depth]<1 \
.        ab LE trying to close non-existent list.
.    address@hidden mm*html-list \\*[misc*st-mm*html-list-stack]
.    address@hidden mm*html-li-status \\*[misc*st-mm*html-li-status-stack]
.    if '\\*[mm*html-list]'BL' \
.        if '\\*[misc*st-mm*html-li-status]'OPEN' \
.            HTML-NS </LI>
.    if '\\*[mm*html-list]'BL' \
.        HTML-NS </UL>
.    if '\\*[mm*html-list]'ML' \
.        if '\\*[misc*st-mm*html-li-status]'OPEN' \
.            HTML-NS </LI>
.    if '\\*[mm*html-list]'ML' \
.        HTML-NS </UL>
.    if '\\*[mm*html-list]'VL' \
.        if '\\*[misc*st-mm*html-li-status]'OPEN' \
.            HTML </DD>
.    if '\\*[mm*html-list]'VL' \
.        HTML-NS </DL>
.    if '\\*[mm*html-list]'AL' \
.        if '\\*[misc*st-mm*html-li-status]'OPEN' \
.            HTML-NS </LI>
.    if '\\*[mm*html-list]'AL' \
.        HTML-NS </OL>
.        \" pop list and list-status stacks, throw away results
.    address@hidden mm*html-li-status-stack
.    address@hidden mm*html-list-stack
.        \" decrement list depth
.    nr mm*html-list-depth  -1
..

reply via email to

[Prev in Thread] Current Thread [Next in Thread]