groff
[Top][All Lists]
Advanced

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

[Groff] that last mmhtml.tmac I sent


From: Chuck Robey
Subject: [Groff] that last mmhtml.tmac I sent
Date: Mon, 04 Jan 2010 16:49:47 -0500
User-agent: Thunderbird 2.0.0.19 (X11/20090121)

I found (by putting in a larger document into it for testing) that my AL list
might have been screwing up the index number for the 2nd (or later) portions of
embedded AL lists.  I *think* I have it fixed, at least with the doc I'm now
using for testing, so I'm attaching it here.
.\"     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.
.\"-----------------------------------------------------------------
.if '\*[.T]'html' \{\
.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 <OL type=\\*[mm*html-list-mark] 
\\*[mm*html-compact] >
.el .HTML <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 <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 <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 </LI><LI> \" 
OPEN is printing from here
.if '\\*[mm*html-list]'AL' .if '\\*[mm*html-li-status]'CLOSED' .HTML <LI>
.if '\\*[mm*html-list]'ML' .if '\\*[mm*html-li-status]'OPEN' .HTML </LI><LI>
.if '\\*[mm*html-list]'ML' .if '\\*[mm*html-li-status]'CLOSED' .HTML <LI>
.if '\\*[mm*html-list]'VL' .if '\\*[mm*html-li-status]'OPEN' .HTML 
</DD><DT>\\$1</DT><DD>
.if '\\*[mm*html-list]'VL' .if '\\*[mm*html-li-status]'CLOSED' .HTML 
<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 </LI>
.if '\\*[mm*html-list]'BL' .HTML </UL>
.if '\\*[mm*html-list]'ML' .if '\\*[misc*st-mm*html-li-status]'OPEN' .HTML </LI>
.if '\\*[mm*html-list]'ML' .HTML </UL>
.if '\\*[mm*html-list]'VL' .if '\\*[misc*st-mm*html-li-status]'OPEN' .HTML </DD>
.if '\\*[mm*html-list]'VL' .HTML </DL>
.if '\\*[mm*html-list]'AL' .if '\\*[misc*st-mm*html-li-status]'OPEN' .HTML </LI>
.if '\\*[mm*html-list]'AL' .HTML </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]