358 lines · 6.5 KB · Text
RawDownload
.TH HTMLROFF 6.SH NAMEhtmlroff \- HTML formatting and typesetting.SH DESCRIPTION.IR Htmlroff (1)accepts .I troffinput with a few extensions and changes.This manual describes the changes to the input language,assuming a working knowledge of.I troffitself..SS Name lengths.PPRequest, macro, string, and number names can be longerthan two letters, as in:.IP.EX\&.html c <center>\&.de footnoteFootnote here.\&..\&.footnote\&.ds string "hello\&\e*[string]\&.nr number 1\&\en[number].EE.SS HTML output.PPTwo new requests:.IP.EX\&.html \fIid\fP \fR[ \fI<html>\fP ]\fL\&.ihtml \fIid\fP \fR[ \fI<ihtml>\fP ]\fL.EE.LP.B .htmland.B .ihtmlinsert HTML into the output.The requests are only for opening new HTML tags.To close previously-opened tags, repeat the requestwith the same.IR id .For example, the input:.IP.EX\&.html t <table><tr>\&.html td <td>Cell 1\&.html td <td>Cell 2\&.html td\&.html t.EE.LPproduces this output:.IP.EX<table><tr><td>Cell 1</td><td>Cell 2</td></tr></table>.EE.LPThe.B .htmlrequest is intended for block-level HTML constructs (those that can contain.BR <p> )and maintains the HTML tag stack automatically.Intermediate tags need not be explicitly closed:removing the final.B \&.html tline in the example above would produce the same output.The special.I id.L -closes the HTML tags immediately after printing them..PPThe.B .ihtmlrequest is similar to.B .htmlbut is intended for inline HTML constructs such as.B <b>or.B <i>(those that can be containedwithin .BR <p> ).Unlike.BR .html ,.B .ihtmltreats the open HTML tags as a set rather than a stack:each must be explicitly closed.Although it treats the tags as a set, .B .ihtmltreats nesting properly in the output,closing and reopening tags as necessary.For example, the input:.IP.EX\&.ihtml style <b>\&.ihtml link <a href="link.html">Bold\&.ihtml style <i>and italic, still linked.\&.ihtml link <a>Unlinked.\&.ihtml style.EE.LPproduces this output:.IP.EX<b><a href="link.html">Bold</a></b><i><a href="link.html">and italic, still linked.</i></a><i>Unlinked.</i>.EE.PPOutside of.B .htmland.B .ihtmlrequests, the characters.LR < ,.LR > ,and.L &are treated as normal characters, not HTML markers,and are translated to.LR &lt; ,.LR &gt; ,and.L &amp;on output.To embed the raw HTML markers, use.LR \e< ,.LR \e> ,and.L \e@.RI [ sic ]..SS Font changes.PP.I Htmlroffinterprets the usual .BR \ef ,.BR .ft ,.BR \es ,and.B .psrequests to change the font and point size.After applying each such change to its internal registers,.I htmlroffinvokes the.B .fontmacro to emit corresponding HTML.The default definition of.B .fontis:.IP.EX\&.de font\&.ihtml f1\&.ihtml f\&.ihtml f <span style=\"font-size=\\n(.spt\">\&.if \\n(.f==2 .ihtml f1 <i>\&.if \\n(.f==3 .ihtml f1 <b>\&.if \\n(.f==4 .ihtml f1 <b><i>\&.if \\n(.f==5 .ihtml f1 <tt>\&.if \\n(.f==6 .ihtml f1 <tt><i>\&...EE.LPInput files can redefine.B .fontlike any other request or macro..SS Paragraphs.I Htmlroffimplements line height, text adjustment, and margins by wrapping all output text in .B <p style="...">tags.This behavior can be disabled by setting the.B .paragraphnumber register to zero.Setting the.B .marginregister to zeroeliminates only the margin annotations..SS Subscripts and superscripts.PP.I Htmlroffinterprets the.BR \eu ,.BR \ed ,and.BR \ev requests to move vertically during output.It emits output vertically offset up the page inside.B <sup>tags and output vertically offset down the page inside.B <sub>tags.  This heuristic handles simple equations formatted by.IR eqn (1)..SS Conditional input.PPTo make it easier to write input files that can be formatted by both.I troffand.IR htmlroff ,.I htmlroffadds a new condition.B hwhich evaluates true in.B .ifand.B .ierequests.The.B tcondition continues to evaluate true, to accomodate input files trying to distinguish between.I troffand.IR nroff .To write a conditional matching.I troffalone, use.RB ` ".if !h .if t" '..PP.I Htmlroff 'shandling of conditional input does not match.IR troff 'sexactly.For example,.IP.EX\&.if 0 \e{\e\&.de xx\&..\&.\e}.EE.LPredefines the.B xxmacro in .I troffbut not in.IR htmlroff .Do not write files depending on this behavior, as this bug may be fixedin the future..I Htmlroffalso mishandles.B \e}in some cases.  To work around them, use.B .\e}on a line by itself, as in the last example..SS Diversions.PPDiversions in .I htmlroffuse the alignment in effect at the time of thediversionwhen output.In particular,.IP.EX\&.di xxLine here.\&.di\&.nf\&.ce \&.xx.EE.LPproduces a centered line in .I troffbut not in .IR htmlroff .The solution is to center inside the diversion, as in.IP.EX\&.di xx\&.if h .ce 999Line here\&.di.EE.SS Traps.I Htmlroffimplements traps at vertical position 0,which run when the first character is aboutto be printed.Other position traps are ignored.Input traps are implemented..SS Input pipes.PP.I Htmlroffadds a new request.B .inputpipe.I stop.I cmdthat redirects.IR htmlroff 'sinput into a pipe to .IR cmd .The redirection stops on encountering the line.IR stop ,optionally followed by white space and extra text.This is a dangerous and clumsy request, as .I htmlroffstops interpreting its input during the redirection, so.I stopmust be found in the input itself, not in a macro thatthe input might appear to call.Although clumsy,.B .inputpipeallows input files to invoke.I troffto handle complicated input.For example, .B tmac.htmlredefines the.B PSmacro that marks the beginning of a.IR pic (1)picture:.IP.EX\&.nr png -1 1\&.de PS\&.ds pngbase "\e\e*[basename]\&.if '\e\e*[pngbase]'' .ds pngbase \e\en(.B\&.ds pngfile \e\e*[pngbase]\e\en+[png].png\&.html - <center><img src="\e\e*[pngfile]"></center>\&.inputpipe .PE troff2png >\e\e*[pngfile]\&...EE.LPThis macro invokes the shell script.I troff2pngto run troff and convert the Postscriptoutput to a PNG image file.Before starting the program, the macro createsa new file name for the image and printsHTML referring to it.The.B .Bregister holds the final path element(the base name) of the current input file..SS UnimplementedTabs are set every eight spaces and cannot be changed..PPSome requests, such as .BR .tl ,are unimplemented for lack of a good implementation.Workarounds can be defined as necessary in input files..SH SEE ALSO.IR htmlroff (1),.IR mhtml (6)