10Sstevel@tonic-gatepackage Pod::LaTeX; 20Sstevel@tonic-gate 30Sstevel@tonic-gate=head1 NAME 40Sstevel@tonic-gate 50Sstevel@tonic-gatePod::LaTeX - Convert Pod data to formatted Latex 60Sstevel@tonic-gate 70Sstevel@tonic-gate=head1 SYNOPSIS 80Sstevel@tonic-gate 90Sstevel@tonic-gate use Pod::LaTeX; 100Sstevel@tonic-gate my $parser = Pod::LaTeX->new ( ); 110Sstevel@tonic-gate 120Sstevel@tonic-gate $parser->parse_from_filehandle; 130Sstevel@tonic-gate 140Sstevel@tonic-gate $parser->parse_from_file ('file.pod', 'file.tex'); 150Sstevel@tonic-gate 160Sstevel@tonic-gate=head1 DESCRIPTION 170Sstevel@tonic-gate 180Sstevel@tonic-gateC<Pod::LaTeX> is a module to convert documentation in the Pod format 190Sstevel@tonic-gateinto Latex. The L<B<pod2latex>|pod2latex> X<pod2latex> command uses 200Sstevel@tonic-gatethis module for translation. 210Sstevel@tonic-gate 220Sstevel@tonic-gateC<Pod::LaTeX> is a derived class from L<Pod::Select|Pod::Select>. 230Sstevel@tonic-gate 240Sstevel@tonic-gate=cut 250Sstevel@tonic-gate 260Sstevel@tonic-gate 270Sstevel@tonic-gateuse strict; 280Sstevel@tonic-gaterequire Pod::ParseUtils; 290Sstevel@tonic-gateuse base qw/ Pod::Select /; 300Sstevel@tonic-gate 310Sstevel@tonic-gate# use Data::Dumper; # for debugging 320Sstevel@tonic-gateuse Carp; 330Sstevel@tonic-gate 340Sstevel@tonic-gateuse vars qw/ $VERSION %HTML_Escapes @LatexSections /; 350Sstevel@tonic-gate 360Sstevel@tonic-gate$VERSION = '0.55'; 370Sstevel@tonic-gate 380Sstevel@tonic-gate# Definitions of =headN -> latex mapping 390Sstevel@tonic-gate@LatexSections = (qw/ 400Sstevel@tonic-gate chapter 410Sstevel@tonic-gate section 420Sstevel@tonic-gate subsection 430Sstevel@tonic-gate subsubsection 440Sstevel@tonic-gate paragraph 450Sstevel@tonic-gate subparagraph 460Sstevel@tonic-gate /); 470Sstevel@tonic-gate 480Sstevel@tonic-gate# Standard escape sequences converted to Latex. 490Sstevel@tonic-gate# The Unicode name of each character is given in the comments. 500Sstevel@tonic-gate# Complete LaTeX set added by Peter Acklam. 510Sstevel@tonic-gate 520Sstevel@tonic-gate%HTML_Escapes = ( 530Sstevel@tonic-gate 'sol' => '\textfractionsolidus{}', # xxx - or should it be just '/' 540Sstevel@tonic-gate 'verbar' => '|', 550Sstevel@tonic-gate 560Sstevel@tonic-gate # The stuff below is based on the information available at 570Sstevel@tonic-gate # http://www.w3.org/TR/html401/sgml/entities.html 580Sstevel@tonic-gate 590Sstevel@tonic-gate # All characters in the range 0xA0-0xFF of the ISO 8859-1 character set. 600Sstevel@tonic-gate # Several of these characters require the `textcomp' LaTeX package. 610Sstevel@tonic-gate 'nbsp' => q|~|, # 0xA0 - no-break space = non-breaking space 620Sstevel@tonic-gate 'iexcl' => q|\textexclamdown{}|, # 0xA1 - inverted exclamation mark 630Sstevel@tonic-gate 'cent' => q|\textcent{}|, # 0xA2 - cent sign 640Sstevel@tonic-gate 'pound' => q|\textsterling{}|, # 0xA3 - pound sign 650Sstevel@tonic-gate 'curren' => q|\textcurrency{}|, # 0xA4 - currency sign 660Sstevel@tonic-gate 'yen' => q|\textyen{}|, # 0xA5 - yen sign = yuan sign 670Sstevel@tonic-gate 'brvbar' => q|\textbrokenbar{}|, # 0xA6 - broken bar = broken vertical bar 680Sstevel@tonic-gate 'sect' => q|\textsection{}|, # 0xA7 - section sign 690Sstevel@tonic-gate 'uml' => q|\textasciidieresis{}|, # 0xA8 - diaeresis = spacing diaeresis 700Sstevel@tonic-gate 'copy' => q|\textcopyright{}|, # 0xA9 - copyright sign 710Sstevel@tonic-gate 'ordf' => q|\textordfeminine{}|, # 0xAA - feminine ordinal indicator 720Sstevel@tonic-gate 'laquo' => q|\guillemotleft{}|, # 0xAB - left-pointing double angle quotation mark = left pointing guillemet 730Sstevel@tonic-gate 'not' => q|\textlnot{}|, # 0xAC - not sign 740Sstevel@tonic-gate 'shy' => q|\-|, # 0xAD - soft hyphen = discretionary hyphen 750Sstevel@tonic-gate 'reg' => q|\textregistered{}|, # 0xAE - registered sign = registered trade mark sign 760Sstevel@tonic-gate 'macr' => q|\textasciimacron{}|, # 0xAF - macron = spacing macron = overline = APL overbar 770Sstevel@tonic-gate 'deg' => q|\textdegree{}|, # 0xB0 - degree sign 780Sstevel@tonic-gate 'plusmn' => q|\textpm{}|, # 0xB1 - plus-minus sign = plus-or-minus sign 790Sstevel@tonic-gate 'sup2' => q|\texttwosuperior{}|, # 0xB2 - superscript two = superscript digit two = squared 800Sstevel@tonic-gate 'sup3' => q|\textthreesuperior{}|, # 0xB3 - superscript three = superscript digit three = cubed 810Sstevel@tonic-gate 'acute' => q|\textasciiacute{}|, # 0xB4 - acute accent = spacing acute 820Sstevel@tonic-gate 'micro' => q|\textmu{}|, # 0xB5 - micro sign 830Sstevel@tonic-gate 'para' => q|\textparagraph{}|, # 0xB6 - pilcrow sign = paragraph sign 840Sstevel@tonic-gate 'middot' => q|\textperiodcentered{}|, # 0xB7 - middle dot = Georgian comma = Greek middle dot 850Sstevel@tonic-gate 'cedil' => q|\c{}|, # 0xB8 - cedilla = spacing cedilla 860Sstevel@tonic-gate 'sup1' => q|\textonesuperior{}|, # 0xB9 - superscript one = superscript digit one 870Sstevel@tonic-gate 'ordm' => q|\textordmasculine{}|, # 0xBA - masculine ordinal indicator 880Sstevel@tonic-gate 'raquo' => q|\guillemotright{}|, # 0xBB - right-pointing double angle quotation mark = right pointing guillemet 890Sstevel@tonic-gate 'frac14' => q|\textonequarter{}|, # 0xBC - vulgar fraction one quarter = fraction one quarter 900Sstevel@tonic-gate 'frac12' => q|\textonehalf{}|, # 0xBD - vulgar fraction one half = fraction one half 910Sstevel@tonic-gate 'frac34' => q|\textthreequarters{}|, # 0xBE - vulgar fraction three quarters = fraction three quarters 920Sstevel@tonic-gate 'iquest' => q|\textquestiondown{}|, # 0xBF - inverted question mark = turned question mark 930Sstevel@tonic-gate 'Agrave' => q|\`A|, # 0xC0 - latin capital letter A with grave = latin capital letter A grave 940Sstevel@tonic-gate 'Aacute' => q|\'A|, # 0xC1 - latin capital letter A with acute 950Sstevel@tonic-gate 'Acirc' => q|\^A|, # 0xC2 - latin capital letter A with circumflex 960Sstevel@tonic-gate 'Atilde' => q|\~A|, # 0xC3 - latin capital letter A with tilde 970Sstevel@tonic-gate 'Auml' => q|\"A|, # 0xC4 - latin capital letter A with diaeresis 980Sstevel@tonic-gate 'Aring' => q|\AA{}|, # 0xC5 - latin capital letter A with ring above = latin capital letter A ring 990Sstevel@tonic-gate 'AElig' => q|\AE{}|, # 0xC6 - latin capital letter AE = latin capital ligature AE 1000Sstevel@tonic-gate 'Ccedil' => q|\c{C}|, # 0xC7 - latin capital letter C with cedilla 1010Sstevel@tonic-gate 'Egrave' => q|\`E|, # 0xC8 - latin capital letter E with grave 1020Sstevel@tonic-gate 'Eacute' => q|\'E|, # 0xC9 - latin capital letter E with acute 1030Sstevel@tonic-gate 'Ecirc' => q|\^E|, # 0xCA - latin capital letter E with circumflex 1040Sstevel@tonic-gate 'Euml' => q|\"E|, # 0xCB - latin capital letter E with diaeresis 1050Sstevel@tonic-gate 'Igrave' => q|\`I|, # 0xCC - latin capital letter I with grave 1060Sstevel@tonic-gate 'Iacute' => q|\'I|, # 0xCD - latin capital letter I with acute 1070Sstevel@tonic-gate 'Icirc' => q|\^I|, # 0xCE - latin capital letter I with circumflex 1080Sstevel@tonic-gate 'Iuml' => q|\"I|, # 0xCF - latin capital letter I with diaeresis 1090Sstevel@tonic-gate 'ETH' => q|\DH{}|, # 0xD0 - latin capital letter ETH 1100Sstevel@tonic-gate 'Ntilde' => q|\~N|, # 0xD1 - latin capital letter N with tilde 1110Sstevel@tonic-gate 'Ograve' => q|\`O|, # 0xD2 - latin capital letter O with grave 1120Sstevel@tonic-gate 'Oacute' => q|\'O|, # 0xD3 - latin capital letter O with acute 1130Sstevel@tonic-gate 'Ocirc' => q|\^O|, # 0xD4 - latin capital letter O with circumflex 1140Sstevel@tonic-gate 'Otilde' => q|\~O|, # 0xD5 - latin capital letter O with tilde 1150Sstevel@tonic-gate 'Ouml' => q|\"O|, # 0xD6 - latin capital letter O with diaeresis 1160Sstevel@tonic-gate 'times' => q|\texttimes{}|, # 0xD7 - multiplication sign 1170Sstevel@tonic-gate 'Oslash' => q|\O{}|, # 0xD8 - latin capital letter O with stroke = latin capital letter O slash 1180Sstevel@tonic-gate 'Ugrave' => q|\`U|, # 0xD9 - latin capital letter U with grave 1190Sstevel@tonic-gate 'Uacute' => q|\'U|, # 0xDA - latin capital letter U with acute 1200Sstevel@tonic-gate 'Ucirc' => q|\^U|, # 0xDB - latin capital letter U with circumflex 1210Sstevel@tonic-gate 'Uuml' => q|\"U|, # 0xDC - latin capital letter U with diaeresis 1220Sstevel@tonic-gate 'Yacute' => q|\'Y|, # 0xDD - latin capital letter Y with acute 1230Sstevel@tonic-gate 'THORN' => q|\TH{}|, # 0xDE - latin capital letter THORN 1240Sstevel@tonic-gate 'szlig' => q|\ss{}|, # 0xDF - latin small letter sharp s = ess-zed 1250Sstevel@tonic-gate 'agrave' => q|\`a|, # 0xE0 - latin small letter a with grave = latin small letter a grave 1260Sstevel@tonic-gate 'aacute' => q|\'a|, # 0xE1 - latin small letter a with acute 1270Sstevel@tonic-gate 'acirc' => q|\^a|, # 0xE2 - latin small letter a with circumflex 1280Sstevel@tonic-gate 'atilde' => q|\~a|, # 0xE3 - latin small letter a with tilde 1290Sstevel@tonic-gate 'auml' => q|\"a|, # 0xE4 - latin small letter a with diaeresis 1300Sstevel@tonic-gate 'aring' => q|\aa{}|, # 0xE5 - latin small letter a with ring above = latin small letter a ring 1310Sstevel@tonic-gate 'aelig' => q|\ae{}|, # 0xE6 - latin small letter ae = latin small ligature ae 1320Sstevel@tonic-gate 'ccedil' => q|\c{c}|, # 0xE7 - latin small letter c with cedilla 1330Sstevel@tonic-gate 'egrave' => q|\`e|, # 0xE8 - latin small letter e with grave 1340Sstevel@tonic-gate 'eacute' => q|\'e|, # 0xE9 - latin small letter e with acute 1350Sstevel@tonic-gate 'ecirc' => q|\^e|, # 0xEA - latin small letter e with circumflex 1360Sstevel@tonic-gate 'euml' => q|\"e|, # 0xEB - latin small letter e with diaeresis 1370Sstevel@tonic-gate 'igrave' => q|\`i|, # 0xEC - latin small letter i with grave 1380Sstevel@tonic-gate 'iacute' => q|\'i|, # 0xED - latin small letter i with acute 1390Sstevel@tonic-gate 'icirc' => q|\^i|, # 0xEE - latin small letter i with circumflex 1400Sstevel@tonic-gate 'iuml' => q|\"i|, # 0xEF - latin small letter i with diaeresis 1410Sstevel@tonic-gate 'eth' => q|\dh{}|, # 0xF0 - latin small letter eth 1420Sstevel@tonic-gate 'ntilde' => q|\~n|, # 0xF1 - latin small letter n with tilde 1430Sstevel@tonic-gate 'ograve' => q|\`o|, # 0xF2 - latin small letter o with grave 1440Sstevel@tonic-gate 'oacute' => q|\'o|, # 0xF3 - latin small letter o with acute 1450Sstevel@tonic-gate 'ocirc' => q|\^o|, # 0xF4 - latin small letter o with circumflex 1460Sstevel@tonic-gate 'otilde' => q|\~o|, # 0xF5 - latin small letter o with tilde 1470Sstevel@tonic-gate 'ouml' => q|\"o|, # 0xF6 - latin small letter o with diaeresis 1480Sstevel@tonic-gate 'divide' => q|\textdiv{}|, # 0xF7 - division sign 1490Sstevel@tonic-gate 'oslash' => q|\o{}|, # 0xF8 - latin small letter o with stroke, = latin small letter o slash 1500Sstevel@tonic-gate 'ugrave' => q|\`u|, # 0xF9 - latin small letter u with grave 1510Sstevel@tonic-gate 'uacute' => q|\'u|, # 0xFA - latin small letter u with acute 1520Sstevel@tonic-gate 'ucirc' => q|\^u|, # 0xFB - latin small letter u with circumflex 1530Sstevel@tonic-gate 'uuml' => q|\"u|, # 0xFC - latin small letter u with diaeresis 1540Sstevel@tonic-gate 'yacute' => q|\'y|, # 0xFD - latin small letter y with acute 1550Sstevel@tonic-gate 'thorn' => q|\th{}|, # 0xFE - latin small letter thorn 1560Sstevel@tonic-gate 'yuml' => q|\"y|, # 0xFF - latin small letter y with diaeresis 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate # Latin Extended-B 1590Sstevel@tonic-gate 'fnof' => q|\textflorin{}|, # latin small f with hook = function = florin 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate # Greek 1620Sstevel@tonic-gate 'Alpha' => q|$\mathrm{A}$|, # greek capital letter alpha 1630Sstevel@tonic-gate 'Beta' => q|$\mathrm{B}$|, # greek capital letter beta 1640Sstevel@tonic-gate 'Gamma' => q|$\Gamma$|, # greek capital letter gamma 1650Sstevel@tonic-gate 'Delta' => q|$\Delta$|, # greek capital letter delta 1660Sstevel@tonic-gate 'Epsilon' => q|$\mathrm{E}$|, # greek capital letter epsilon 1670Sstevel@tonic-gate 'Zeta' => q|$\mathrm{Z}$|, # greek capital letter zeta 1680Sstevel@tonic-gate 'Eta' => q|$\mathrm{H}$|, # greek capital letter eta 1690Sstevel@tonic-gate 'Theta' => q|$\Theta$|, # greek capital letter theta 1700Sstevel@tonic-gate 'Iota' => q|$\mathrm{I}$|, # greek capital letter iota 1710Sstevel@tonic-gate 'Kappa' => q|$\mathrm{K}$|, # greek capital letter kappa 1720Sstevel@tonic-gate 'Lambda' => q|$\Lambda$|, # greek capital letter lambda 1730Sstevel@tonic-gate 'Mu' => q|$\mathrm{M}$|, # greek capital letter mu 1740Sstevel@tonic-gate 'Nu' => q|$\mathrm{N}$|, # greek capital letter nu 1750Sstevel@tonic-gate 'Xi' => q|$\Xi$|, # greek capital letter xi 1760Sstevel@tonic-gate 'Omicron' => q|$\mathrm{O}$|, # greek capital letter omicron 1770Sstevel@tonic-gate 'Pi' => q|$\Pi$|, # greek capital letter pi 1780Sstevel@tonic-gate 'Rho' => q|$\mathrm{R}$|, # greek capital letter rho 1790Sstevel@tonic-gate 'Sigma' => q|$\Sigma$|, # greek capital letter sigma 1800Sstevel@tonic-gate 'Tau' => q|$\mathrm{T}$|, # greek capital letter tau 1810Sstevel@tonic-gate 'Upsilon' => q|$\Upsilon$|, # greek capital letter upsilon 1820Sstevel@tonic-gate 'Phi' => q|$\Phi$|, # greek capital letter phi 1830Sstevel@tonic-gate 'Chi' => q|$\mathrm{X}$|, # greek capital letter chi 1840Sstevel@tonic-gate 'Psi' => q|$\Psi$|, # greek capital letter psi 1850Sstevel@tonic-gate 'Omega' => q|$\Omega$|, # greek capital letter omega 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate 'alpha' => q|$\alpha$|, # greek small letter alpha 1880Sstevel@tonic-gate 'beta' => q|$\beta$|, # greek small letter beta 1890Sstevel@tonic-gate 'gamma' => q|$\gamma$|, # greek small letter gamma 1900Sstevel@tonic-gate 'delta' => q|$\delta$|, # greek small letter delta 1910Sstevel@tonic-gate 'epsilon' => q|$\epsilon$|, # greek small letter epsilon 1920Sstevel@tonic-gate 'zeta' => q|$\zeta$|, # greek small letter zeta 1930Sstevel@tonic-gate 'eta' => q|$\eta$|, # greek small letter eta 1940Sstevel@tonic-gate 'theta' => q|$\theta$|, # greek small letter theta 1950Sstevel@tonic-gate 'iota' => q|$\iota$|, # greek small letter iota 1960Sstevel@tonic-gate 'kappa' => q|$\kappa$|, # greek small letter kappa 1970Sstevel@tonic-gate 'lambda' => q|$\lambda$|, # greek small letter lambda 1980Sstevel@tonic-gate 'mu' => q|$\mu$|, # greek small letter mu 1990Sstevel@tonic-gate 'nu' => q|$\nu$|, # greek small letter nu 2000Sstevel@tonic-gate 'xi' => q|$\xi$|, # greek small letter xi 2010Sstevel@tonic-gate 'omicron' => q|$o$|, # greek small letter omicron 2020Sstevel@tonic-gate 'pi' => q|$\pi$|, # greek small letter pi 2030Sstevel@tonic-gate 'rho' => q|$\rho$|, # greek small letter rho 2040Sstevel@tonic-gate# 'sigmaf' => q||, # greek small letter final sigma 2050Sstevel@tonic-gate 'sigma' => q|$\sigma$|, # greek small letter sigma 2060Sstevel@tonic-gate 'tau' => q|$\tau$|, # greek small letter tau 2070Sstevel@tonic-gate 'upsilon' => q|$\upsilon$|, # greek small letter upsilon 2080Sstevel@tonic-gate 'phi' => q|$\phi$|, # greek small letter phi 2090Sstevel@tonic-gate 'chi' => q|$\chi$|, # greek small letter chi 2100Sstevel@tonic-gate 'psi' => q|$\psi$|, # greek small letter psi 2110Sstevel@tonic-gate 'omega' => q|$\omega$|, # greek small letter omega 2120Sstevel@tonic-gate# 'thetasym' => q||, # greek small letter theta symbol 2130Sstevel@tonic-gate# 'upsih' => q||, # greek upsilon with hook symbol 2140Sstevel@tonic-gate# 'piv' => q||, # greek pi symbol 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate # General Punctuation 2170Sstevel@tonic-gate 'bull' => q|\textbullet{}|, # bullet = black small circle 2180Sstevel@tonic-gate # bullet is NOT the same as bullet operator 2190Sstevel@tonic-gate 'hellip' => q|\textellipsis{}|, # horizontal ellipsis = three dot leader 2200Sstevel@tonic-gate 'prime' => q|\textquotesingle{}|, # prime = minutes = feet 2210Sstevel@tonic-gate 'Prime' => q|\textquotedbl{}|, # double prime = seconds = inches 2220Sstevel@tonic-gate 'oline' => q|\textasciimacron{}|, # overline = spacing overscore 2230Sstevel@tonic-gate 'frasl' => q|\textfractionsolidus{}|, # fraction slash 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate # Letterlike Symbols 2260Sstevel@tonic-gate 'weierp' => q|$\wp$|, # script capital P = power set = Weierstrass p 2270Sstevel@tonic-gate 'image' => q|$\Re$|, # blackletter capital I = imaginary part 2280Sstevel@tonic-gate 'real' => q|$\Im$|, # blackletter capital R = real part symbol 2290Sstevel@tonic-gate 'trade' => q|\texttrademark{}|, # trade mark sign 2300Sstevel@tonic-gate# 'alefsym' => q||, # alef symbol = first transfinite cardinal 2310Sstevel@tonic-gate # alef symbol is NOT the same as hebrew letter alef, although the same 2320Sstevel@tonic-gate # glyph could be used to depict both characters 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate # Arrows 2350Sstevel@tonic-gate 'larr' => q|\textleftarrow{}|, # leftwards arrow 2360Sstevel@tonic-gate 'uarr' => q|\textuparrow{}|, # upwards arrow 2370Sstevel@tonic-gate 'rarr' => q|\textrightarrow{}|, # rightwards arrow 2380Sstevel@tonic-gate 'darr' => q|\textdownarrow{}|, # downwards arrow 2390Sstevel@tonic-gate 'harr' => q|$\leftrightarrow$|, # left right arrow 2400Sstevel@tonic-gate# 'crarr' => q||, # downwards arrow with corner leftwards = carriage return 2410Sstevel@tonic-gate 'lArr' => q|$\Leftarrow$|, # leftwards double arrow 2420Sstevel@tonic-gate # ISO 10646 does not say that lArr is the same as the 'is implied by' 2430Sstevel@tonic-gate # arrow but also does not have any other character for that function. So 2440Sstevel@tonic-gate # lArr can be used for 'is implied by' as ISOtech suggests 2450Sstevel@tonic-gate 'uArr' => q|$\Uparrow$|, # upwards double arrow 2460Sstevel@tonic-gate 'rArr' => q|$\Rightarrow$|, # rightwards double arrow 2470Sstevel@tonic-gate # ISO 10646 does not say this is the 'implies' character but does not 2480Sstevel@tonic-gate # have another character with this function so ? rArr can be used for 2490Sstevel@tonic-gate # 'implies' as ISOtech suggests 2500Sstevel@tonic-gate 'dArr' => q|$\Downarrow$|, # downwards double arrow 2510Sstevel@tonic-gate 'hArr' => q|$\Leftrightarrow$|, # left right double arrow 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate # Mathematical Operators. 2540Sstevel@tonic-gate # Some of these require the `amssymb' package. 2550Sstevel@tonic-gate 'forall' => q|$\forall$|, # for all 2560Sstevel@tonic-gate 'part' => q|$\partial$|, # partial differential 2570Sstevel@tonic-gate 'exist' => q|$\exists$|, # there exists 2580Sstevel@tonic-gate 'empty' => q|$\emptyset$|, # empty set = null set = diameter 2590Sstevel@tonic-gate 'nabla' => q|$\nabla$|, # nabla = backward difference 2600Sstevel@tonic-gate 'isin' => q|$\in$|, # element of 2610Sstevel@tonic-gate 'notin' => q|$\notin$|, # not an element of 2620Sstevel@tonic-gate 'ni' => q|$\ni$|, # contains as member 2630Sstevel@tonic-gate 'prod' => q|$\prod$|, # n-ary product = product sign 2640Sstevel@tonic-gate # prod is NOT the same character as 'greek capital letter pi' though the 2650Sstevel@tonic-gate # same glyph might be used for both 2660Sstevel@tonic-gate 'sum' => q|$\sum$|, # n-ary sumation 2670Sstevel@tonic-gate # sum is NOT the same character as 'greek capital letter sigma' though 2680Sstevel@tonic-gate # the same glyph might be used for both 2690Sstevel@tonic-gate 'minus' => q|$-$|, # minus sign 2700Sstevel@tonic-gate 'lowast' => q|$\ast$|, # asterisk operator 2710Sstevel@tonic-gate 'radic' => q|$\surd$|, # square root = radical sign 2720Sstevel@tonic-gate 'prop' => q|$\propto$|, # proportional to 2730Sstevel@tonic-gate 'infin' => q|$\infty$|, # infinity 2740Sstevel@tonic-gate 'ang' => q|$\angle$|, # angle 2750Sstevel@tonic-gate 'and' => q|$\wedge$|, # logical and = wedge 2760Sstevel@tonic-gate 'or' => q|$\vee$|, # logical or = vee 2770Sstevel@tonic-gate 'cap' => q|$\cap$|, # intersection = cap 2780Sstevel@tonic-gate 'cup' => q|$\cup$|, # union = cup 2790Sstevel@tonic-gate 'int' => q|$\int$|, # integral 2800Sstevel@tonic-gate 'there4' => q|$\therefore$|, # therefore 2810Sstevel@tonic-gate 'sim' => q|$\sim$|, # tilde operator = varies with = similar to 2820Sstevel@tonic-gate # tilde operator is NOT the same character as the tilde 2830Sstevel@tonic-gate 'cong' => q|$\cong$|, # approximately equal to 2840Sstevel@tonic-gate 'asymp' => q|$\asymp$|, # almost equal to = asymptotic to 2850Sstevel@tonic-gate 'ne' => q|$\neq$|, # not equal to 2860Sstevel@tonic-gate 'equiv' => q|$\equiv$|, # identical to 2870Sstevel@tonic-gate 'le' => q|$\leq$|, # less-than or equal to 2880Sstevel@tonic-gate 'ge' => q|$\geq$|, # greater-than or equal to 2890Sstevel@tonic-gate 'sub' => q|$\subset$|, # subset of 2900Sstevel@tonic-gate 'sup' => q|$\supset$|, # superset of 2910Sstevel@tonic-gate # note that nsup, 'not a superset of' is not covered by the Symbol font 2920Sstevel@tonic-gate # encoding and is not included. 2930Sstevel@tonic-gate 'nsub' => q|$\not\subset$|, # not a subset of 2940Sstevel@tonic-gate 'sube' => q|$\subseteq$|, # subset of or equal to 2950Sstevel@tonic-gate 'supe' => q|$\supseteq$|, # superset of or equal to 2960Sstevel@tonic-gate 'oplus' => q|$\oplus$|, # circled plus = direct sum 2970Sstevel@tonic-gate 'otimes' => q|$\otimes$|, # circled times = vector product 2980Sstevel@tonic-gate 'perp' => q|$\perp$|, # up tack = orthogonal to = perpendicular 2990Sstevel@tonic-gate 'sdot' => q|$\cdot$|, # dot operator 3000Sstevel@tonic-gate # dot operator is NOT the same character as middle dot 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate # Miscellaneous Technical 3030Sstevel@tonic-gate 'lceil' => q|$\lceil$|, # left ceiling = apl upstile 3040Sstevel@tonic-gate 'rceil' => q|$\rceil$|, # right ceiling 3050Sstevel@tonic-gate 'lfloor' => q|$\lfloor$|, # left floor = apl downstile 3060Sstevel@tonic-gate 'rfloor' => q|$\rfloor$|, # right floor 3070Sstevel@tonic-gate 'lang' => q|$\langle$|, # left-pointing angle bracket = bra 3080Sstevel@tonic-gate # lang is NOT the same character as 'less than' or 'single left-pointing 3090Sstevel@tonic-gate # angle quotation mark' 3100Sstevel@tonic-gate 'rang' => q|$\rangle$|, # right-pointing angle bracket = ket 3110Sstevel@tonic-gate # rang is NOT the same character as 'greater than' or 'single 3120Sstevel@tonic-gate # right-pointing angle quotation mark' 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate # Geometric Shapes 3150Sstevel@tonic-gate 'loz' => q|$\lozenge$|, # lozenge 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate # Miscellaneous Symbols 3180Sstevel@tonic-gate 'spades' => q|$\spadesuit$|, # black spade suit 3190Sstevel@tonic-gate 'clubs' => q|$\clubsuit$|, # black club suit = shamrock 3200Sstevel@tonic-gate 'hearts' => q|$\heartsuit$|, # black heart suit = valentine 3210Sstevel@tonic-gate 'diams' => q|$\diamondsuit$|, # black diamond suit 3220Sstevel@tonic-gate 3230Sstevel@tonic-gate # C0 Controls and Basic Latin 3240Sstevel@tonic-gate 'quot' => q|"|, # quotation mark = APL quote ["] 3250Sstevel@tonic-gate 'amp' => q|\&|, # ampersand 3260Sstevel@tonic-gate 'lt' => q|<|, # less-than sign 3270Sstevel@tonic-gate 'gt' => q|>|, # greater-than sign 3280Sstevel@tonic-gate 'OElig' => q|\OE{}|, # latin capital ligature OE 3290Sstevel@tonic-gate 'oelig' => q|\oe{}|, # latin small ligature oe 3300Sstevel@tonic-gate 'Scaron' => q|\v{S}|, # latin capital letter S with caron 3310Sstevel@tonic-gate 'scaron' => q|\v{s}|, # latin small letter s with caron 3320Sstevel@tonic-gate 'Yuml' => q|\"Y|, # latin capital letter Y with diaeresis 3330Sstevel@tonic-gate 'circ' => q|\textasciicircum{}|, # modifier letter circumflex accent 3340Sstevel@tonic-gate 'tilde' => q|\textasciitilde{}|, # small tilde 3350Sstevel@tonic-gate 'ensp' => q|\phantom{n}|, # en space 3360Sstevel@tonic-gate 'emsp' => q|\hspace{1em}|, # em space 3370Sstevel@tonic-gate 'thinsp' => q|\,|, # thin space 3380Sstevel@tonic-gate 'zwnj' => q|{}|, # zero width non-joiner 3390Sstevel@tonic-gate# 'zwj' => q||, # zero width joiner 3400Sstevel@tonic-gate# 'lrm' => q||, # left-to-right mark 3410Sstevel@tonic-gate# 'rlm' => q||, # right-to-left mark 3420Sstevel@tonic-gate 'ndash' => q|--|, # en dash 3430Sstevel@tonic-gate 'mdash' => q|---|, # em dash 3440Sstevel@tonic-gate 'lsquo' => q|\textquoteleft{}|, # left single quotation mark 3450Sstevel@tonic-gate 'rsquo' => q|\textquoteright{}|, # right single quotation mark 3460Sstevel@tonic-gate 'sbquo' => q|\quotesinglbase{}|, # single low-9 quotation mark 3470Sstevel@tonic-gate 'ldquo' => q|\textquotedblleft{}|, # left double quotation mark 3480Sstevel@tonic-gate 'rdquo' => q|\textquotedblright{}|, # right double quotation mark 3490Sstevel@tonic-gate 'bdquo' => q|\quotedblbase{}|, # double low-9 quotation mark 3500Sstevel@tonic-gate 'dagger' => q|\textdagger{}|, # dagger 3510Sstevel@tonic-gate 'Dagger' => q|\textdaggerdbl{}|, # double dagger 3520Sstevel@tonic-gate 'permil' => q|\textperthousand{}|, # per mille sign 3530Sstevel@tonic-gate 'lsaquo' => q|\guilsinglleft{}|, # single left-pointing angle quotation mark 3540Sstevel@tonic-gate 'rsaquo' => q|\guilsinglright{}|, # single right-pointing angle quotation mark 3550Sstevel@tonic-gate 'euro' => q|\texteuro{}|, # euro sign 3560Sstevel@tonic-gate); 3570Sstevel@tonic-gate 3580Sstevel@tonic-gate=head1 OBJECT METHODS 3590Sstevel@tonic-gate 3600Sstevel@tonic-gateThe following methods are provided in this module. Methods inherited 3610Sstevel@tonic-gatefrom C<Pod::Select> are not described in the public interface. 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate=over 4 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate=begin __PRIVATE__ 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate=item C<initialize> 3680Sstevel@tonic-gate 3690Sstevel@tonic-gateInitialise the object. This method is subclassed from C<Pod::Parser>. 3700Sstevel@tonic-gateThe base class method is invoked. This method defines the default 3710Sstevel@tonic-gatebehaviour of the object unless overridden by supplying arguments to 3720Sstevel@tonic-gatethe constructor. 3730Sstevel@tonic-gate 3740Sstevel@tonic-gateInternal settings are defaulted as well as the public instance data. 3750Sstevel@tonic-gateInternal hash values are accessed directly (rather than through 3760Sstevel@tonic-gatea method) and start with an underscore. 3770Sstevel@tonic-gate 3780Sstevel@tonic-gateThis method should not be invoked by the user directly. 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate=end __PRIVATE__ 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate=cut 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate# - An array for nested lists 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate# Arguments have already been read by this point 3890Sstevel@tonic-gate 3900Sstevel@tonic-gatesub initialize { 3910Sstevel@tonic-gate my $self = shift; 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate # print Dumper($self); 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate # Internals 3960Sstevel@tonic-gate $self->{_Lists} = []; # For nested lists 3970Sstevel@tonic-gate $self->{_suppress_all_para} = 0; # For =begin blocks 3980Sstevel@tonic-gate $self->{_dont_modify_any_para}=0; # For =begin blocks 3990Sstevel@tonic-gate $self->{_CURRENT_HEAD1} = ''; # Name of current HEAD1 section 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate # Options - only initialise if not already set 4020Sstevel@tonic-gate 4030Sstevel@tonic-gate # Cause the '=head1 NAME' field to be treated specially 4040Sstevel@tonic-gate # The contents of the NAME paragraph will be converted 4050Sstevel@tonic-gate # to a section title. All subsequent =head1 will be converted 4060Sstevel@tonic-gate # to =head2 and down. Will not affect =head1's prior to NAME 4070Sstevel@tonic-gate # Assumes: 'Module - purpose' format 4080Sstevel@tonic-gate # Also creates a purpose field 4090Sstevel@tonic-gate # The name is used for Labeling of the subsequent subsections 4100Sstevel@tonic-gate $self->{ReplaceNAMEwithSection} = 0 4110Sstevel@tonic-gate unless exists $self->{ReplaceNAMEwithSection}; 4120Sstevel@tonic-gate $self->{AddPreamble} = 1 # make full latex document 4130Sstevel@tonic-gate unless exists $self->{AddPreamble}; 4140Sstevel@tonic-gate $self->{StartWithNewPage} = 0 # Start new page for pod section 4150Sstevel@tonic-gate unless exists $self->{StartWithNewPage}; 4160Sstevel@tonic-gate $self->{TableOfContents} = 0 # Add table of contents 417*3517Smp204432 unless exists $self->{TableOfContents}; # only relevant if AddPreamble=1 4180Sstevel@tonic-gate $self->{AddPostamble} = 1 # Add closing latex code at end 4190Sstevel@tonic-gate unless exists $self->{AddPostamble}; # effectively end{document} and index 4200Sstevel@tonic-gate $self->{MakeIndex} = 1 # Add index (only relevant AddPostamble 4210Sstevel@tonic-gate unless exists $self->{MakeIndex}; # and AddPreamble) 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate $self->{UniqueLabels} = 1 # Use label unique for each pod 4240Sstevel@tonic-gate unless exists $self->{UniqueLabels}; # either based on the filename 4250Sstevel@tonic-gate # or supplied 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate # Control the level of =head1. default is \section 4280Sstevel@tonic-gate # 4290Sstevel@tonic-gate $self->{Head1Level} = 1 # Offset in latex sections 4300Sstevel@tonic-gate unless exists $self->{Head1Level}; # 0 is chapter, 2 is subsection 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate # Control at which level numbering of sections is turned off 4330Sstevel@tonic-gate # ie subsection becomes subsection* 4340Sstevel@tonic-gate # The numbering is relative to the latex sectioning commands 4350Sstevel@tonic-gate # and is independent of Pod heading level 4360Sstevel@tonic-gate # default is to number \section but not \subsection 4370Sstevel@tonic-gate $self->{LevelNoNum} = 2 4380Sstevel@tonic-gate unless exists $self->{LevelNoNum}; 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate # Label to be used as prefix to all internal section names 4410Sstevel@tonic-gate # If not defined will attempt to derive it from the filename 4420Sstevel@tonic-gate # This can not happen when running parse_from_filehandle though 4430Sstevel@tonic-gate # hence the ability to set the label externally 4440Sstevel@tonic-gate # The label could then be Pod::Parser_DESCRIPTION or somesuch 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate $self->{Label} = undef # label to be used as prefix 4470Sstevel@tonic-gate unless exists $self->{Label}; # to all internal section names 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate # These allow the caller to add arbritrary latex code to 4500Sstevel@tonic-gate # start and end of document. AddPreamble and AddPostamble are ignored 4510Sstevel@tonic-gate # if these are set. 4520Sstevel@tonic-gate # Also MakeIndex and TableOfContents are also ignored. 4530Sstevel@tonic-gate $self->{UserPreamble} = undef # User supplied start (AddPreamble =1) 4540Sstevel@tonic-gate unless exists $self->{Label}; 4550Sstevel@tonic-gate $self->{UserPostamble} = undef # Use supplied end (AddPostamble=1) 4560Sstevel@tonic-gate unless exists $self->{Label}; 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate # Run base initialize 4590Sstevel@tonic-gate $self->SUPER::initialize; 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate} 4620Sstevel@tonic-gate 4630Sstevel@tonic-gate=back 4640Sstevel@tonic-gate 4650Sstevel@tonic-gate=head2 Data Accessors 4660Sstevel@tonic-gate 4670Sstevel@tonic-gateThe following methods are provided for accessing instance data. These 4680Sstevel@tonic-gatemethods should be used for accessing configuration parameters rather 4690Sstevel@tonic-gatethan assuming the object is a hash. 4700Sstevel@tonic-gate 4710Sstevel@tonic-gateDefault values can be supplied by using these names as keys to a hash 4720Sstevel@tonic-gateof arguments when using the C<new()> constructor. 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate=over 4 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate=item B<AddPreamble> 4770Sstevel@tonic-gate 4780Sstevel@tonic-gateLogical to control whether a C<latex> preamble is to be written. 4790Sstevel@tonic-gateIf true, a valid C<latex> preamble is written before the pod data is written. 4800Sstevel@tonic-gateThis is similar to: 4810Sstevel@tonic-gate 4820Sstevel@tonic-gate \documentclass{article} 4830Sstevel@tonic-gate \usepackage[T1]{fontenc} 4840Sstevel@tonic-gate \usepackage{textcomp} 4850Sstevel@tonic-gate \begin{document} 4860Sstevel@tonic-gate 4870Sstevel@tonic-gatebut will be more complicated if table of contents and indexing are required. 4880Sstevel@tonic-gateCan be used to set or retrieve the current value. 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate $add = $parser->AddPreamble(); 4910Sstevel@tonic-gate $parser->AddPreamble(1); 4920Sstevel@tonic-gate 4930Sstevel@tonic-gateIf used in conjunction with C<AddPostamble> a full latex document will 4940Sstevel@tonic-gatebe written that could be immediately processed by C<latex>. 4950Sstevel@tonic-gate 4960Sstevel@tonic-gateFor some pod escapes it may be necessary to include the amsmath 4970Sstevel@tonic-gatepackage. This is not yet added to the preamble automaatically. 4980Sstevel@tonic-gate 4990Sstevel@tonic-gate=cut 5000Sstevel@tonic-gate 5010Sstevel@tonic-gatesub AddPreamble { 5020Sstevel@tonic-gate my $self = shift; 5030Sstevel@tonic-gate if (@_) { 5040Sstevel@tonic-gate $self->{AddPreamble} = shift; 5050Sstevel@tonic-gate } 5060Sstevel@tonic-gate return $self->{AddPreamble}; 5070Sstevel@tonic-gate} 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate=item B<AddPostamble> 5100Sstevel@tonic-gate 5110Sstevel@tonic-gateLogical to control whether a standard C<latex> ending is written to the output 5120Sstevel@tonic-gatefile after the document has been processed. 5130Sstevel@tonic-gateIn its simplest form this is simply: 5140Sstevel@tonic-gate 5150Sstevel@tonic-gate \end{document} 5160Sstevel@tonic-gate 5170Sstevel@tonic-gatebut can be more complicated if a index is required. 5180Sstevel@tonic-gateCan be used to set or retrieve the current value. 5190Sstevel@tonic-gate 5200Sstevel@tonic-gate $add = $parser->AddPostamble(); 5210Sstevel@tonic-gate $parser->AddPostamble(1); 5220Sstevel@tonic-gate 5230Sstevel@tonic-gateIf used in conjunction with C<AddPreaamble> a full latex document will 5240Sstevel@tonic-gatebe written that could be immediately processed by C<latex>. 5250Sstevel@tonic-gate 5260Sstevel@tonic-gate=cut 5270Sstevel@tonic-gate 5280Sstevel@tonic-gatesub AddPostamble { 5290Sstevel@tonic-gate my $self = shift; 5300Sstevel@tonic-gate if (@_) { 5310Sstevel@tonic-gate $self->{AddPostamble} = shift; 5320Sstevel@tonic-gate } 5330Sstevel@tonic-gate return $self->{AddPostamble}; 5340Sstevel@tonic-gate} 5350Sstevel@tonic-gate 5360Sstevel@tonic-gate=item B<Head1Level> 5370Sstevel@tonic-gate 5380Sstevel@tonic-gateThe C<latex> sectioning level that should be used to correspond to 5390Sstevel@tonic-gatea pod C<=head1> directive. This can be used, for example, to turn 5400Sstevel@tonic-gatea C<=head1> into a C<latex> C<subsection>. This should hold a number 5410Sstevel@tonic-gatecorresponding to the required position in an array containing the 5420Sstevel@tonic-gatefollowing elements: 5430Sstevel@tonic-gate 5440Sstevel@tonic-gate [0] chapter 5450Sstevel@tonic-gate [1] section 5460Sstevel@tonic-gate [2] subsection 5470Sstevel@tonic-gate [3] subsubsection 5480Sstevel@tonic-gate [4] paragraph 5490Sstevel@tonic-gate [5] subparagraph 5500Sstevel@tonic-gate 5510Sstevel@tonic-gateCan be used to set or retrieve the current value: 5520Sstevel@tonic-gate 5530Sstevel@tonic-gate $parser->Head1Level(2); 5540Sstevel@tonic-gate $sect = $parser->Head1Level; 5550Sstevel@tonic-gate 5560Sstevel@tonic-gateSetting this number too high can result in sections that may not be reproducible 5570Sstevel@tonic-gatein the expected way. For example, setting this to 4 would imply that C<=head3> 5580Sstevel@tonic-gatedo not have a corresponding C<latex> section (C<=head1> would correspond to 5590Sstevel@tonic-gatea C<paragraph>). 5600Sstevel@tonic-gate 5610Sstevel@tonic-gateA check is made to ensure that the supplied value is an integer in the 5620Sstevel@tonic-gaterange 0 to 5. 5630Sstevel@tonic-gate 5640Sstevel@tonic-gateDefault is for a value of 1 (i.e. a C<section>). 5650Sstevel@tonic-gate 5660Sstevel@tonic-gate=cut 5670Sstevel@tonic-gate 5680Sstevel@tonic-gatesub Head1Level { 5690Sstevel@tonic-gate my $self = shift; 5700Sstevel@tonic-gate if (@_) { 5710Sstevel@tonic-gate my $arg = shift; 5720Sstevel@tonic-gate if ($arg =~ /^\d$/ && $arg <= $#LatexSections) { 5730Sstevel@tonic-gate $self->{Head1Level} = $arg; 5740Sstevel@tonic-gate } else { 5750Sstevel@tonic-gate carp "Head1Level supplied ($arg) must be integer in range 0 to ".$#LatexSections . "- Ignoring\n"; 5760Sstevel@tonic-gate } 5770Sstevel@tonic-gate } 5780Sstevel@tonic-gate return $self->{Head1Level}; 5790Sstevel@tonic-gate} 5800Sstevel@tonic-gate 5810Sstevel@tonic-gate=item B<Label> 5820Sstevel@tonic-gate 5830Sstevel@tonic-gateThis is the label that is prefixed to all C<latex> label and index 5840Sstevel@tonic-gateentries to make them unique. In general, pods have similarly titled 5850Sstevel@tonic-gatesections (NAME, DESCRIPTION etc) and a C<latex> label will be multiply 5860Sstevel@tonic-gatedefined if more than one pod document is to be included in a single 5870Sstevel@tonic-gateC<latex> file. To overcome this, this label is prefixed to a label 5880Sstevel@tonic-gatewhenever a label is required (joined with an underscore) or to an 5890Sstevel@tonic-gateindex entry (joined by an exclamation mark which is the normal index 5900Sstevel@tonic-gateseparator). For example, C<\label{text}> becomes C<\label{Label_text}>. 5910Sstevel@tonic-gate 5920Sstevel@tonic-gateCan be used to set or retrieve the current value: 5930Sstevel@tonic-gate 5940Sstevel@tonic-gate $label = $parser->Label; 5950Sstevel@tonic-gate $parser->Label($label); 5960Sstevel@tonic-gate 5970Sstevel@tonic-gateThis label is only used if C<UniqueLabels> is true. 5980Sstevel@tonic-gateIts value is set automatically from the C<NAME> field 5990Sstevel@tonic-gateif C<ReplaceNAMEwithSection> is true. If this is not the case 6000Sstevel@tonic-gateit must be set manually before starting the parse. 6010Sstevel@tonic-gate 6020Sstevel@tonic-gateDefault value is C<undef>. 6030Sstevel@tonic-gate 6040Sstevel@tonic-gate=cut 6050Sstevel@tonic-gate 6060Sstevel@tonic-gatesub Label { 6070Sstevel@tonic-gate my $self = shift; 6080Sstevel@tonic-gate if (@_) { 6090Sstevel@tonic-gate $self->{Label} = shift; 6100Sstevel@tonic-gate } 6110Sstevel@tonic-gate return $self->{Label}; 6120Sstevel@tonic-gate} 6130Sstevel@tonic-gate 6140Sstevel@tonic-gate=item B<LevelNoNum> 6150Sstevel@tonic-gate 6160Sstevel@tonic-gateControl the point at which C<latex> section numbering is turned off. 6170Sstevel@tonic-gateFor example, this can be used to make sure that C<latex> sections 6180Sstevel@tonic-gateare numbered but subsections are not. 6190Sstevel@tonic-gate 6200Sstevel@tonic-gateCan be used to set or retrieve the current value: 6210Sstevel@tonic-gate 6220Sstevel@tonic-gate $lev = $parser->LevelNoNum; 6230Sstevel@tonic-gate $parser->LevelNoNum(2); 6240Sstevel@tonic-gate 6250Sstevel@tonic-gateThe argument must be an integer between 0 and 5 and is the same as the 6260Sstevel@tonic-gatenumber described in C<Head1Level> method description. The number has 6270Sstevel@tonic-gatenothing to do with the pod heading number, only the C<latex> sectioning. 6280Sstevel@tonic-gate 6290Sstevel@tonic-gateDefault is 2. (i.e. C<latex> subsections are written as C<subsection*> 6300Sstevel@tonic-gatebut sections are numbered). 6310Sstevel@tonic-gate 6320Sstevel@tonic-gate=cut 6330Sstevel@tonic-gate 6340Sstevel@tonic-gatesub LevelNoNum { 6350Sstevel@tonic-gate my $self = shift; 6360Sstevel@tonic-gate if (@_) { 6370Sstevel@tonic-gate $self->{LevelNoNum} = shift; 6380Sstevel@tonic-gate } 6390Sstevel@tonic-gate return $self->{LevelNoNum}; 6400Sstevel@tonic-gate} 6410Sstevel@tonic-gate 6420Sstevel@tonic-gate=item B<MakeIndex> 6430Sstevel@tonic-gate 6440Sstevel@tonic-gateControls whether C<latex> commands for creating an index are to be inserted 6450Sstevel@tonic-gateinto the preamble and postamble 6460Sstevel@tonic-gate 6470Sstevel@tonic-gate $makeindex = $parser->MakeIndex; 6480Sstevel@tonic-gate $parser->MakeIndex(0); 6490Sstevel@tonic-gate 6500Sstevel@tonic-gateIrrelevant if both C<AddPreamble> and C<AddPostamble> are false (or equivalently, 6510Sstevel@tonic-gateC<UserPreamble> and C<UserPostamble> are set). 6520Sstevel@tonic-gate 6530Sstevel@tonic-gateDefault is for an index to be created. 6540Sstevel@tonic-gate 6550Sstevel@tonic-gate=cut 6560Sstevel@tonic-gate 6570Sstevel@tonic-gatesub MakeIndex { 6580Sstevel@tonic-gate my $self = shift; 6590Sstevel@tonic-gate if (@_) { 6600Sstevel@tonic-gate $self->{MakeIndex} = shift; 6610Sstevel@tonic-gate } 6620Sstevel@tonic-gate return $self->{MakeIndex}; 6630Sstevel@tonic-gate} 6640Sstevel@tonic-gate 6650Sstevel@tonic-gate=item B<ReplaceNAMEwithSection> 6660Sstevel@tonic-gate 6670Sstevel@tonic-gateThis controls whether the C<NAME> section in the pod is to be translated 6680Sstevel@tonic-gateliterally or converted to a slightly modified output where the section 6690Sstevel@tonic-gatename is the pod name rather than "NAME". 6700Sstevel@tonic-gate 6710Sstevel@tonic-gateIf true, the pod segment 6720Sstevel@tonic-gate 6730Sstevel@tonic-gate =head1 NAME 6740Sstevel@tonic-gate 6750Sstevel@tonic-gate pod::name - purpose 6760Sstevel@tonic-gate 6770Sstevel@tonic-gate =head1 SYNOPSIS 6780Sstevel@tonic-gate 6790Sstevel@tonic-gateis converted to the C<latex> 6800Sstevel@tonic-gate 6810Sstevel@tonic-gate \section{pod::name\label{pod_name}\index{pod::name}} 6820Sstevel@tonic-gate 6830Sstevel@tonic-gate Purpose 6840Sstevel@tonic-gate 6850Sstevel@tonic-gate \subsection*{SYNOPSIS\label{pod_name_SYNOPSIS}% 6860Sstevel@tonic-gate \index{pod::name!SYNOPSIS}} 6870Sstevel@tonic-gate 6880Sstevel@tonic-gate(dependent on the value of C<Head1Level> and C<LevelNoNum>). Note that 6890Sstevel@tonic-gatesubsequent C<head1> directives translate to subsections rather than 6900Sstevel@tonic-gatesections and that the labels and index now include the pod name (dependent 6910Sstevel@tonic-gateon the value of C<UniqueLabels>). 6920Sstevel@tonic-gate 6930Sstevel@tonic-gateThe C<Label> is set from the pod name regardless of any current value 6940Sstevel@tonic-gateof C<Label>. 6950Sstevel@tonic-gate 6960Sstevel@tonic-gate $mod = $parser->ReplaceNAMEwithSection; 6970Sstevel@tonic-gate $parser->ReplaceNAMEwithSection(0); 6980Sstevel@tonic-gate 6990Sstevel@tonic-gateDefault is to translate the pod literally. 7000Sstevel@tonic-gate 7010Sstevel@tonic-gate=cut 7020Sstevel@tonic-gate 7030Sstevel@tonic-gatesub ReplaceNAMEwithSection { 7040Sstevel@tonic-gate my $self = shift; 7050Sstevel@tonic-gate if (@_) { 7060Sstevel@tonic-gate $self->{ReplaceNAMEwithSection} = shift; 7070Sstevel@tonic-gate } 7080Sstevel@tonic-gate return $self->{ReplaceNAMEwithSection}; 7090Sstevel@tonic-gate} 7100Sstevel@tonic-gate 7110Sstevel@tonic-gate=item B<StartWithNewPage> 7120Sstevel@tonic-gate 7130Sstevel@tonic-gateIf true, each pod translation will begin with a C<latex> 7140Sstevel@tonic-gateC<\clearpage>. 7150Sstevel@tonic-gate 7160Sstevel@tonic-gate $parser->StartWithNewPage(1); 7170Sstevel@tonic-gate $newpage = $parser->StartWithNewPage; 7180Sstevel@tonic-gate 7190Sstevel@tonic-gateDefault is false. 7200Sstevel@tonic-gate 7210Sstevel@tonic-gate=cut 7220Sstevel@tonic-gate 7230Sstevel@tonic-gatesub StartWithNewPage { 7240Sstevel@tonic-gate my $self = shift; 7250Sstevel@tonic-gate if (@_) { 7260Sstevel@tonic-gate $self->{StartWithNewPage} = shift; 7270Sstevel@tonic-gate } 7280Sstevel@tonic-gate return $self->{StartWithNewPage}; 7290Sstevel@tonic-gate} 7300Sstevel@tonic-gate 7310Sstevel@tonic-gate=item B<TableOfContents> 7320Sstevel@tonic-gate 7330Sstevel@tonic-gateIf true, a table of contents will be created. 7340Sstevel@tonic-gateIrrelevant if C<AddPreamble> is false or C<UserPreamble> 7350Sstevel@tonic-gateis set. 7360Sstevel@tonic-gate 7370Sstevel@tonic-gate $toc = $parser->TableOfContents; 7380Sstevel@tonic-gate $parser->TableOfContents(1); 7390Sstevel@tonic-gate 7400Sstevel@tonic-gateDefault is false. 7410Sstevel@tonic-gate 7420Sstevel@tonic-gate=cut 7430Sstevel@tonic-gate 7440Sstevel@tonic-gatesub TableOfContents { 7450Sstevel@tonic-gate my $self = shift; 7460Sstevel@tonic-gate if (@_) { 7470Sstevel@tonic-gate $self->{TableOfContents} = shift; 7480Sstevel@tonic-gate } 7490Sstevel@tonic-gate return $self->{TableOfContents}; 7500Sstevel@tonic-gate} 7510Sstevel@tonic-gate 7520Sstevel@tonic-gate=item B<UniqueLabels> 7530Sstevel@tonic-gate 7540Sstevel@tonic-gateIf true, the translator will attempt to make sure that 7550Sstevel@tonic-gateeach C<latex> label or index entry will be uniquely identified 7560Sstevel@tonic-gateby prefixing the contents of C<Label>. This allows 7570Sstevel@tonic-gatemultiple documents to be combined without clashing 7580Sstevel@tonic-gatecommon labels such as C<DESCRIPTION> and C<SYNOPSIS> 7590Sstevel@tonic-gate 7600Sstevel@tonic-gate $parser->UniqueLabels(1); 7610Sstevel@tonic-gate $unq = $parser->UniqueLabels; 7620Sstevel@tonic-gate 7630Sstevel@tonic-gateDefault is true. 7640Sstevel@tonic-gate 7650Sstevel@tonic-gate=cut 7660Sstevel@tonic-gate 7670Sstevel@tonic-gatesub UniqueLabels { 7680Sstevel@tonic-gate my $self = shift; 7690Sstevel@tonic-gate if (@_) { 7700Sstevel@tonic-gate $self->{UniqueLabels} = shift; 7710Sstevel@tonic-gate } 7720Sstevel@tonic-gate return $self->{UniqueLabels}; 7730Sstevel@tonic-gate} 7740Sstevel@tonic-gate 7750Sstevel@tonic-gate=item B<UserPreamble> 7760Sstevel@tonic-gate 7770Sstevel@tonic-gateUser supplied C<latex> preamble. Added before the pod translation 7780Sstevel@tonic-gatedata. 7790Sstevel@tonic-gate 7800Sstevel@tonic-gateIf set, the contents will be prepended to the output file before the translated 7810Sstevel@tonic-gatedata regardless of the value of C<AddPreamble>. 7820Sstevel@tonic-gateC<MakeIndex> and C<TableOfContents> will also be ignored. 7830Sstevel@tonic-gate 7840Sstevel@tonic-gate=cut 7850Sstevel@tonic-gate 7860Sstevel@tonic-gatesub UserPreamble { 7870Sstevel@tonic-gate my $self = shift; 7880Sstevel@tonic-gate if (@_) { 7890Sstevel@tonic-gate $self->{UserPreamble} = shift; 7900Sstevel@tonic-gate } 7910Sstevel@tonic-gate return $self->{UserPreamble}; 7920Sstevel@tonic-gate} 7930Sstevel@tonic-gate 7940Sstevel@tonic-gate=item B<UserPostamble> 7950Sstevel@tonic-gate 7960Sstevel@tonic-gateUser supplied C<latex> postamble. Added after the pod translation 7970Sstevel@tonic-gatedata. 7980Sstevel@tonic-gate 7990Sstevel@tonic-gateIf set, the contents will be prepended to the output file after the translated 8000Sstevel@tonic-gatedata regardless of the value of C<AddPostamble>. 8010Sstevel@tonic-gateC<MakeIndex> will also be ignored. 8020Sstevel@tonic-gate 8030Sstevel@tonic-gate=cut 8040Sstevel@tonic-gate 8050Sstevel@tonic-gatesub UserPostamble { 8060Sstevel@tonic-gate my $self = shift; 8070Sstevel@tonic-gate if (@_) { 8080Sstevel@tonic-gate $self->{UserPostamble} = shift; 8090Sstevel@tonic-gate } 8100Sstevel@tonic-gate return $self->{UserPostamble}; 8110Sstevel@tonic-gate} 8120Sstevel@tonic-gate 8130Sstevel@tonic-gate=begin __PRIVATE__ 8140Sstevel@tonic-gate 8150Sstevel@tonic-gate=item B<Lists> 8160Sstevel@tonic-gate 8170Sstevel@tonic-gateContains details of the currently active lists. 8180Sstevel@tonic-gate The array contains C<Pod::List> objects. A new C<Pod::List> 8190Sstevel@tonic-gateobject is created each time a list is encountered and it is 8200Sstevel@tonic-gatepushed onto this stack. When the list context ends, it 8210Sstevel@tonic-gateis popped from the stack. The array will be empty if no 8220Sstevel@tonic-gatelists are active. 8230Sstevel@tonic-gate 8240Sstevel@tonic-gateReturns array of list information in list context 8250Sstevel@tonic-gateReturns array ref in scalar context 8260Sstevel@tonic-gate 8270Sstevel@tonic-gate=cut 8280Sstevel@tonic-gate 8290Sstevel@tonic-gate 8300Sstevel@tonic-gate 8310Sstevel@tonic-gatesub lists { 8320Sstevel@tonic-gate my $self = shift; 8330Sstevel@tonic-gate return @{ $self->{_Lists} } if wantarray(); 8340Sstevel@tonic-gate return $self->{_Lists}; 8350Sstevel@tonic-gate} 8360Sstevel@tonic-gate 8370Sstevel@tonic-gate=end __PRIVATE__ 8380Sstevel@tonic-gate 8390Sstevel@tonic-gate=back 8400Sstevel@tonic-gate 8410Sstevel@tonic-gate=begin __PRIVATE__ 8420Sstevel@tonic-gate 8430Sstevel@tonic-gate=head2 Subclassed methods 8440Sstevel@tonic-gate 8450Sstevel@tonic-gateThe following methods override methods provided in the C<Pod::Select> 8460Sstevel@tonic-gatebase class. See C<Pod::Parser> and C<Pod::Select> for more information 8470Sstevel@tonic-gateon what these methods require. 8480Sstevel@tonic-gate 8490Sstevel@tonic-gate=over 4 8500Sstevel@tonic-gate 8510Sstevel@tonic-gate=cut 8520Sstevel@tonic-gate 8530Sstevel@tonic-gate######### END ACCESSORS ################### 8540Sstevel@tonic-gate 8550Sstevel@tonic-gate# Opening pod 8560Sstevel@tonic-gate 8570Sstevel@tonic-gate=item B<begin_pod> 8580Sstevel@tonic-gate 8590Sstevel@tonic-gateWrites the C<latex> preamble if requested. 8600Sstevel@tonic-gate 8610Sstevel@tonic-gate=cut 8620Sstevel@tonic-gate 8630Sstevel@tonic-gatesub begin_pod { 8640Sstevel@tonic-gate my $self = shift; 8650Sstevel@tonic-gate 8660Sstevel@tonic-gate # Get the pod identification 8670Sstevel@tonic-gate # This should really come from the '=head1 NAME' paragraph 8680Sstevel@tonic-gate 8690Sstevel@tonic-gate my $infile = $self->input_file; 8700Sstevel@tonic-gate my $class = ref($self); 8710Sstevel@tonic-gate my $date = gmtime(time); 8720Sstevel@tonic-gate 8730Sstevel@tonic-gate # Comment message to say where this came from 8740Sstevel@tonic-gate my $comment = << "__TEX_COMMENT__"; 8750Sstevel@tonic-gate%% Latex generated from POD in document $infile 8760Sstevel@tonic-gate%% Using the perl module $class 8770Sstevel@tonic-gate%% Converted on $date 8780Sstevel@tonic-gate__TEX_COMMENT__ 8790Sstevel@tonic-gate 8800Sstevel@tonic-gate # Write the preamble 8810Sstevel@tonic-gate # If the caller has supplied one then we just use that 8820Sstevel@tonic-gate 8830Sstevel@tonic-gate my $preamble = ''; 8840Sstevel@tonic-gate if (defined $self->UserPreamble) { 8850Sstevel@tonic-gate 8860Sstevel@tonic-gate $preamble = $self->UserPreamble; 8870Sstevel@tonic-gate 8880Sstevel@tonic-gate # Add the description of where this came from 8890Sstevel@tonic-gate $preamble .= "\n$comment"; 8900Sstevel@tonic-gate 8910Sstevel@tonic-gate 8920Sstevel@tonic-gate } elsif ($self->AddPreamble) { 8930Sstevel@tonic-gate # Write our own preamble 8940Sstevel@tonic-gate 8950Sstevel@tonic-gate # Code to initialise index making 8960Sstevel@tonic-gate # Use an array so that we can prepend comment if required 8970Sstevel@tonic-gate my @makeidx = ( 8980Sstevel@tonic-gate '\usepackage{makeidx}', 8990Sstevel@tonic-gate '\makeindex', 9000Sstevel@tonic-gate ); 9010Sstevel@tonic-gate 9020Sstevel@tonic-gate unless ($self->MakeIndex) { 9030Sstevel@tonic-gate foreach (@makeidx) { 9040Sstevel@tonic-gate $_ = '%% ' . $_; 9050Sstevel@tonic-gate } 9060Sstevel@tonic-gate } 9070Sstevel@tonic-gate my $makeindex = join("\n",@makeidx) . "\n"; 9080Sstevel@tonic-gate 9090Sstevel@tonic-gate 9100Sstevel@tonic-gate # Table of contents 9110Sstevel@tonic-gate my $tableofcontents = '\tableofcontents'; 9120Sstevel@tonic-gate 9130Sstevel@tonic-gate $tableofcontents = '%% ' . $tableofcontents 9140Sstevel@tonic-gate unless $self->TableOfContents; 9150Sstevel@tonic-gate 9160Sstevel@tonic-gate # Roll our own 9170Sstevel@tonic-gate $preamble = << "__TEX_HEADER__"; 9180Sstevel@tonic-gate\\documentclass{article} 9190Sstevel@tonic-gate\\usepackage[T1]{fontenc} 9200Sstevel@tonic-gate\\usepackage{textcomp} 9210Sstevel@tonic-gate 9220Sstevel@tonic-gate$comment 9230Sstevel@tonic-gate 9240Sstevel@tonic-gate$makeindex 9250Sstevel@tonic-gate 9260Sstevel@tonic-gate\\begin{document} 9270Sstevel@tonic-gate 9280Sstevel@tonic-gate$tableofcontents 9290Sstevel@tonic-gate 9300Sstevel@tonic-gate__TEX_HEADER__ 9310Sstevel@tonic-gate 9320Sstevel@tonic-gate } 9330Sstevel@tonic-gate 9340Sstevel@tonic-gate # Write the header (blank if none) 9350Sstevel@tonic-gate $self->_output($preamble); 9360Sstevel@tonic-gate 9370Sstevel@tonic-gate # Start on new page if requested 9380Sstevel@tonic-gate $self->_output("\\clearpage\n") if $self->StartWithNewPage; 9390Sstevel@tonic-gate 9400Sstevel@tonic-gate} 9410Sstevel@tonic-gate 9420Sstevel@tonic-gate 9430Sstevel@tonic-gate=item B<end_pod> 9440Sstevel@tonic-gate 9450Sstevel@tonic-gateWrite the closing C<latex> code. 9460Sstevel@tonic-gate 9470Sstevel@tonic-gate=cut 9480Sstevel@tonic-gate 9490Sstevel@tonic-gatesub end_pod { 9500Sstevel@tonic-gate my $self = shift; 9510Sstevel@tonic-gate 9520Sstevel@tonic-gate # End string 9530Sstevel@tonic-gate my $end = ''; 9540Sstevel@tonic-gate 9550Sstevel@tonic-gate # Use the user version of the postamble if deinfed 9560Sstevel@tonic-gate if (defined $self->UserPostamble) { 9570Sstevel@tonic-gate $end = $self->UserPostamble; 9580Sstevel@tonic-gate 9590Sstevel@tonic-gate $self->_output($end); 9600Sstevel@tonic-gate 9610Sstevel@tonic-gate } elsif ($self->AddPostamble) { 9620Sstevel@tonic-gate 9630Sstevel@tonic-gate # Check for index 9640Sstevel@tonic-gate my $makeindex = '\printindex'; 9650Sstevel@tonic-gate 9660Sstevel@tonic-gate $makeindex = '%% '. $makeindex unless $self->MakeIndex; 9670Sstevel@tonic-gate 9680Sstevel@tonic-gate $end = "$makeindex\n\n\\end{document}\n"; 9690Sstevel@tonic-gate } 9700Sstevel@tonic-gate 9710Sstevel@tonic-gate 9720Sstevel@tonic-gate $self->_output($end); 9730Sstevel@tonic-gate 9740Sstevel@tonic-gate} 9750Sstevel@tonic-gate 9760Sstevel@tonic-gate=item B<command> 9770Sstevel@tonic-gate 9780Sstevel@tonic-gateProcess basic pod commands. 9790Sstevel@tonic-gate 9800Sstevel@tonic-gate=cut 9810Sstevel@tonic-gate 9820Sstevel@tonic-gatesub command { 9830Sstevel@tonic-gate my $self = shift; 9840Sstevel@tonic-gate my ($command, $paragraph, $line_num, $parobj) = @_; 9850Sstevel@tonic-gate 9860Sstevel@tonic-gate # return if we dont care 9870Sstevel@tonic-gate return if $command eq 'pod'; 9880Sstevel@tonic-gate 9890Sstevel@tonic-gate # Store a copy of the raw text in case we are in a =for 9900Sstevel@tonic-gate # block and need to preserve the existing latex 9910Sstevel@tonic-gate my $rawpara = $paragraph; 9920Sstevel@tonic-gate 9930Sstevel@tonic-gate # Do the latex escapes 9940Sstevel@tonic-gate $paragraph = $self->_replace_special_chars($paragraph); 9950Sstevel@tonic-gate 9960Sstevel@tonic-gate # Interpolate pod sequences in paragraph 9970Sstevel@tonic-gate $paragraph = $self->interpolate($paragraph, $line_num); 9980Sstevel@tonic-gate $paragraph =~ s/\s+$//; 9990Sstevel@tonic-gate 10000Sstevel@tonic-gate # Replace characters that can only be done after 10010Sstevel@tonic-gate # interpolation of interior sequences 10020Sstevel@tonic-gate $paragraph = $self->_replace_special_chars_late($paragraph); 10030Sstevel@tonic-gate 10040Sstevel@tonic-gate # Now run the command 10050Sstevel@tonic-gate if ($command eq 'over') { 10060Sstevel@tonic-gate 10070Sstevel@tonic-gate $self->begin_list($paragraph, $line_num); 10080Sstevel@tonic-gate 10090Sstevel@tonic-gate } elsif ($command eq 'item') { 10100Sstevel@tonic-gate 10110Sstevel@tonic-gate $self->add_item($paragraph, $line_num); 10120Sstevel@tonic-gate 10130Sstevel@tonic-gate } elsif ($command eq 'back') { 10140Sstevel@tonic-gate 10150Sstevel@tonic-gate $self->end_list($line_num); 10160Sstevel@tonic-gate 10170Sstevel@tonic-gate } elsif ($command eq 'head1') { 10180Sstevel@tonic-gate 10190Sstevel@tonic-gate # Store the name of the section 10200Sstevel@tonic-gate $self->{_CURRENT_HEAD1} = $paragraph; 10210Sstevel@tonic-gate 10220Sstevel@tonic-gate # Print it 10230Sstevel@tonic-gate $self->head(1, $paragraph, $parobj); 10240Sstevel@tonic-gate 10250Sstevel@tonic-gate } elsif ($command eq 'head2') { 10260Sstevel@tonic-gate 10270Sstevel@tonic-gate $self->head(2, $paragraph, $parobj); 10280Sstevel@tonic-gate 10290Sstevel@tonic-gate } elsif ($command eq 'head3') { 10300Sstevel@tonic-gate 10310Sstevel@tonic-gate $self->head(3, $paragraph, $parobj); 10320Sstevel@tonic-gate 10330Sstevel@tonic-gate } elsif ($command eq 'head4') { 10340Sstevel@tonic-gate 10350Sstevel@tonic-gate $self->head(4, $paragraph, $parobj); 10360Sstevel@tonic-gate 10370Sstevel@tonic-gate } elsif ($command eq 'head5') { 10380Sstevel@tonic-gate 10390Sstevel@tonic-gate $self->head(5, $paragraph, $parobj); 10400Sstevel@tonic-gate 10410Sstevel@tonic-gate } elsif ($command eq 'head6') { 10420Sstevel@tonic-gate 10430Sstevel@tonic-gate $self->head(6, $paragraph, $parobj); 10440Sstevel@tonic-gate 10450Sstevel@tonic-gate } elsif ($command eq 'begin') { 10460Sstevel@tonic-gate 10470Sstevel@tonic-gate # pass through if latex 10480Sstevel@tonic-gate if ($paragraph =~ /^latex/i) { 10490Sstevel@tonic-gate # Make sure that subsequent paragraphs are not modfied before printing 10500Sstevel@tonic-gate $self->{_dont_modify_any_para} = 1; 10510Sstevel@tonic-gate 10520Sstevel@tonic-gate } else { 10530Sstevel@tonic-gate # Suppress all subsequent paragraphs unless 10540Sstevel@tonic-gate # it is explcitly intended for latex 10550Sstevel@tonic-gate $self->{_suppress_all_para} = 1; 10560Sstevel@tonic-gate } 10570Sstevel@tonic-gate 10580Sstevel@tonic-gate } elsif ($command eq 'for') { 10590Sstevel@tonic-gate 10600Sstevel@tonic-gate # =for latex 10610Sstevel@tonic-gate # some latex 10620Sstevel@tonic-gate 10630Sstevel@tonic-gate # With =for we will get the text for the full paragraph 10640Sstevel@tonic-gate # as well as the format name. 10650Sstevel@tonic-gate # We do not get an additional paragraph later on. The next 10660Sstevel@tonic-gate # paragraph is not governed by the =for 10670Sstevel@tonic-gate 10680Sstevel@tonic-gate # The first line contains the format and the rest is the 10690Sstevel@tonic-gate # raw code. 10700Sstevel@tonic-gate my ($format, $chunk) = split(/\n/, $rawpara, 2); 10710Sstevel@tonic-gate 10720Sstevel@tonic-gate # If we have got some latex code print it out immediately 10730Sstevel@tonic-gate # unmodified. Else do nothing. 10740Sstevel@tonic-gate if ($format =~ /^latex/i) { 10750Sstevel@tonic-gate # Make sure that next paragraph is not modfied before printing 10760Sstevel@tonic-gate $self->_output( $chunk ); 10770Sstevel@tonic-gate 10780Sstevel@tonic-gate } 10790Sstevel@tonic-gate 10800Sstevel@tonic-gate } elsif ($command eq 'end') { 10810Sstevel@tonic-gate 10820Sstevel@tonic-gate # Reset suppression 10830Sstevel@tonic-gate $self->{_suppress_all_para} = 0; 10840Sstevel@tonic-gate $self->{_dont_modify_any_para} = 0; 10850Sstevel@tonic-gate 10860Sstevel@tonic-gate } elsif ($command eq 'pod') { 10870Sstevel@tonic-gate 10880Sstevel@tonic-gate # Do nothing 10890Sstevel@tonic-gate 10900Sstevel@tonic-gate } else { 10910Sstevel@tonic-gate carp "Command $command not recognised at line $line_num\n"; 10920Sstevel@tonic-gate } 10930Sstevel@tonic-gate 10940Sstevel@tonic-gate} 10950Sstevel@tonic-gate 10960Sstevel@tonic-gate=item B<verbatim> 10970Sstevel@tonic-gate 10980Sstevel@tonic-gateVerbatim text 10990Sstevel@tonic-gate 11000Sstevel@tonic-gate=cut 11010Sstevel@tonic-gate 11020Sstevel@tonic-gatesub verbatim { 11030Sstevel@tonic-gate my $self = shift; 11040Sstevel@tonic-gate my ($paragraph, $line_num, $parobj) = @_; 11050Sstevel@tonic-gate 11060Sstevel@tonic-gate # Expand paragraph unless in =begin block 11070Sstevel@tonic-gate if ($self->{_dont_modify_any_para}) { 11080Sstevel@tonic-gate # Just print as is 11090Sstevel@tonic-gate $self->_output($paragraph); 11100Sstevel@tonic-gate 11110Sstevel@tonic-gate } else { 11120Sstevel@tonic-gate 11130Sstevel@tonic-gate return if $paragraph =~ /^\s+$/; 11140Sstevel@tonic-gate 11150Sstevel@tonic-gate # Clean trailing space 11160Sstevel@tonic-gate $paragraph =~ s/\s+$//; 11170Sstevel@tonic-gate 11180Sstevel@tonic-gate # Clean tabs. Routine taken from Tabs.pm 11190Sstevel@tonic-gate # by David Muir Sharnoff muir@idiom.com, 11200Sstevel@tonic-gate # slightly modified by hsmyers@sdragons.com 10/22/01 11210Sstevel@tonic-gate my @l = split("\n",$paragraph); 11220Sstevel@tonic-gate foreach (@l) { 11230Sstevel@tonic-gate 1 while s/(^|\n)([^\t\n]*)(\t+)/ 11240Sstevel@tonic-gate $1. $2 . (" " x 11250Sstevel@tonic-gate (8 * length($3) 11260Sstevel@tonic-gate - (length($2) % 8))) 11270Sstevel@tonic-gate /sex; 11280Sstevel@tonic-gate } 11290Sstevel@tonic-gate $paragraph = join("\n",@l); 11300Sstevel@tonic-gate # End of change. 11310Sstevel@tonic-gate 11320Sstevel@tonic-gate 11330Sstevel@tonic-gate 11340Sstevel@tonic-gate $self->_output('\begin{verbatim}' . "\n$paragraph\n". '\end{verbatim}'."\n"); 11350Sstevel@tonic-gate } 11360Sstevel@tonic-gate} 11370Sstevel@tonic-gate 11380Sstevel@tonic-gate=item B<textblock> 11390Sstevel@tonic-gate 11400Sstevel@tonic-gatePlain text paragraph. 11410Sstevel@tonic-gate 11420Sstevel@tonic-gate=cut 11430Sstevel@tonic-gate 11440Sstevel@tonic-gatesub textblock { 11450Sstevel@tonic-gate my $self = shift; 11460Sstevel@tonic-gate my ($paragraph, $line_num, $parobj) = @_; 11470Sstevel@tonic-gate 11480Sstevel@tonic-gate # print Dumper($self); 11490Sstevel@tonic-gate 11500Sstevel@tonic-gate # Expand paragraph unless in =begin block 11510Sstevel@tonic-gate if ($self->{_dont_modify_any_para}) { 11520Sstevel@tonic-gate # Just print as is 11530Sstevel@tonic-gate $self->_output($paragraph); 11540Sstevel@tonic-gate 11550Sstevel@tonic-gate return; 11560Sstevel@tonic-gate } 11570Sstevel@tonic-gate 11580Sstevel@tonic-gate 11590Sstevel@tonic-gate # Escape latex special characters 11600Sstevel@tonic-gate $paragraph = $self->_replace_special_chars($paragraph); 11610Sstevel@tonic-gate 11620Sstevel@tonic-gate # Interpolate interior sequences 11630Sstevel@tonic-gate my $expansion = $self->interpolate($paragraph, $line_num); 11640Sstevel@tonic-gate $expansion =~ s/\s+$//; 11650Sstevel@tonic-gate 11660Sstevel@tonic-gate # Escape special characters that can not be done earlier 11670Sstevel@tonic-gate $expansion = $self->_replace_special_chars_late($expansion); 11680Sstevel@tonic-gate 11690Sstevel@tonic-gate # If we are replacing 'head1 NAME' with a section 11700Sstevel@tonic-gate # we need to look in the paragraph and rewrite things 11710Sstevel@tonic-gate # Need to make sure this is called only on the first paragraph 11720Sstevel@tonic-gate # following 'head1 NAME' and not on subsequent paragraphs that may be 11730Sstevel@tonic-gate # present. 11740Sstevel@tonic-gate if ($self->{_CURRENT_HEAD1} =~ /^NAME/i && $self->ReplaceNAMEwithSection()) { 11750Sstevel@tonic-gate 11760Sstevel@tonic-gate # Strip white space from start and end 11770Sstevel@tonic-gate $paragraph =~ s/^\s+//; 11780Sstevel@tonic-gate $paragraph =~ s/\s$//; 11790Sstevel@tonic-gate 11800Sstevel@tonic-gate # Split the string into 2 parts 11810Sstevel@tonic-gate my ($name, $purpose) = split(/\s+-\s+/, $expansion,2); 11820Sstevel@tonic-gate 11830Sstevel@tonic-gate # Now prevent this from triggering until a new head1 NAME is set 11840Sstevel@tonic-gate $self->{_CURRENT_HEAD1} = '_NAME'; 11850Sstevel@tonic-gate 11860Sstevel@tonic-gate # Might want to clear the Label() before doing this (CHECK) 11870Sstevel@tonic-gate 11880Sstevel@tonic-gate # Print the heading 11890Sstevel@tonic-gate $self->head(1, $name, $parobj); 11900Sstevel@tonic-gate 11910Sstevel@tonic-gate # Set the labeling in case we want unique names later 11920Sstevel@tonic-gate $self->Label( $self->_create_label( $name, 1 ) ); 11930Sstevel@tonic-gate 11940Sstevel@tonic-gate # Raise the Head1Level by one so that subsequent =head1 appear 11950Sstevel@tonic-gate # as subsections of the main name section unless we are already 11960Sstevel@tonic-gate # at maximum [Head1Level() could check this itself - CHECK] 11970Sstevel@tonic-gate $self->Head1Level( $self->Head1Level() + 1) 11980Sstevel@tonic-gate unless $self->Head1Level == $#LatexSections; 11990Sstevel@tonic-gate 12000Sstevel@tonic-gate # Now write out the new latex paragraph 12010Sstevel@tonic-gate $purpose = ucfirst($purpose); 12020Sstevel@tonic-gate $self->_output("\n\n$purpose\n\n"); 12030Sstevel@tonic-gate 12040Sstevel@tonic-gate } else { 12050Sstevel@tonic-gate # Just write the output 12060Sstevel@tonic-gate $self->_output("\n\n$expansion\n\n"); 12070Sstevel@tonic-gate } 12080Sstevel@tonic-gate 12090Sstevel@tonic-gate} 12100Sstevel@tonic-gate 12110Sstevel@tonic-gate=item B<interior_sequence> 12120Sstevel@tonic-gate 12130Sstevel@tonic-gateInterior sequence expansion 12140Sstevel@tonic-gate 12150Sstevel@tonic-gate=cut 12160Sstevel@tonic-gate 12170Sstevel@tonic-gatesub interior_sequence { 12180Sstevel@tonic-gate my $self = shift; 12190Sstevel@tonic-gate 12200Sstevel@tonic-gate my ($seq_command, $seq_argument, $pod_seq) = @_; 12210Sstevel@tonic-gate 12220Sstevel@tonic-gate if ($seq_command eq 'B') { 12230Sstevel@tonic-gate return "\\textbf{$seq_argument}"; 12240Sstevel@tonic-gate 12250Sstevel@tonic-gate } elsif ($seq_command eq 'I') { 12260Sstevel@tonic-gate return "\\textit{$seq_argument}"; 12270Sstevel@tonic-gate 12280Sstevel@tonic-gate } elsif ($seq_command eq 'E') { 12290Sstevel@tonic-gate 12300Sstevel@tonic-gate # If it is simply a number 12310Sstevel@tonic-gate if ($seq_argument =~ /^\d+$/) { 12320Sstevel@tonic-gate return chr($seq_argument); 12330Sstevel@tonic-gate # Look up escape in hash table 12340Sstevel@tonic-gate } elsif (exists $HTML_Escapes{$seq_argument}) { 12350Sstevel@tonic-gate return $HTML_Escapes{$seq_argument}; 12360Sstevel@tonic-gate 12370Sstevel@tonic-gate } else { 12380Sstevel@tonic-gate my ($file, $line) = $pod_seq->file_line(); 12390Sstevel@tonic-gate warn "Escape sequence $seq_argument not recognised at line $line of file $file\n"; 12400Sstevel@tonic-gate return; 12410Sstevel@tonic-gate } 12420Sstevel@tonic-gate 12430Sstevel@tonic-gate } elsif ($seq_command eq 'Z') { 12440Sstevel@tonic-gate 12450Sstevel@tonic-gate # Zero width space 12460Sstevel@tonic-gate return '{}'; 12470Sstevel@tonic-gate 12480Sstevel@tonic-gate } elsif ($seq_command eq 'C') { 12490Sstevel@tonic-gate return "\\texttt{$seq_argument}"; 12500Sstevel@tonic-gate 12510Sstevel@tonic-gate } elsif ($seq_command eq 'F') { 12520Sstevel@tonic-gate return "\\emph{$seq_argument}"; 12530Sstevel@tonic-gate 12540Sstevel@tonic-gate } elsif ($seq_command eq 'S') { 12550Sstevel@tonic-gate # non breakable spaces 12560Sstevel@tonic-gate my $nbsp = '~'; 12570Sstevel@tonic-gate 12580Sstevel@tonic-gate $seq_argument =~ s/\s/$nbsp/g; 12590Sstevel@tonic-gate return $seq_argument; 12600Sstevel@tonic-gate 12610Sstevel@tonic-gate } elsif ($seq_command eq 'L') { 12620Sstevel@tonic-gate my $link = new Pod::Hyperlink($seq_argument); 12630Sstevel@tonic-gate 12640Sstevel@tonic-gate # undef on failure 12650Sstevel@tonic-gate unless (defined $link) { 12660Sstevel@tonic-gate carp $@; 12670Sstevel@tonic-gate return; 12680Sstevel@tonic-gate } 12690Sstevel@tonic-gate 12700Sstevel@tonic-gate # Handle internal links differently 12710Sstevel@tonic-gate my $type = $link->type; 12720Sstevel@tonic-gate my $page = $link->page; 12730Sstevel@tonic-gate 12740Sstevel@tonic-gate if ($type eq 'section' && $page eq '') { 12750Sstevel@tonic-gate # Use internal latex reference 12760Sstevel@tonic-gate my $node = $link->node; 12770Sstevel@tonic-gate 12780Sstevel@tonic-gate # Convert to a label 12790Sstevel@tonic-gate $node = $self->_create_label($node); 12800Sstevel@tonic-gate 12810Sstevel@tonic-gate return "\\S\\ref{$node}"; 12820Sstevel@tonic-gate 12830Sstevel@tonic-gate } else { 12840Sstevel@tonic-gate # Use default markup for external references 12850Sstevel@tonic-gate # (although Starlink would use \xlabel) 12860Sstevel@tonic-gate my $markup = $link->markup; 12870Sstevel@tonic-gate my ($file, $line) = $pod_seq->file_line(); 12880Sstevel@tonic-gate 12890Sstevel@tonic-gate return $self->interpolate($link->markup, $line); 12900Sstevel@tonic-gate } 12910Sstevel@tonic-gate 12920Sstevel@tonic-gate 12930Sstevel@tonic-gate 12940Sstevel@tonic-gate } elsif ($seq_command eq 'P') { 12950Sstevel@tonic-gate # Special markup for Pod::Hyperlink 12960Sstevel@tonic-gate # Replace :: with / - but not sure if I want to do this 12970Sstevel@tonic-gate # any more. 12980Sstevel@tonic-gate my $link = $seq_argument; 12990Sstevel@tonic-gate $link =~ s|::|/|g; 13000Sstevel@tonic-gate 13010Sstevel@tonic-gate my $ref = "\\emph{$seq_argument}"; 13020Sstevel@tonic-gate return $ref; 13030Sstevel@tonic-gate 13040Sstevel@tonic-gate } elsif ($seq_command eq 'Q') { 13050Sstevel@tonic-gate # Special markup for Pod::Hyperlink 13060Sstevel@tonic-gate return "\\textsf{$seq_argument}"; 13070Sstevel@tonic-gate 13080Sstevel@tonic-gate } elsif ($seq_command eq 'X') { 13090Sstevel@tonic-gate # Index entries 13100Sstevel@tonic-gate 13110Sstevel@tonic-gate # use \index command 13120Sstevel@tonic-gate # I will let '!' go through for now 13130Sstevel@tonic-gate # not sure how sub categories are handled in X<> 13140Sstevel@tonic-gate my $index = $self->_create_index($seq_argument); 13150Sstevel@tonic-gate return "\\index{$index}\n"; 13160Sstevel@tonic-gate 13170Sstevel@tonic-gate } else { 13180Sstevel@tonic-gate carp "Unknown sequence $seq_command<$seq_argument>"; 13190Sstevel@tonic-gate } 13200Sstevel@tonic-gate 13210Sstevel@tonic-gate} 13220Sstevel@tonic-gate 13230Sstevel@tonic-gate=back 13240Sstevel@tonic-gate 13250Sstevel@tonic-gate=head2 List Methods 13260Sstevel@tonic-gate 13270Sstevel@tonic-gateMethods used to handle lists. 13280Sstevel@tonic-gate 13290Sstevel@tonic-gate=over 4 13300Sstevel@tonic-gate 13310Sstevel@tonic-gate=item B<begin_list> 13320Sstevel@tonic-gate 13330Sstevel@tonic-gateCalled when a new list is found (via the C<over> directive). 13340Sstevel@tonic-gateCreates a new C<Pod::List> object and stores it on the 13350Sstevel@tonic-gatelist stack. 13360Sstevel@tonic-gate 13370Sstevel@tonic-gate $parser->begin_list($indent, $line_num); 13380Sstevel@tonic-gate 13390Sstevel@tonic-gate=cut 13400Sstevel@tonic-gate 13410Sstevel@tonic-gatesub begin_list { 13420Sstevel@tonic-gate my $self = shift; 13430Sstevel@tonic-gate my $indent = shift; 13440Sstevel@tonic-gate my $line_num = shift; 13450Sstevel@tonic-gate 13460Sstevel@tonic-gate # Indicate that a list should be started for the next item 13470Sstevel@tonic-gate # need to do this to work out the type of list 13480Sstevel@tonic-gate push ( @{$self->lists}, new Pod::List(-indent => $indent, 13490Sstevel@tonic-gate -start => $line_num, 13500Sstevel@tonic-gate -file => $self->input_file, 13510Sstevel@tonic-gate ) 13520Sstevel@tonic-gate ); 13530Sstevel@tonic-gate 13540Sstevel@tonic-gate} 13550Sstevel@tonic-gate 13560Sstevel@tonic-gate=item B<end_list> 13570Sstevel@tonic-gate 13580Sstevel@tonic-gateCalled when the end of a list is found (the C<back> directive). 13590Sstevel@tonic-gatePops the C<Pod::List> object off the stack of lists and writes 13600Sstevel@tonic-gatethe C<latex> code required to close a list. 13610Sstevel@tonic-gate 13620Sstevel@tonic-gate $parser->end_list($line_num); 13630Sstevel@tonic-gate 13640Sstevel@tonic-gate=cut 13650Sstevel@tonic-gate 13660Sstevel@tonic-gatesub end_list { 13670Sstevel@tonic-gate my $self = shift; 13680Sstevel@tonic-gate my $line_num = shift; 13690Sstevel@tonic-gate 13700Sstevel@tonic-gate unless (defined $self->lists->[-1]) { 13710Sstevel@tonic-gate my $file = $self->input_file; 13720Sstevel@tonic-gate warn "No list is active at line $line_num (file=$file). Missing =over?\n"; 13730Sstevel@tonic-gate return; 13740Sstevel@tonic-gate } 13750Sstevel@tonic-gate 13760Sstevel@tonic-gate # What to write depends on list type 13770Sstevel@tonic-gate my $type = $self->lists->[-1]->type; 13780Sstevel@tonic-gate 13790Sstevel@tonic-gate # Dont write anything if the list type is not set 13800Sstevel@tonic-gate # iomplying that a list was created but no entries were 13810Sstevel@tonic-gate # placed in it (eg because of a =begin/=end combination) 13820Sstevel@tonic-gate $self->_output("\\end{$type}\n") 13830Sstevel@tonic-gate if (defined $type && length($type) > 0); 13840Sstevel@tonic-gate 13850Sstevel@tonic-gate # Clear list 13860Sstevel@tonic-gate pop(@{ $self->lists}); 13870Sstevel@tonic-gate 13880Sstevel@tonic-gate} 13890Sstevel@tonic-gate 13900Sstevel@tonic-gate=item B<add_item> 13910Sstevel@tonic-gate 13920Sstevel@tonic-gateAdd items to the list. The first time an item is encountered 13930Sstevel@tonic-gate(determined from the state of the current C<Pod::List> object) 13940Sstevel@tonic-gatethe type of list is determined (ordered, unnumbered or description) 13950Sstevel@tonic-gateand the relevant latex code issued. 13960Sstevel@tonic-gate 13970Sstevel@tonic-gate $parser->add_item($paragraph, $line_num); 13980Sstevel@tonic-gate 13990Sstevel@tonic-gate=cut 14000Sstevel@tonic-gate 14010Sstevel@tonic-gatesub add_item { 14020Sstevel@tonic-gate my $self = shift; 14030Sstevel@tonic-gate my $paragraph = shift; 14040Sstevel@tonic-gate my $line_num = shift; 14050Sstevel@tonic-gate 14060Sstevel@tonic-gate unless (defined $self->lists->[-1]) { 14070Sstevel@tonic-gate my $file = $self->input_file; 14080Sstevel@tonic-gate warn "List has already ended by line $line_num of file $file. Missing =over?\n"; 14090Sstevel@tonic-gate # Replace special chars 14100Sstevel@tonic-gate# $paragraph = $self->_replace_special_chars($paragraph); 14110Sstevel@tonic-gate $self->_output("$paragraph\n\n"); 14120Sstevel@tonic-gate return; 14130Sstevel@tonic-gate } 14140Sstevel@tonic-gate 14150Sstevel@tonic-gate # If paragraphs printing is turned off via =begin/=end or whatver 14160Sstevel@tonic-gate # simply return immediately 14170Sstevel@tonic-gate return if $self->{_suppress_all_para}; 14180Sstevel@tonic-gate 14190Sstevel@tonic-gate # Check to see whether we are starting a new lists 14200Sstevel@tonic-gate if (scalar($self->lists->[-1]->item) == 0) { 14210Sstevel@tonic-gate 14220Sstevel@tonic-gate # Examine the paragraph to determine what type of list 14230Sstevel@tonic-gate # we have 14240Sstevel@tonic-gate $paragraph =~ s/\s+$//; 14250Sstevel@tonic-gate $paragraph =~ s/^\s+//; 14260Sstevel@tonic-gate 14270Sstevel@tonic-gate my $type; 14280Sstevel@tonic-gate if (substr($paragraph, 0,1) eq '*') { 14290Sstevel@tonic-gate $type = 'itemize'; 14300Sstevel@tonic-gate } elsif ($paragraph =~ /^\d/) { 14310Sstevel@tonic-gate $type = 'enumerate'; 14320Sstevel@tonic-gate } else { 14330Sstevel@tonic-gate $type = 'description'; 14340Sstevel@tonic-gate } 14350Sstevel@tonic-gate $self->lists->[-1]->type($type); 14360Sstevel@tonic-gate 14370Sstevel@tonic-gate $self->_output("\\begin{$type}\n"); 14380Sstevel@tonic-gate 14390Sstevel@tonic-gate } 14400Sstevel@tonic-gate 14410Sstevel@tonic-gate my $type = $self->lists->[-1]->type; 14420Sstevel@tonic-gate 14430Sstevel@tonic-gate if ($type eq 'description') { 14440Sstevel@tonic-gate # Handle long items - long items do not wrap 14450Sstevel@tonic-gate # If the string is longer than 40 characters we split 14460Sstevel@tonic-gate # it into a real item header and some bold text. 14470Sstevel@tonic-gate my $maxlen = 40; 14480Sstevel@tonic-gate my ($hunk1, $hunk2) = $self->_split_delimited( $paragraph, $maxlen ); 14490Sstevel@tonic-gate 14500Sstevel@tonic-gate # Print the first hunk 14510Sstevel@tonic-gate $self->_output("\n\\item[$hunk1] "); 14520Sstevel@tonic-gate 14530Sstevel@tonic-gate # and the second hunk if it is defined 14540Sstevel@tonic-gate if ($hunk2) { 14550Sstevel@tonic-gate $self->_output("\\textbf{$hunk2}"); 14560Sstevel@tonic-gate } else { 14570Sstevel@tonic-gate # Not there so make sure we have a new line 14580Sstevel@tonic-gate $self->_output("\\mbox{}"); 14590Sstevel@tonic-gate } 14600Sstevel@tonic-gate 14610Sstevel@tonic-gate } else { 14620Sstevel@tonic-gate # If the item was '* Something' or '\d+ something' we still need to write 14630Sstevel@tonic-gate # out the something. Also allow 1) and 1. 14640Sstevel@tonic-gate my $extra_info = $paragraph; 14650Sstevel@tonic-gate $extra_info =~ s/^(\*|\d+[\.\)]?)\s*//; 14660Sstevel@tonic-gate $self->_output("\n\\item $extra_info"); 14670Sstevel@tonic-gate } 14680Sstevel@tonic-gate 14690Sstevel@tonic-gate # Store the item name in the object. Required so that 14700Sstevel@tonic-gate # we can tell if the list is new or not 14710Sstevel@tonic-gate $self->lists->[-1]->item($paragraph); 14720Sstevel@tonic-gate 14730Sstevel@tonic-gate} 14740Sstevel@tonic-gate 14750Sstevel@tonic-gate=back 14760Sstevel@tonic-gate 14770Sstevel@tonic-gate=head2 Methods for headings 14780Sstevel@tonic-gate 14790Sstevel@tonic-gate=over 4 14800Sstevel@tonic-gate 14810Sstevel@tonic-gate=item B<head> 14820Sstevel@tonic-gate 14830Sstevel@tonic-gatePrint a heading of the required level. 14840Sstevel@tonic-gate 14850Sstevel@tonic-gate $parser->head($level, $paragraph, $parobj); 14860Sstevel@tonic-gate 14870Sstevel@tonic-gateThe first argument is the pod heading level. The second argument 14880Sstevel@tonic-gateis the contents of the heading. The 3rd argument is a Pod::Paragraph 14890Sstevel@tonic-gateobject so that the line number can be extracted. 14900Sstevel@tonic-gate 14910Sstevel@tonic-gate=cut 14920Sstevel@tonic-gate 14930Sstevel@tonic-gatesub head { 14940Sstevel@tonic-gate my $self = shift; 14950Sstevel@tonic-gate my $num = shift; 14960Sstevel@tonic-gate my $paragraph = shift; 14970Sstevel@tonic-gate my $parobj = shift; 14980Sstevel@tonic-gate 14990Sstevel@tonic-gate # If we are replace 'head1 NAME' with a section 15000Sstevel@tonic-gate # we return immediately if we get it 15010Sstevel@tonic-gate return 15020Sstevel@tonic-gate if ($self->{_CURRENT_HEAD1} =~ /^NAME/i && $self->ReplaceNAMEwithSection()); 15030Sstevel@tonic-gate 15040Sstevel@tonic-gate # Create a label 15050Sstevel@tonic-gate my $label = $self->_create_label($paragraph); 15060Sstevel@tonic-gate 15070Sstevel@tonic-gate # Create an index entry 15080Sstevel@tonic-gate my $index = $self->_create_index($paragraph); 15090Sstevel@tonic-gate 15100Sstevel@tonic-gate # Work out position in the above array taking into account 15110Sstevel@tonic-gate # that =head1 is equivalent to $self->Head1Level 15120Sstevel@tonic-gate 15130Sstevel@tonic-gate my $level = $self->Head1Level() - 1 + $num; 15140Sstevel@tonic-gate 15150Sstevel@tonic-gate # Warn if heading to large 15160Sstevel@tonic-gate if ($num > $#LatexSections) { 15170Sstevel@tonic-gate my $line = $parobj->file_line; 15180Sstevel@tonic-gate my $file = $self->input_file; 15190Sstevel@tonic-gate warn "Heading level too large ($level) for LaTeX at line $line of file $file\n"; 15200Sstevel@tonic-gate $level = $#LatexSections; 15210Sstevel@tonic-gate } 15220Sstevel@tonic-gate 15230Sstevel@tonic-gate # Check to see whether section should be unnumbered 15240Sstevel@tonic-gate my $star = ($level >= $self->LevelNoNum ? '*' : ''); 15250Sstevel@tonic-gate 15260Sstevel@tonic-gate # Section 15270Sstevel@tonic-gate $self->_output("\\" .$LatexSections[$level] .$star ."{$paragraph\\label{".$label ."}\\index{".$index."}}\n"); 15280Sstevel@tonic-gate 15290Sstevel@tonic-gate} 15300Sstevel@tonic-gate 15310Sstevel@tonic-gate 15320Sstevel@tonic-gate=back 15330Sstevel@tonic-gate 15340Sstevel@tonic-gate=end __PRIVATE__ 15350Sstevel@tonic-gate 15360Sstevel@tonic-gate=begin __PRIVATE__ 15370Sstevel@tonic-gate 15380Sstevel@tonic-gate=head2 Internal methods 15390Sstevel@tonic-gate 15400Sstevel@tonic-gateInternal routines are described in this section. They do not form part of the 15410Sstevel@tonic-gatepublic interface. All private methods start with an underscore. 15420Sstevel@tonic-gate 15430Sstevel@tonic-gate=over 4 15440Sstevel@tonic-gate 15450Sstevel@tonic-gate=item B<_output> 15460Sstevel@tonic-gate 15470Sstevel@tonic-gateOutput text to the output filehandle. This method must be always be called 15480Sstevel@tonic-gateto output parsed text. 15490Sstevel@tonic-gate 15500Sstevel@tonic-gate $parser->_output($text); 15510Sstevel@tonic-gate 15520Sstevel@tonic-gateDoes not write anything if a =begin is active that should be 15530Sstevel@tonic-gateignored. 15540Sstevel@tonic-gate 15550Sstevel@tonic-gate=cut 15560Sstevel@tonic-gate 15570Sstevel@tonic-gatesub _output { 15580Sstevel@tonic-gate my $self = shift; 15590Sstevel@tonic-gate my $text = shift; 15600Sstevel@tonic-gate 15610Sstevel@tonic-gate print { $self->output_handle } $text 15620Sstevel@tonic-gate unless $self->{_suppress_all_para}; 15630Sstevel@tonic-gate 15640Sstevel@tonic-gate} 15650Sstevel@tonic-gate 15660Sstevel@tonic-gate 15670Sstevel@tonic-gate=item B<_replace_special_chars> 15680Sstevel@tonic-gate 15690Sstevel@tonic-gateSubroutine to replace characters that are special in C<latex> 15700Sstevel@tonic-gatewith the escaped forms 15710Sstevel@tonic-gate 15720Sstevel@tonic-gate $escaped = $parser->_replace_special_chars($paragraph); 15730Sstevel@tonic-gate 15740Sstevel@tonic-gateNeed to call this routine before interior_sequences are munged but not 15750Sstevel@tonic-gateif verbatim. It must be called before interpolation of interior 15760Sstevel@tonic-gatesequences so that curly brackets and special latex characters inserted 15770Sstevel@tonic-gateduring interpolation are not themselves escaped. This means that < and 15780Sstevel@tonic-gate> can not be modified here since the text still contains interior 15790Sstevel@tonic-gatesequences. 15800Sstevel@tonic-gate 15810Sstevel@tonic-gateSpecial characters and the C<latex> equivalents are: 15820Sstevel@tonic-gate 15830Sstevel@tonic-gate } \} 15840Sstevel@tonic-gate { \{ 15850Sstevel@tonic-gate _ \_ 15860Sstevel@tonic-gate $ \$ 15870Sstevel@tonic-gate % \% 15880Sstevel@tonic-gate & \& 15890Sstevel@tonic-gate \ $\backslash$ 15900Sstevel@tonic-gate ^ \^{} 15910Sstevel@tonic-gate ~ \~{} 15920Sstevel@tonic-gate # \# 15930Sstevel@tonic-gate 15940Sstevel@tonic-gate=cut 15950Sstevel@tonic-gate 15960Sstevel@tonic-gatesub _replace_special_chars { 15970Sstevel@tonic-gate my $self = shift; 15980Sstevel@tonic-gate my $paragraph = shift; 15990Sstevel@tonic-gate 16000Sstevel@tonic-gate # Replace a \ with $\backslash$ 16010Sstevel@tonic-gate # This is made more complicated because the dollars will be escaped 16020Sstevel@tonic-gate # by the subsequent replacement. Easiest to add \backslash 16030Sstevel@tonic-gate # now and then add the dollars 16040Sstevel@tonic-gate $paragraph =~ s/\\/\\backslash/g; 16050Sstevel@tonic-gate 16060Sstevel@tonic-gate # Must be done after escape of \ since this command adds latex escapes 16070Sstevel@tonic-gate # Replace characters that can be escaped 16080Sstevel@tonic-gate $paragraph =~ s/([\$\#&%_{}])/\\$1/g; 16090Sstevel@tonic-gate 16100Sstevel@tonic-gate # Replace ^ characters with \^{} so that $^F works okay 16110Sstevel@tonic-gate $paragraph =~ s/(\^)/\\$1\{\}/g; 16120Sstevel@tonic-gate 16130Sstevel@tonic-gate # Replace tilde (~) with \texttt{\~{}} 16140Sstevel@tonic-gate $paragraph =~ s/~/\\texttt\{\\~\{\}\}/g; 16150Sstevel@tonic-gate 16160Sstevel@tonic-gate # Now add the dollars around each \backslash 16170Sstevel@tonic-gate $paragraph =~ s/(\\backslash)/\$$1\$/g; 16180Sstevel@tonic-gate return $paragraph; 16190Sstevel@tonic-gate} 16200Sstevel@tonic-gate 16210Sstevel@tonic-gate=item B<_replace_special_chars_late> 16220Sstevel@tonic-gate 16230Sstevel@tonic-gateReplace special characters that can not be replaced before interior 16240Sstevel@tonic-gatesequence interpolation. See C<_replace_special_chars> for a routine 16250Sstevel@tonic-gateto replace special characters prior to interpolation of interior 16260Sstevel@tonic-gatesequences. 16270Sstevel@tonic-gate 16280Sstevel@tonic-gateDoes the following transformation: 16290Sstevel@tonic-gate 16300Sstevel@tonic-gate < $<$ 16310Sstevel@tonic-gate > $>$ 16320Sstevel@tonic-gate | $|$ 16330Sstevel@tonic-gate 16340Sstevel@tonic-gate 16350Sstevel@tonic-gate=cut 16360Sstevel@tonic-gate 16370Sstevel@tonic-gatesub _replace_special_chars_late { 16380Sstevel@tonic-gate my $self = shift; 16390Sstevel@tonic-gate my $paragraph = shift; 16400Sstevel@tonic-gate 16410Sstevel@tonic-gate # < and > 16420Sstevel@tonic-gate $paragraph =~ s/(<|>)/\$$1\$/g; 16430Sstevel@tonic-gate 16440Sstevel@tonic-gate # Replace | with $|$ 16450Sstevel@tonic-gate $paragraph =~ s'\|'$|$'g; 16460Sstevel@tonic-gate 16470Sstevel@tonic-gate 16480Sstevel@tonic-gate return $paragraph; 16490Sstevel@tonic-gate} 16500Sstevel@tonic-gate 16510Sstevel@tonic-gate 16520Sstevel@tonic-gate=item B<_create_label> 16530Sstevel@tonic-gate 16540Sstevel@tonic-gateReturn a string that can be used as an internal reference 16550Sstevel@tonic-gatein a C<latex> document (i.e. accepted by the C<\label> command) 16560Sstevel@tonic-gate 16570Sstevel@tonic-gate $label = $parser->_create_label($string) 16580Sstevel@tonic-gate 16590Sstevel@tonic-gateIf UniqueLabels is true returns a label prefixed by Label() 16600Sstevel@tonic-gateThis can be suppressed with an optional second argument. 16610Sstevel@tonic-gate 16620Sstevel@tonic-gate $label = $parser->_create_label($string, $suppress); 16630Sstevel@tonic-gate 16640Sstevel@tonic-gateIf a second argument is supplied (of any value including undef) 16650Sstevel@tonic-gatethe Label() is never prefixed. This means that this routine can 16660Sstevel@tonic-gatebe called to create a Label() without prefixing a previous setting. 16670Sstevel@tonic-gate 16680Sstevel@tonic-gate=cut 16690Sstevel@tonic-gate 16700Sstevel@tonic-gatesub _create_label { 16710Sstevel@tonic-gate my $self = shift; 16720Sstevel@tonic-gate my $paragraph = shift; 16730Sstevel@tonic-gate my $suppress = (@_ ? 1 : 0 ); 16740Sstevel@tonic-gate 16750Sstevel@tonic-gate # Remove latex commands 16760Sstevel@tonic-gate $paragraph = $self->_clean_latex_commands($paragraph); 16770Sstevel@tonic-gate 16780Sstevel@tonic-gate # Remove non alphanumerics from the label and replace with underscores 16790Sstevel@tonic-gate # want to protect '-' though so use negated character classes 16800Sstevel@tonic-gate $paragraph =~ s/[^-:\w]/_/g; 16810Sstevel@tonic-gate 16820Sstevel@tonic-gate # Multiple underscores will look unsightly so remove repeats 16830Sstevel@tonic-gate # This will also have the advantage of tidying up the end and 16840Sstevel@tonic-gate # start of string 16850Sstevel@tonic-gate $paragraph =~ s/_+/_/g; 16860Sstevel@tonic-gate 16870Sstevel@tonic-gate # If required need to make sure that the label is unique 16880Sstevel@tonic-gate # since it is possible to have multiple pods in a single 16890Sstevel@tonic-gate # document 16900Sstevel@tonic-gate if (!$suppress && $self->UniqueLabels() && defined $self->Label) { 16910Sstevel@tonic-gate $paragraph = $self->Label() .'_'. $paragraph; 16920Sstevel@tonic-gate } 16930Sstevel@tonic-gate 16940Sstevel@tonic-gate return $paragraph; 16950Sstevel@tonic-gate} 16960Sstevel@tonic-gate 16970Sstevel@tonic-gate 16980Sstevel@tonic-gate=item B<_create_index> 16990Sstevel@tonic-gate 17000Sstevel@tonic-gateSimilar to C<_create_label> except an index entry is created. 17010Sstevel@tonic-gateIf C<UniqueLabels> is true, the index entry is prefixed by 17020Sstevel@tonic-gatethe current C<Label> and an exclamation mark. 17030Sstevel@tonic-gate 17040Sstevel@tonic-gate $ind = $parser->_create_index($paragraph); 17050Sstevel@tonic-gate 17060Sstevel@tonic-gateAn exclamation mark is used by C<makeindex> to generate 17070Sstevel@tonic-gatesub-entries in an index. 17080Sstevel@tonic-gate 17090Sstevel@tonic-gate=cut 17100Sstevel@tonic-gate 17110Sstevel@tonic-gatesub _create_index { 17120Sstevel@tonic-gate my $self = shift; 17130Sstevel@tonic-gate my $paragraph = shift; 17140Sstevel@tonic-gate my $suppress = (@_ ? 1 : 0 ); 17150Sstevel@tonic-gate 17160Sstevel@tonic-gate # Remove latex commands 17170Sstevel@tonic-gate $paragraph = $self->_clean_latex_commands($paragraph); 17180Sstevel@tonic-gate 17190Sstevel@tonic-gate # If required need to make sure that the index entry is unique 17200Sstevel@tonic-gate # since it is possible to have multiple pods in a single 17210Sstevel@tonic-gate # document 17220Sstevel@tonic-gate if (!$suppress && $self->UniqueLabels() && defined $self->Label) { 17230Sstevel@tonic-gate $paragraph = $self->Label() .'!'. $paragraph; 17240Sstevel@tonic-gate } 17250Sstevel@tonic-gate 17260Sstevel@tonic-gate # Need to replace _ with space 17270Sstevel@tonic-gate $paragraph =~ s/_/ /g; 17280Sstevel@tonic-gate 17290Sstevel@tonic-gate return $paragraph; 17300Sstevel@tonic-gate 17310Sstevel@tonic-gate} 17320Sstevel@tonic-gate 17330Sstevel@tonic-gate=item B<_clean_latex_commands> 17340Sstevel@tonic-gate 17350Sstevel@tonic-gateRemoves latex commands from text. The latex command is assumed to be of the 17360Sstevel@tonic-gateform C<\command{ text }>. "C<text>" is retained 17370Sstevel@tonic-gate 17380Sstevel@tonic-gate $clean = $parser->_clean_latex_commands($text); 17390Sstevel@tonic-gate 17400Sstevel@tonic-gate=cut 17410Sstevel@tonic-gate 17420Sstevel@tonic-gatesub _clean_latex_commands { 17430Sstevel@tonic-gate my $self = shift; 17440Sstevel@tonic-gate my $paragraph = shift; 17450Sstevel@tonic-gate 17460Sstevel@tonic-gate # Remove latex commands of the form \text{ } 17470Sstevel@tonic-gate # and replace with the contents of the { } 17480Sstevel@tonic-gate # need to make this non-greedy so that it can handle 17490Sstevel@tonic-gate # "\text{a} and \text2{b}" 17500Sstevel@tonic-gate # without converting it to 17510Sstevel@tonic-gate # "a} and \text2{b" 17520Sstevel@tonic-gate # This match will still get into trouble if \} is present 17530Sstevel@tonic-gate # This is not vital since the subsequent replacement of non-alphanumeric 17540Sstevel@tonic-gate # characters will tidy it up anyway 17550Sstevel@tonic-gate $paragraph =~ s/\\\w+{(.*?)}/$1/g; 17560Sstevel@tonic-gate 17570Sstevel@tonic-gate return $paragraph 17580Sstevel@tonic-gate} 17590Sstevel@tonic-gate 17600Sstevel@tonic-gate=item B<_split_delimited> 17610Sstevel@tonic-gate 17620Sstevel@tonic-gateSplit the supplied string into two parts at approximately the 17630Sstevel@tonic-gatespecified word boundary. Special care is made to make sure that it 17640Sstevel@tonic-gatedoes not split in the middle of some curly brackets. 17650Sstevel@tonic-gate 17660Sstevel@tonic-gatee.g. "this text is \textbf{very bold}" would not be split into 17670Sstevel@tonic-gate"this text is \textbf{very" and " bold". 17680Sstevel@tonic-gate 17690Sstevel@tonic-gate ($hunk1, $hunk2) = $self->_split_delimited( $para, $length); 17700Sstevel@tonic-gate 17710Sstevel@tonic-gateThe length indicates the maximum length of hunk1. 17720Sstevel@tonic-gate 17730Sstevel@tonic-gate=cut 17740Sstevel@tonic-gate 17750Sstevel@tonic-gate# initially Supplied by hsmyers@sdragons.com 17760Sstevel@tonic-gate# 10/25/01, utility to split \hbox 17770Sstevel@tonic-gate# busting lines. Reformatted by TimJ to match module style. 17780Sstevel@tonic-gatesub _split_delimited { 17790Sstevel@tonic-gate my $self = shift; 17800Sstevel@tonic-gate my $input = shift; 17810Sstevel@tonic-gate my $limit = shift; 17820Sstevel@tonic-gate 17830Sstevel@tonic-gate # Return immediately if already small 17840Sstevel@tonic-gate return ($input, '') if length($input) < $limit; 17850Sstevel@tonic-gate 17860Sstevel@tonic-gate my @output; 17870Sstevel@tonic-gate my $s = ''; 17880Sstevel@tonic-gate my $t = ''; 17890Sstevel@tonic-gate my $depth = 0; 17900Sstevel@tonic-gate my $token; 17910Sstevel@tonic-gate 17920Sstevel@tonic-gate $input =~ s/\n/ /gm; 17930Sstevel@tonic-gate $input .= ' '; 17940Sstevel@tonic-gate foreach ( split ( //, $input ) ) { 17950Sstevel@tonic-gate $token .= $_; 17960Sstevel@tonic-gate if (/\{/) { 17970Sstevel@tonic-gate $depth++; 17980Sstevel@tonic-gate } elsif ( /}/ ) { 17990Sstevel@tonic-gate $depth--; 18000Sstevel@tonic-gate } elsif ( / / and $depth == 0) { 18010Sstevel@tonic-gate push @output, $token if ( $token and $token ne ' ' ); 18020Sstevel@tonic-gate $token = ''; 18030Sstevel@tonic-gate } 18040Sstevel@tonic-gate } 18050Sstevel@tonic-gate 18060Sstevel@tonic-gate foreach (@output) { 18070Sstevel@tonic-gate if (length($s) < $limit) { 18080Sstevel@tonic-gate $s .= $_; 18090Sstevel@tonic-gate } else { 18100Sstevel@tonic-gate $t .= $_; 18110Sstevel@tonic-gate } 18120Sstevel@tonic-gate } 18130Sstevel@tonic-gate 18140Sstevel@tonic-gate # Tidy up 18150Sstevel@tonic-gate $s =~ s/\s+$//; 18160Sstevel@tonic-gate $t =~ s/\s+$//; 18170Sstevel@tonic-gate return ($s,$t); 18180Sstevel@tonic-gate} 18190Sstevel@tonic-gate 18200Sstevel@tonic-gate=back 18210Sstevel@tonic-gate 18220Sstevel@tonic-gate=end __PRIVATE__ 18230Sstevel@tonic-gate 18240Sstevel@tonic-gate=head1 NOTES 18250Sstevel@tonic-gate 18260Sstevel@tonic-gateCompatible with C<latex2e> only. Can not be used with C<latex> v2.09 18270Sstevel@tonic-gateor earlier. 18280Sstevel@tonic-gate 18290Sstevel@tonic-gateA subclass of C<Pod::Select> so that specific pod sections can be 18300Sstevel@tonic-gateconverted to C<latex> by using the C<select> method. 18310Sstevel@tonic-gate 18320Sstevel@tonic-gateSome HTML escapes are missing and many have not been tested. 18330Sstevel@tonic-gate 18340Sstevel@tonic-gate=head1 SEE ALSO 18350Sstevel@tonic-gate 18360Sstevel@tonic-gateL<Pod::Parser>, L<Pod::Select>, L<pod2latex> 18370Sstevel@tonic-gate 18380Sstevel@tonic-gate=head1 AUTHORS 18390Sstevel@tonic-gate 18400Sstevel@tonic-gateTim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt> 18410Sstevel@tonic-gate 18420Sstevel@tonic-gateBug fixes and improvements have been received from: Simon Cozens 18430Sstevel@tonic-gateE<lt>simon@cozens.netE<gt>, Mark A. Hershberger 18440Sstevel@tonic-gateE<lt>mah@everybody.orgE<gt>, Marcel Grunauer 18450Sstevel@tonic-gateE<lt>marcel@codewerk.comE<gt>, Hugh S Myers 18460Sstevel@tonic-gateE<lt>hsmyers@sdragons.comE<gt>, Peter J Acklam 18470Sstevel@tonic-gateE<lt>jacklam@math.uio.noE<gt>, Sudhi Herle E<lt>sudhi@herle.netE<gt> 18480Sstevel@tonic-gateand Ariel Scolnicov E<lt>ariels@compugen.co.ilE<gt>. 18490Sstevel@tonic-gate 18500Sstevel@tonic-gate 18510Sstevel@tonic-gate=head1 COPYRIGHT 18520Sstevel@tonic-gate 18530Sstevel@tonic-gateCopyright (C) 2000-2003 Tim Jenness. All Rights Reserved. 18540Sstevel@tonic-gate 18550Sstevel@tonic-gateThis program is free software; you can redistribute it and/or modify 18560Sstevel@tonic-gateit under the same terms as Perl itself. 18570Sstevel@tonic-gate 18580Sstevel@tonic-gate=begin __PRIVATE__ 18590Sstevel@tonic-gate 18600Sstevel@tonic-gate=head1 REVISION 18610Sstevel@tonic-gate 18620Sstevel@tonic-gate$Id: LaTeX.pm,v 1.17 2003/04/05 21:25:49 timj Exp $ 18630Sstevel@tonic-gate 18640Sstevel@tonic-gate=end __PRIVATE__ 18650Sstevel@tonic-gate 18660Sstevel@tonic-gate=cut 18670Sstevel@tonic-gate 18680Sstevel@tonic-gate1; 1869