html.pm 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829
  1. # -*-perl-*-
  2. # vim: set filetype=perl:
  3. ######################################################################
  4. # File: html.pm
  5. # html output formatting
  6. #
  7. # A copy of this file is pasted into the beginning of texi2html by
  8. # running './configure'.
  9. #
  10. # This file is in the public domain. Thus it may easily be used as an
  11. # example for further customizations.
  12. #
  13. # Taken from texi2html.pm in 2009.
  14. # Originally written by Olaf Bachmann.
  15. #
  16. # $Id$
  17. use strict;
  18. use vars qw(@html_default_multitable_stack);
  19. # used in mediawiki.pm
  20. #my @html_default_multitable_stack;
  21. # tracks menu entry index
  22. my $html_menu_entry_index;
  23. # the simple_formatted document title
  24. my $html_default_title;
  25. # initialise the html output
  26. sub html_default_load(;$)
  27. {
  28. my $from_command_line = shift;
  29. t2h_default_set_variables_xml();
  30. ###############################################################
  31. # defaults
  32. set_default('HEADERS', 1);
  33. @T2H_FORMAT_EXPAND = ('html');
  34. # The value is the 'SystemLiteral' which identifies the canonical DTD
  35. # for the document.
  36. # Definition: The SystemLiteral is called the entity's system
  37. # identifier. It is a URI, which may be used to retrieve the entity.
  38. # See http://www.xml.com/axml/target.html#NT-ExternalID
  39. set_default('DOCTYPE', '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
  40. # When frames are used, this SystemLiteral identifies the DTD used for
  41. # the file containing the frame description.
  42. set_default('FRAMESET_DOCTYPE', '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">');
  43. # if the value is true the Texinfo menus are shown.
  44. set_default('SHOW_MENU', 1);
  45. set_default('SHOW_TITLE', 1);
  46. # default is to use nodes only as elements.
  47. set_default('USE_SECTIONS', undef);
  48. set_default('TOP_FILE', 'index.html');
  49. # file name used for Top node when NODE_FILES is true
  50. set_default('TOP_NODE_FILE', 'index');
  51. ##############################################################################
  52. #
  53. # The following can only be set in the init file
  54. #
  55. ##############################################################################
  56. set_default('INLINE_INSERTCOPYING', 0);
  57. # if this variable is true, numeric entities are used when there is no
  58. # corresponding textual entity.
  59. set_default('USE_NUMERIC_ENTITY', 1);
  60. # if true, use the original command if the result is an entity
  61. set_default('ENABLE_ENCODING_USE_ENTITY', 1);
  62. # if set, do redirection files for renamed nodes
  63. set_default('RENAMED_NODES_REDIRECTIONS', 1);
  64. # used as identation for block enclosing command @example, etc
  65. # If not empty, must be enclosed in <td></td>
  66. $EXAMPLE_INDENT_CELL = '<td>&nbsp;</td>';
  67. # same as above, only for @small
  68. $SMALL_EXAMPLE_INDENT_CELL = '<td>&nbsp;</td>';
  69. # font size for @small
  70. $SMALL_FONT_SIZE = '-1';
  71. # horizontal rules
  72. # Not used
  73. $SMALL_RULE = '<hr size="1">';
  74. $MIDDLE_RULE = '<hr size="2">';
  75. # used almost everywhere
  76. $DEFAULT_RULE = '<hr>';
  77. # used for top element and before misc elements
  78. $BIG_RULE = '<hr size="6">';
  79. # symbol put at the beginning of nodes entry in menu (and optionnaly of
  80. # unnumbered in menus, see next variable)
  81. $MENU_SYMBOL = '&bull;';
  82. #$MENU_SYMBOL = '*';
  83. set_default('SIMPLE_MENU', 0);
  84. # extension for nodes files when NODE_FILES is true
  85. set_default('NODE_FILE_EXTENSION', 'html');
  86. # extension
  87. set_default('EXTENSION', 'html');
  88. # default is to split the html output
  89. set_default('SPLIT', 'node');
  90. # this resets all the variables to the texi2html specific values if
  91. # called as texi2html
  92. t2h_default_set_variables_texi2html() if ($COMMAND_NAME eq 'texi2html');
  93. # this controls the pre style for menus
  94. $MENU_PRE_STYLE = 'font-family: serif';
  95. # on bug-texinfo is has been said the the style is not code_style
  96. # for menus (except for the node name).
  97. # this controls the menu preformatted format
  98. # FIXME this is not dynamic, so change in MENU_PRE_STYLE is not taken
  99. # into account.
  100. # This is used if the menu appears within a preformatted format (which
  101. # is certainly an invalid construct), and SIMPLE_MENU is not set.
  102. $MENU_PRE_COMPLEX_FORMAT = {
  103. 'pre_style' => $MENU_PRE_STYLE,
  104. 'class' => 'menu-preformatted',
  105. # 'style' => 'code'
  106. };
  107. # This controls the ul style for toc
  108. $NO_BULLET_LIST_STYLE = 'list-style: none';
  109. $NO_BULLET_LIST_CLASS = 'no-bullet';
  110. $NO_BULLET_LIST_ATTRIBUTE = ' class="'.$NO_BULLET_LIST_CLASS.'"';
  111. # These lines are inserted before and after the shortcontents
  112. $BEFORE_OVERVIEW = "<div class=\"shortcontents\">\n";
  113. $AFTER_OVERVIEW = "</div>\n";
  114. # These lines are inserted before and after the contents
  115. $BEFORE_TOC_LINES = "<div class=\"contents\">\n";
  116. $AFTER_TOC_LINES = "</div>\n";
  117. # text inserted after <body ...>
  118. $AFTER_BODY_OPEN = '';
  119. # text inserted before </body>, this will be automatically inside <p></p>
  120. $PRE_BODY_CLOSE = '';
  121. # this is added inside <head></head> after <title> and some <meta name>
  122. # stuff, it can be used for eg. <style>, <script>, <meta> etc. tags.
  123. $EXTRA_HEAD = '';
  124. # Specifies the minimum page length required before a navigation panel
  125. # is placed at the bottom of a page
  126. set_default('WORDS_IN_PAGE', 300);
  127. # html version for latex2html
  128. set_default('L2H_HTML_VERSION', '4.0');
  129. # this is not set dynamically
  130. if (!get_conf('HEADER_IN_TABLE'))
  131. {
  132. @SECTION_BUTTONS = ([ 'NodeNext', \&html_default_node_direction ],
  133. [ 'NodePrev', \&html_default_node_direction ],
  134. [ 'NodeUp', \&html_default_node_direction ], ' ',
  135. 'Contents', 'Index');
  136. @CHAPTER_BUTTONS = @SECTION_FOOTER_BUTTONS = @NODE_FOOTER_BUTTONS =
  137. @MISC_BUTTONS = @TOP_BUTTONS = @SECTION_BUTTONS;
  138. @LINKS_BUTTONS =
  139. (
  140. 'Top', 'Index', 'Contents', 'About', 'NodeUp', 'NextFile', 'PrevFile'
  141. );
  142. $BIG_RULE = $DEFAULT_RULE;
  143. }
  144. set_default('ICONS', 0);
  145. %BUTTONS_ACCESSKEY =
  146. (
  147. 'Top', '',
  148. 'Contents', '',
  149. 'Overview', '',
  150. 'Index', '',
  151. 'This', '',
  152. 'Back', 'p',
  153. 'FastBack', '',
  154. 'Prev', 'p',
  155. 'Up', 'u',
  156. 'Next', 'n',
  157. 'NodeUp', 'u',
  158. 'NodeNext', 'n',
  159. 'NodePrev', 'p',
  160. 'NodeForward', '',
  161. 'NodeBack', '',
  162. 'Forward', 'n',
  163. 'FastForward', '',
  164. 'About' , '',
  165. 'First', '',
  166. 'Last', '',
  167. 'NextFile', '',
  168. 'PrevFile', '',
  169. );
  170. # see http://www.w3.org/TR/REC-html40/types.html#type-links
  171. %BUTTONS_REL =
  172. (
  173. 'Top', 'start',
  174. 'Contents', 'contents',
  175. 'Overview', '',
  176. 'Index', 'index',
  177. 'This', '',
  178. 'Back', 'previous',
  179. 'FastBack', '',
  180. 'Prev', 'previous',
  181. 'Up', 'up',
  182. 'Next', 'next',
  183. 'NodeUp', 'up',
  184. 'NodeNext', 'next',
  185. 'NodePrev', 'previous',
  186. 'NodeForward', '',
  187. 'NodeBack', '',
  188. 'Forward', 'next',
  189. 'FastForward', '',
  190. 'About' , 'help',
  191. 'First', '',
  192. 'Last', '',
  193. 'NextFile', 'next',
  194. 'PrevFile', 'previous',
  195. );
  196. # PRE_ABOUT can be a function reference or a scalar.
  197. # Note that if it is a scalar, T2H_InitGlobals has not been called,
  198. # and all global variables like $ADDRESS are not available.
  199. $PRE_ABOUT = sub
  200. {
  201. return ' ' . &$program_string() . "\n";
  202. };
  203. # If customizing $AFTER_ABOUT, be sure to put the content inside <p></p>.
  204. $AFTER_ABOUT = '';
  205. %BUTTONS_EXAMPLE =
  206. (
  207. 'Top', ' &nbsp; ',
  208. 'Contents', ' &nbsp; ',
  209. 'Overview', ' &nbsp; ',
  210. 'Index', ' &nbsp; ',
  211. 'This', '1.2.3',
  212. 'Back', '1.2.2',
  213. 'FastBack', '1',
  214. 'Prev', '1.2.2',
  215. 'Up', '1.2',
  216. 'Next', '1.2.4',
  217. 'NodeUp', '1.2',
  218. 'NodeNext', '1.2.4',
  219. 'NodePrev', '1.2.2',
  220. 'NodeForward', '1.2.4',
  221. 'NodeBack', '1.2.2',
  222. 'Forward', '1.2.4',
  223. 'FastForward', '2',
  224. 'About', ' &nbsp; ',
  225. 'First', '1.',
  226. 'Last', '1.2.4',
  227. 'NextFile', ' &nbsp; ',
  228. 'PrevFile', ' &nbsp; ',
  229. );
  230. @IMAGE_EXTENSIONS = ('png','jpg','jpeg','gif');
  231. #, 'txt');
  232. #######################################################################
  233. #
  234. # Values guessed if not set here. The value used is in
  235. # $Texi2HTML::THISDOC{'VARNAME'}
  236. #
  237. #######################################################################
  238. set_default('BODYTEXT', undef);
  239. $translate_names = \&html_default_translate_names;
  240. t2h_default_push_handler(\&html_default_initialize, \@command_handler_init);
  241. # This must be done after language has been set
  242. t2h_default_push_handler(\&html_default_bodytext, \@command_handler_process);
  243. # This must be done after the fulltitle has been set
  244. t2h_default_push_handler(\&html_default_do_title, \@command_handler_output);
  245. ########################################################################
  246. # Control of Page layout:
  247. # There are the following subs which control the layout:
  248. #
  249. $print_section = \&HTML_DEFAULT_print_section;
  250. $end_section = \&HTML_DEFAULT_end_section;
  251. $one_section = \&HTML_DEFAULT_one_section;
  252. $print_Top_footer = \&HTML_DEFAULT_print_Top_footer;
  253. $print_Top = \&HTML_DEFAULT_print_Top;
  254. # changed in info format, but irrelevant for non-split formats
  255. $print_Footnotes = \&T2H_DEFAULT_print_Footnotes;
  256. $print_misc_header = \&HTML_DEFAULT_print_misc_header;
  257. $print_misc_footer = \&HTML_DEFAULT_print_misc_footer;
  258. $print_section_footer = \&HTML_DEFAULT_print_section_footer;
  259. $print_chapter_header = \&HTML_DEFAULT_print_chapter_header;
  260. $print_section_header = \&HTML_DEFAULT_print_section_header;
  261. $print_chapter_footer = \&HTML_DEFAULT_print_chapter_footer;
  262. $print_page_head = \&HTML_DEFAULT_print_page_head;
  263. $print_page_foot = \&HTML_DEFAULT_print_page_foot;
  264. $print_head_navigation = \&HTML_DEFAULT_print_head_navigation;
  265. $print_foot_navigation = \&HTML_DEFAULT_print_foot_navigation;
  266. $button_icon_img = \&HTML_DEFAULT_button_icon_img;
  267. $button_formatting = \&HTML_DEFAULT_button_formatting;
  268. $print_navigation = \&HTML_DEFAULT_print_navigation;
  269. $about_body = \&HTML_DEFAULT_about_body;
  270. $print_frame = \&HTML_DEFAULT_print_frame;
  271. $print_toc_frame = \&HTML_DEFAULT_print_toc_frame;
  272. $contents = \&HTML_DEFAULT_contents;
  273. $shortcontents = \&HTML_DEFAULT_shortcontents;
  274. $print_redirection_page = \&HTML_DEFAULT_print_redirection_page;
  275. ########################################################################
  276. # Control of formatting:
  277. # 1.) For some changes, it is often enough to change the value of
  278. # some global map. It might necessitate building a little
  279. # function along with the change in hash, if the change is the use
  280. # of another function (in style_map).
  281. # 2.) For other changes, reimplement one of the t2h_default_<fnc>* routines,
  282. # give them another name, and assign them to the respective
  283. # $<fnc> variable (below).
  284. #
  285. # texinfo "simple things" (@foo) to HTML ones
  286. #
  287. %simple_map = %default_simple_map;
  288. $simple_map{'*'} = '<br>'; # HTML+
  289. $simple_map{' '} = '&nbsp;';
  290. $simple_map{"\t"} = '&nbsp;';
  291. $simple_map{"\n"} = '&nbsp;';
  292. # "&#173;" or "&shy;" could also be possible for @-, but it seems
  293. # that some browser will consider this as an always visible hyphen mark
  294. # which is not what we want (see http://www.cs.tut.fi/~jkorpela/shy.html)
  295. #$simple_map{'-'} = ''; # hyphenation hint
  296. # this map is used in preformatted text
  297. %simple_map_pre = %simple_map;
  298. $simple_map_pre{'*'} = "\n";
  299. # use entities in the default case
  300. #$things_map{'dots'} = '<small class="dots">...</small>';
  301. $things_map{'enddots'} = '<small class="enddots">...</small>';
  302. %style_map = ();
  303. %style_map_pre = ();
  304. t2h_default_copy_style_map (\%default_style_map, \%style_map);
  305. t2h_default_copy_style_map (\%default_style_map_pre, \%style_map_pre);
  306. # default is {'args' => ['normal'], 'attribute' => ''},
  307. my %style_map_html = (
  308. 'b', {'inline_attribute' => 'b'},
  309. 'cite', {'inline_attribute' => 'cite'},
  310. 'code', {'inline_attribute' => 'code'},
  311. 'command', {'inline_attribute' => 'code'},
  312. 'dfn', {'inline_attribute' => 'em'},
  313. 'email', {'function' => \&html_default_email},
  314. 'emph', {'inline_attribute' => 'em'},
  315. 'env', {'inline_attribute' => 'code'},
  316. 'file', {'inline_attribute' => 'tt', 'quote' => '"'},
  317. 'headitemfont', {'inline_attribute' => 'b'}, # not really that, in fact it is
  318. # in <th> rather than <td>
  319. 'i', {'inline_attribute' => 'i'},
  320. 'slanted', {'inline_attribute' => 'i'},
  321. 'sansserif', {'inline_attribute' => 'span class="sansserif"'},
  322. 'kbd', {'inline_attribute' => 'kbd'},
  323. 'key', {'begin' => '&lt;', 'end' => '&gt;'},
  324. 'math', {'function' => \&html_default_math},
  325. 'option', {'inline_attribute' => 'samp', 'quote' => '"'},
  326. 'r', {'inline_attribute' => 'span class="roman"'},
  327. 'samp', {'inline_attribute' => 'samp', 'quote' => '"'},
  328. 'sc', {'inline_attribute' => 'small'},
  329. 'strong', {'inline_attribute' => 'strong'},
  330. 't', {'inline_attribute' => 'tt'},
  331. 'uref', {'function' => \&html_default_uref},
  332. 'url', {'function' => \&html_default_uref},
  333. 'indicateurl', {'begin' => '&lt;<code>', 'end' => '</code>&gt;'},
  334. 'var', {'inline_attribute' => 'var'},
  335. 'verb', {'inline_attribute' => 'tt'},
  336. );
  337. foreach my $style_command (keys(%style_map_html))
  338. {
  339. foreach my $key (keys(%{$style_map_html{$style_command}}))
  340. {
  341. $style_map_pre{$style_command}->{$key} = $style_map_html{$style_command}->{$key};
  342. $style_map{$style_command}->{$key} = $style_map_html{$style_command}->{$key};
  343. }
  344. }
  345. %line_command_map = (
  346. 'title' => 'h1',
  347. 'subtitle' => 'h3 align="right"',
  348. 'author' => 'strong',
  349. );
  350. foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents))
  351. {
  352. $style_map{$accent_command} = { 'function' => \&xml_default_accent };
  353. $style_map_pre{$accent_command} = { 'function' => \&xml_default_accent };
  354. }
  355. $style_map_pre{'sc'} = {};
  356. $style_map_pre{'titlefont'} = {};
  357. $style_map_pre{'click'}->{'function'} = \&t2h_default_click_pre;
  358. # uncomment to use the old interface
  359. #%style_map = %old_style_map;
  360. #%style_map_pre = %old_style_map_pre;
  361. %simple_format_simple_map_texi = %simple_map_pre;
  362. %format_map = (
  363. # 'quotation' => 'blockquote',
  364. # lists
  365. # 'itemize' => 'ul',
  366. 'enumerate' => 'ol',
  367. # 'multitable' => 'table',
  368. 'table' => 'dl compact="compact"',
  369. 'vtable' => 'dl compact="compact"',
  370. 'ftable' => 'dl compact="compact"',
  371. 'group' => '',
  372. 'raggedright' => '',
  373. # 'detailmenu' => '',
  374. );
  375. #%special_list_commands = (
  376. # 'table' => {},
  377. # 'vtable' => {},
  378. # 'ftable' => {},
  379. # 'itemize' => { 'bullet' => '' }
  380. # );
  381. $special_list_commands{'itemize'}->{ 'bullet'} = '';
  382. #
  383. # texinfo format to align attribute of paragraphs
  384. #
  385. %paragraph_style = (
  386. 'center' => 'center',
  387. 'flushleft' => 'left',
  388. 'flushright' => 'right',
  389. );
  390. # preformatted formats formatting
  391. if (get_conf('COMPLEX_FORMAT_IN_TABLE'))
  392. {
  393. foreach my $indented_format ('example', 'display', 'lisp')
  394. {
  395. $complex_format_map{"small$indented_format"}->{'begin'} = "<table><tr>$SMALL_EXAMPLE_INDENT_CELL<td>";
  396. $complex_format_map{$indented_format}->{'begin'} = "<table><tr>$EXAMPLE_INDENT_CELL<td>";
  397. $complex_format_map{$indented_format}->{'end'} = "</td></tr></table>\n";
  398. $complex_format_map{"small$indented_format"}->{'end'} = "</td></tr></table>\n";
  399. }
  400. foreach my $non_indented_formats ('format', 'smallformat')
  401. {
  402. $complex_format_map{$non_indented_formats}->{'begin'} = '';
  403. $complex_format_map{$non_indented_formats}->{'end'} = "\n";
  404. }
  405. }
  406. else
  407. {
  408. foreach my $format ('example', 'display', 'lisp', 'format')
  409. {
  410. $complex_format_map{$format}->{'begin'} = html_default_attribute_class('div', $format).">\n";
  411. $complex_format_map{"small$format"}->{'begin'} = html_default_attribute_class('div', "small$format").">\n";
  412. $complex_format_map{$format}->{'end'} = '</div>'."\n";
  413. $complex_format_map{"small$format"}->{'end'} = '</div>'."\n";
  414. }
  415. }
  416. foreach my $format ('menu', 'detailmenu', 'direntry')
  417. {
  418. $complex_format_map{$format} = { 'begin' => '' , 'end' => '',
  419. 'class' => 'menu-preformatted',
  420. };
  421. }
  422. $complex_format_map{'menu_comment'} = {
  423. 'begin' => "<tr><th colspan=\"3\" align=\"left\" valign=\"top\">",
  424. 'end' => "</th></tr>", 'class' => 'menu-comment',
  425. };
  426. %format_in_paragraph = (
  427. 'html' => 1,
  428. );
  429. # map mapping css specification to style
  430. %css_map =
  431. (
  432. "ul.$NO_BULLET_LIST_CLASS" => "$NO_BULLET_LIST_STYLE",
  433. 'pre.menu-comment' => "$MENU_PRE_STYLE",
  434. 'pre.menu-preformatted' => "$MENU_PRE_STYLE",
  435. 'a.summary-letter' => 'text-decoration: none',
  436. 'blockquote.smallquotation' => 'font-size: smaller',
  437. # 'pre.display' => 'font-family: inherit',
  438. # 'pre.smalldisplay' => 'font-family: inherit; font-size: smaller',
  439. 'pre.display' => 'font-family: serif',
  440. 'pre.smalldisplay' => 'font-family: serif; font-size: smaller',
  441. 'pre.smallexample' => 'font-size: smaller',
  442. 'span.sansserif' => 'font-family:sans-serif; font-weight:normal',
  443. 'span.roman' => 'font-family:serif; font-weight:normal',
  444. 'span.nocodebreak' => 'white-space:pre',
  445. 'span.nolinebreak' => 'white-space:pre'
  446. );
  447. $css_map{'pre.format'} = $css_map{'pre.display'};
  448. $css_map{'pre.smallformat'} = $css_map{'pre.smalldisplay'};
  449. $css_map{'pre.smalllisp'} = $css_map{'pre.smallexample'};
  450. foreach my $indented_format ('example', 'display', 'lisp')
  451. {
  452. $css_map{"div.$indented_format"} = 'margin-left: 3.2em';
  453. $css_map{"div.small$indented_format"} = 'margin-left: 3.2em';
  454. }
  455. # formatting functions
  456. $acronym_like = \&html_default_acronym_like;
  457. $anchor = \&html_default_anchor;
  458. $anchor_label = \&html_default_anchor_label;
  459. $begin_format_texi = \&html_default_begin_format_texi;
  460. $caption_shortcaption = \&html_default_caption_shortcaption;
  461. $caption_shortcaption_command = \&html_default_caption_shortcaption_command;
  462. $cartouche = \&html_default_cartouche;
  463. $cell = \&html_default_cell;
  464. $def = \&html_default_def;
  465. $def_item = \&html_default_def_item;
  466. $def_line = \&html_default_def_line;
  467. $element_label = \&html_default_element_label;
  468. $float = \&html_default_float;
  469. $foot_line_and_ref = \&html_default_foot_line_and_ref;
  470. $foot_section = \&html_default_foot_section;
  471. $format_list_item_texi = \&html_default_format_list_item_texi;
  472. $heading = \&t2h_default_heading;
  473. $heading_text = \&html_default_heading_text;
  474. $heading_text_preformatted = \&html_default_heading_text_preformatted;
  475. $image = \&html_default_image;
  476. $index_entry = \&html_default_index_entry;
  477. $index_entry_command = \&html_default_index_entry_command;
  478. $index_entry_label = \&html_default_index_entry_label;
  479. $index_letter = \&html_default_index_letter;
  480. $index_summary = \&html_default_index_summary;
  481. $insertcopying = \&html_default_insertcopying;
  482. $line_command = \&html_default_line_command;
  483. $list_item = \&html_default_list_item;
  484. $listoffloats = \&html_default_listoffloats;
  485. $listoffloats_entry = \&html_default_listoffloats_entry;
  486. $listoffloats_caption = \&html_default_listoffloats_caption;
  487. $listoffloats_float_style = \&html_default_listoffloats_float_style;
  488. $menu_command = \&html_default_menu_command;
  489. $menu_link = \&html_default_menu_link;
  490. $menu_description = \&html_default_menu_description;
  491. $misc_element_label = \&html_default_misc_element_label;
  492. $normal_text = \&html_default_normal_text;
  493. $paragraph = \&html_default_paragraph;
  494. $preformatted = \&html_default_preformatted;
  495. $print_index = \&html_default_print_index;
  496. $protect_text = \&xml_default_protect_text;
  497. $quotation = \&html_default_quotation;
  498. $sp = \&html_default_sp;
  499. $summary_letter = \&html_default_summary_letter;
  500. $tab_item_texi = \&html_default_tab_item_texi;
  501. $table_item = \&html_default_table_item;
  502. $table_line = \&html_default_table_line;
  503. $table_list = \&html_default_table_list;
  504. $raw = \&html_default_raw;
  505. $row = \&html_default_row;
  506. }
  507. # The functions
  508. sub html_default_initialize()
  509. {
  510. @html_default_multitable_stack = ();
  511. $html_default_title = undef;
  512. }
  513. # We have to do this dynamically because of internationalization and because
  514. # in body ENCODING_NAME could be used.
  515. sub html_default_bodytext()
  516. {
  517. # Set the default body text, inserted between <body ... >
  518. set_from_document('BODYTEXT', 'lang="' . get_conf('documentlanguage') . '" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"');
  519. }
  520. sub html_default_translate_names()
  521. {
  522. t2h_default_translate_names();
  523. %NAVIGATION_TEXT =
  524. (
  525. 'Top', gdt('Top'),
  526. 'Contents', gdt('Contents'),
  527. 'Overview', gdt('Overview'),
  528. 'Index', gdt('Index'),
  529. ' ', ' &nbsp; ',
  530. 'This', gdt('current'),
  531. 'Back', ' &lt; ',
  532. 'FastBack', ' &lt;&lt; ',
  533. 'Prev', gdt('Prev'),
  534. 'Up', gdt(' Up '),
  535. 'Next', gdt('Next'),
  536. 'NodeUp', gdt('Node up'),
  537. 'NodeNext', gdt('Next node'),
  538. 'NodePrev', gdt('Previous node'),
  539. 'NodeForward', gdt('Forward node'),
  540. 'NodeBack', gdt('Back node'),
  541. 'Forward', ' &gt; ',
  542. 'FastForward', ' &gt;&gt; ',
  543. 'About', ' ? ',
  544. 'First', ' |&lt; ',
  545. 'Last', ' &gt;| ',
  546. 'NextFile', gdt('Next file'),
  547. 'PrevFile', gdt('Previous file'),
  548. );
  549. }
  550. sub html_default_do_title()
  551. {
  552. $html_default_title = "$Texi2HTML::THISDOC{'fulltitle_simple_format'}";
  553. if ($html_default_title !~ /\S/)
  554. {
  555. $html_default_title = gdt('Untitled Document',{},{'simple_format' => 1});
  556. main::document_warn("Must specify a title with a title command or \@top");
  557. }
  558. }
  559. ########################################################################
  560. # Page formatting functions
  561. #
  562. ########################################################################
  563. # Layout for html for every sections
  564. #
  565. sub HTML_DEFAULT_print_section
  566. {
  567. my $fh = shift;
  568. my $first_in_page = shift;
  569. my $previous_is_top = shift;
  570. my $element = shift;
  571. my $buttons = \@SECTION_BUTTONS;
  572. my $nw = main::print_lines($fh);
  573. if ((get_conf('SPLIT') eq 'node') && get_conf('HEADERS'))
  574. {
  575. my $buttons = \@NODE_FOOTER_BUTTONS;
  576. &$print_foot_navigation($fh, $buttons, $DEFAULT_RULE,
  577. (!get_conf('WORDS_IN_PAGE') or (defined ($nw) and $nw >= get_conf('WORDS_IN_PAGE'))),
  578. $element);
  579. }
  580. }
  581. sub HTML_DEFAULT_one_section($$)
  582. {
  583. my $fh = shift;
  584. my $element = shift;
  585. main::print_lines($fh);
  586. print $fh "$DEFAULT_RULE\n";
  587. &$print_page_foot($fh);
  588. }
  589. ###################################################################
  590. # Layout of top-page I recommend that you use @ifnothtml, @ifhtml,
  591. # @html within the Top texinfo node to specify content of top-level
  592. # page.
  593. #
  594. sub HTML_DEFAULT_print_Top_footer($$$)
  595. {
  596. my $fh = shift;
  597. my $end_page = shift;
  598. my $element = shift;
  599. my $buttons = \@TOP_BUTTONS;
  600. my $rule = $DEFAULT_RULE;
  601. $rule = $BIG_RULE if (!$end_page);
  602. #print STDERR "end_page: $end_page\n";
  603. &$print_foot_navigation($fh, $buttons, $rule,
  604. ($end_page and (get_conf('HEADERS') or (get_conf('SPLIT') and get_conf('SPLIT') ne 'node'))), $element);
  605. if ($end_page)
  606. {
  607. &$print_page_foot($fh);
  608. }
  609. }
  610. sub HTML_DEFAULT_print_Top($$$)
  611. {
  612. my $fh = shift;
  613. my $has_top_heading = shift;
  614. my $element = shift;
  615. main::print_lines($fh, $Texi2HTML::THIS_SECTION);
  616. }
  617. ###################################################################
  618. # Layout of Toc, Overview, and Footnotes pages
  619. # By default, we use "normal" layout
  620. # Texi2HTML::HREF of Next, Prev, Up, Forward, Back, etc are not defined
  621. # use: my $buttons = [...] to redefine navigation buttons
  622. sub HTML_DEFAULT_print_Footnotes
  623. {
  624. return &$print_misc(@_);
  625. }
  626. sub HTML_DEFAULT_print_misc_header
  627. {
  628. my $fh = shift;
  629. my $buttons = shift;
  630. my $new_file = shift;
  631. my $misc_page = shift;
  632. &$print_page_head($fh) if ($new_file);
  633. print $fh "".&$misc_element_label($misc_pages_targets{$misc_page}, $misc_page);
  634. &$print_head_navigation($fh, $buttons) if ($new_file or get_conf('HEADERS'));
  635. }
  636. sub HTML_DEFAULT_print_misc_footer
  637. {
  638. my $fh = shift;
  639. my $buttons = shift;
  640. my $new_file = shift;
  641. &$print_foot_navigation($fh, $buttons, $DEFAULT_RULE,
  642. ($new_file and (get_conf('HEADERS') or (get_conf('SPLIT') and get_conf('SPLIT') ne 'node'))), undef);
  643. if ($new_file)
  644. {
  645. &$print_page_foot($fh);
  646. }
  647. }
  648. ##################################################################
  649. # section_footer is only called if SPLIT eq 'section'
  650. # section_footer: after print_section of last section, before print_page_foot
  651. #
  652. sub HTML_DEFAULT_print_section_footer
  653. {
  654. my $fh = shift;
  655. my $element = shift;
  656. my $buttons = \@SECTION_FOOTER_BUTTONS;
  657. &$print_foot_navigation($fh, $buttons, $DEFAULT_RULE, 1, $element);
  658. }
  659. ###################################################################
  660. # chapter_header and chapter_footer are only called if
  661. # SPLIT eq 'chapter'
  662. # chapter_header: after print_page_head, before print_section
  663. # chapter_footer: after print_section of last section, before print_page_foot
  664. #
  665. # If you want to get rid of navigation stuff after each section,
  666. # redefine print_section such that it does not call print_navigation,
  667. # and put print_navigation into print_chapter_header
  668. sub HTML_DEFAULT_print_chapter_header($$)
  669. {
  670. my $fh = shift;
  671. my $element = shift;
  672. # nothing to do there, by default, the navigation panel
  673. # is the element navigation panel
  674. if (! get_conf('HEADERS'))
  675. { # in this case print_navigation is called here.
  676. my $buttons = \@CHAPTER_BUTTONS;
  677. &$print_head_navigation($fh, $buttons);
  678. print $fh "\n$DEFAULT_RULE\n" unless (get_conf('VERTICAL_HEAD_NAVIGATION'));
  679. }
  680. }
  681. sub HTML_DEFAULT_print_chapter_footer($$)
  682. {
  683. my $fh = shift;
  684. my $element = shift;
  685. my $buttons = \@CHAPTER_BUTTONS;
  686. &$print_foot_navigation($fh, $buttons, $DEFAULT_RULE, 1, $element);
  687. }
  688. sub HTML_DEFAULT_print_section_header($$)
  689. {
  690. my $fh = shift;
  691. my $element = shift;
  692. # nothing to do there, by default
  693. if (! get_conf('HEADERS'))
  694. { # in this case print_navigation is called here.
  695. my $buttons = \@SECTION_BUTTONS;
  696. &$print_head_navigation($fh, $buttons);
  697. }
  698. }
  699. ###################################################################
  700. # Layout of standard header and footer
  701. #
  702. sub HTML_DEFAULT_print_page_head($)
  703. {
  704. my $fh = shift;
  705. my $longtitle = $html_default_title;
  706. $longtitle .= ": $Texi2HTML::SIMPLE_TEXT{'This'}" if (defined ($Texi2HTML::SIMPLE_TEXT{'This'}) and ($Texi2HTML::SIMPLE_TEXT{'This'} !~ /^\s*$/) and get_conf('SPLIT') and ($html_default_title ne $Texi2HTML::SIMPLE_TEXT{'This'}));
  707. my $description = get_conf('documentdescription');
  708. $description = $longtitle if (!defined($description));
  709. $description = "<meta name=\"description\" content=\"$description\">" if
  710. ($description ne '');
  711. my $encoding = '';
  712. $encoding = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".get_conf('ENCODING_NAME')."\">" if (defined(get_conf('ENCODING_NAME')) and (get_conf('ENCODING_NAME') ne ''));
  713. my $date = '';
  714. my $today = get_conf('today');
  715. $today = '' if (!defined($today));
  716. $date = "\n<meta name=\"date\" content=\"$today\">" if (get_conf('DATE_IN_HEADER') and $today ne '');
  717. my $links = '';
  718. if (get_conf('USE_LINKS'))
  719. {
  720. foreach my $link (@LINKS_BUTTONS)
  721. {
  722. #print STDERR "$link!!$Texi2HTML::HREF{$link}\n";
  723. if (defined($Texi2HTML::HREF{$link}) and $Texi2HTML::HREF{$link} ne '')
  724. {
  725. my $title = '';
  726. $title = " title=\"$Texi2HTML::SIMPLE_TEXT{$link}\"" if (defined($Texi2HTML::SIMPLE_TEXT{$link}));
  727. my $rel = '';
  728. $rel = " rel=\"$BUTTONS_REL{$link}\"" if (defined($BUTTONS_REL{$link}));
  729. $links .= "<link href=\"$Texi2HTML::HREF{$link}\"${rel}${title}>\n";
  730. }
  731. }
  732. }
  733. my $css_text = '';
  734. $css_text = get_conf('CSS_LINES') if (defined(get_conf('CSS_LINES')));
  735. my $doctype = get_conf('DOCTYPE');
  736. my $bodytext = get_conf('BODYTEXT');
  737. print $fh <<EOT;
  738. $doctype
  739. <html>
  740. $Texi2HTML::THISDOC{'copying_comment'}<!-- Created by $Texi2HTML::THISDOC{'program_and_version'}, $Texi2HTML::THISDOC{'program_homepage'} -->
  741. <head>
  742. <title>$longtitle</title>
  743. $description
  744. <meta name="keywords" content="$longtitle">
  745. <meta name="resource-type" content="document">
  746. <meta name="distribution" content="global">
  747. <meta name="Generator" content="$Texi2HTML::THISDOC{'program'}">$date
  748. $encoding
  749. ${links}$css_text
  750. $EXTRA_HEAD
  751. </head>
  752. <body $bodytext>
  753. $AFTER_BODY_OPEN
  754. EOT
  755. }
  756. sub HTML_DEFAULT_end_section($$$)
  757. {
  758. my $fh = shift;
  759. my $misc_or_top_and_section_separation = shift;
  760. my $element = shift;
  761. if ($misc_or_top_and_section_separation)
  762. {
  763. my $rule = $BIG_RULE;
  764. # in that case we are almost surely at the end of the document
  765. $rule = $DEFAULT_RULE if (! get_conf('MONOLITHIC'));
  766. &$print_foot_navigation($fh, undef, $rule, 0, $element, 1);
  767. }
  768. else
  769. {
  770. print $fh "$DEFAULT_RULE\n";
  771. }
  772. }
  773. sub HTML_DEFAULT_print_page_foot($)
  774. {
  775. my $fh = shift;
  776. my $program_text = '';
  777. if (get_conf('PROGRAM_NAME_IN_FOOTER'))
  778. {
  779. my $program_string = &$program_string();
  780. $program_text = " <font size=\"-1\">
  781. $program_string
  782. </font>
  783. <br>";
  784. }
  785. print $fh <<EOT;
  786. <p>
  787. $program_text
  788. $PRE_BODY_CLOSE
  789. </p>
  790. </body>
  791. </html>
  792. EOT
  793. }
  794. ###################################################################
  795. # Layout of navigation panel
  796. sub HTML_DEFAULT_print_head_navigation($$$$$)
  797. {
  798. my $fh = shift;
  799. my $buttons = shift;
  800. my $first_in_page = shift;
  801. my $previous_is_top = shift;
  802. my $element = shift;
  803. my $result = '';
  804. if (get_conf('VERTICAL_HEAD_NAVIGATION'))
  805. {
  806. $result .= <<EOT;
  807. <table border="0" cellpadding="0" cellspacing="0">
  808. <tr valign="top">
  809. <td align="left">
  810. EOT
  811. }
  812. $result .= &$print_navigation($buttons, get_conf('VERTICAL_HEAD_NAVIGATION'));
  813. if (get_conf('VERTICAL_HEAD_NAVIGATION'))
  814. {
  815. $result .= <<EOT;
  816. </td>
  817. <td align="left">
  818. EOT
  819. }
  820. elsif (get_conf('SPLIT') eq 'node')
  821. {
  822. $result .= "$DEFAULT_RULE\n";
  823. }
  824. print $fh $result if (defined($fh));
  825. return $result;
  826. }
  827. sub HTML_DEFAULT_print_foot_navigation($$$$$;$)
  828. {
  829. my $fh = shift;
  830. my $buttons = shift;
  831. my $rule = shift;
  832. my $print_navigation_panel = shift;
  833. my $element = shift;
  834. # set if called between sections and top or between sections and misc.
  835. # could also be the last element
  836. my $maybe_in_page = shift;
  837. $rule = '' if (!defined($rule));
  838. $print_navigation_panel = 1 if (!defined($print_navigation_panel)
  839. and defined($buttons));
  840. # avoid the rule if at the end of a page and there is nothing below
  841. $rule = '' if (!get_conf('PROGRAM_NAME_IN_FOOTER') and !$print_navigation_panel and !$maybe_in_page);
  842. if (get_conf('VERTICAL_HEAD_NAVIGATION'))
  843. {
  844. print $fh <<EOT;
  845. </td>
  846. </tr>
  847. </table>
  848. EOT
  849. }
  850. print $fh "$rule\n" if ($rule ne '');
  851. print $fh "".&$print_navigation($buttons) if ($print_navigation_panel);
  852. }
  853. ######################################################################
  854. # navigation panel
  855. #
  856. # how to create IMG tag
  857. sub HTML_DEFAULT_button_icon_img
  858. {
  859. my $button = shift;
  860. my $icon = shift;
  861. my $name = shift;
  862. return '' if (!defined($icon));
  863. $button = "" if (!defined ($button));
  864. $name = '' if (!defined($name));
  865. my $alt = '';
  866. if ($name ne '')
  867. {
  868. if ($button ne '')
  869. {
  870. $alt = "$button: $name";
  871. }
  872. else
  873. {
  874. $alt = $name;
  875. }
  876. }
  877. else
  878. {
  879. $alt = $button;
  880. }
  881. return qq{<img src="$icon" border="0" alt="$alt" align="middle">};
  882. }
  883. sub HTML_DEFAULT_button_formatting($$)
  884. {
  885. my $button = shift;
  886. my $vertical = shift;
  887. my ($active, $passive);
  888. if (ref($button) eq 'CODE')
  889. {
  890. $active = &$button($vertical);
  891. }
  892. elsif (ref($button) eq 'SCALAR')
  893. {
  894. $active = "$$button" if defined($$button);
  895. }
  896. elsif (ref($button) eq 'ARRAY')
  897. {
  898. my $text = $button->[1];
  899. my $button_href = $button->[0];
  900. # verify that $button_href is simple text and text is a reference
  901. if (defined($button_href) and !ref($button_href)
  902. and defined($text) and (ref($text) eq 'SCALAR') and defined($$text))
  903. { # use given text
  904. if ($Texi2HTML::HREF{$button_href})
  905. {
  906. my $anchor_attributes = '';
  907. if (get_conf('USE_ACCESSKEY') and (defined($BUTTONS_ACCESSKEY{$button_href})) and ($BUTTONS_ACCESSKEY{$button_href} ne ''))
  908. {
  909. $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$button_href}\"";
  910. }
  911. if (get_conf('USE_REL_REV') and (defined($BUTTONS_REL{$button_href})) and ($BUTTONS_REL{$button_href} ne ''))
  912. {
  913. $anchor_attributes .= " rel=\"$BUTTONS_REL{$button_href}\"";
  914. }
  915. $active = "" .
  916. &$anchor('',
  917. $Texi2HTML::HREF{$button_href},
  918. $$text,
  919. $anchor_attributes
  920. );
  921. }
  922. else
  923. {
  924. $passive = $$text;
  925. }
  926. }
  927. elsif (defined($button_href) and !ref($button_href)
  928. and defined($text) and (ref($text) eq 'CODE'))
  929. {
  930. $active = &$text($button_href);
  931. }
  932. }
  933. elsif ($button eq ' ')
  934. { # handle space button
  935. $active =
  936. (get_conf('ICONS') && $ACTIVE_ICONS{' '}) ?
  937. &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{' '}) :
  938. $NAVIGATION_TEXT{' '};
  939. #next;
  940. }
  941. elsif ($Texi2HTML::HREF{$button})
  942. { # button is active
  943. my $btitle = $BUTTONS_GOTO{$button} ?
  944. 'title="' . $BUTTONS_GOTO{$button} . '"' : '';
  945. if (get_conf('USE_ACCESSKEY') and (defined($BUTTONS_ACCESSKEY{$button})) and ($BUTTONS_ACCESSKEY{$button} ne ''))
  946. {
  947. $btitle .= " accesskey=\"$BUTTONS_ACCESSKEY{$button}\"";
  948. }
  949. if (get_conf('USE_REL_REV') and (defined($BUTTONS_REL{$button})) and ($BUTTONS_REL{$button} ne ''))
  950. {
  951. $btitle .= " rel=\"$BUTTONS_REL{$button}\"";
  952. }
  953. if (get_conf('ICONS') && $ACTIVE_ICONS{$button})
  954. { # use icon
  955. $active = '' .
  956. &$anchor('',
  957. $Texi2HTML::HREF{$button},
  958. &$button_icon_img($BUTTONS_NAME{$button},
  959. $ACTIVE_ICONS{$button},
  960. $Texi2HTML::SIMPLE_TEXT{$button}),
  961. $btitle
  962. );
  963. }
  964. else
  965. { # use text
  966. $active =
  967. '[' .
  968. &$anchor('',
  969. $Texi2HTML::HREF{$button},
  970. $NAVIGATION_TEXT{$button},
  971. $btitle
  972. ) .
  973. ']';
  974. }
  975. }
  976. else
  977. { # button is passive
  978. $passive =
  979. get_conf('ICONS') && $PASSIVE_ICONS{$button} ?
  980. &$button_icon_img($BUTTONS_NAME{$button},
  981. $PASSIVE_ICONS{$button},
  982. $Texi2HTML::SIMPLE_TEXT{$button}) :
  983. "[" . $NAVIGATION_TEXT{$button} . "]";
  984. }
  985. return ($active, $passive);
  986. }
  987. my %html_default_node_directions;
  988. foreach my $node_directions ('NodeNext', 'NodePrev', 'NodeUp')
  989. {
  990. $html_default_node_directions{$node_directions} = 1;
  991. }
  992. sub HTML_DEFAULT_print_navigation($;$)
  993. {
  994. my $buttons = shift;
  995. my $vertical = shift;
  996. my $first_button = 1;
  997. my $result = '';
  998. if (get_conf('HEADER_IN_TABLE'))
  999. {
  1000. $result .= html_default_attribute_class('table', 'header').' cellpadding="1" cellspacing="1" border="0">'."\n";
  1001. $result .= "<tr>" unless $vertical;
  1002. }
  1003. else
  1004. {
  1005. $result .= html_default_attribute_class('div', 'header').">\n<p>\n";
  1006. }
  1007. for my $button (@$buttons)
  1008. {
  1009. if (get_conf('HEADER_IN_TABLE'))
  1010. {
  1011. $result .= qq{<tr valign="top" align="left">\n} if $vertical;
  1012. $result .= qq{<td valign="middle" align="left">};
  1013. }
  1014. my $direction;
  1015. if (ref($button) eq 'ARRAY' and defined($button->[0]) and !ref($button->[0]))
  1016. {
  1017. $direction = $button->[0];
  1018. }
  1019. elsif (defined($button) and !ref($button))
  1020. {
  1021. $direction = $button;
  1022. }
  1023. my ($active, $passive) = &$button_formatting($button, $vertical);
  1024. if (get_conf('HEADER_IN_TABLE'))
  1025. {
  1026. if (defined($active))
  1027. {
  1028. $first_button = 0 if ($first_button);
  1029. $result .= $active;
  1030. }
  1031. elsif (defined($passive))
  1032. {
  1033. $first_button = 0 if ($first_button);
  1034. $result .= $passive;
  1035. }
  1036. $result .= "</td>\n";
  1037. $result .= "</tr>\n" if $vertical;
  1038. }
  1039. elsif (defined($active))
  1040. { # only active buttons are print out when not in table
  1041. if (defined($direction) and $html_default_node_directions{$direction} and !$first_button)
  1042. {
  1043. $active = ', ' .$active;
  1044. }
  1045. $result .= $active;
  1046. $first_button = 0 if ($first_button);
  1047. }
  1048. }
  1049. if (get_conf('HEADER_IN_TABLE'))
  1050. {
  1051. $result .= "</tr>" unless $vertical;
  1052. $result .= "</table>\n";
  1053. }
  1054. else
  1055. {
  1056. $result .= "</p>\n</div>\n";
  1057. }
  1058. return $result;
  1059. }
  1060. sub html_default_node_direction($)
  1061. {
  1062. my $direction = shift;
  1063. my $result = undef;
  1064. if ($Texi2HTML::HREF{$direction} and $Texi2HTML::NODE{$direction})
  1065. {
  1066. my $anchor_attributes = '';
  1067. if (get_conf('USE_ACCESSKEY') and (defined($BUTTONS_ACCESSKEY{$direction})) and ($BUTTONS_ACCESSKEY{$direction} ne ''))
  1068. {
  1069. $anchor_attributes = "accesskey=\"$BUTTONS_ACCESSKEY{$direction}\"";
  1070. }
  1071. if (get_conf('USE_REL_REV') and (defined($BUTTONS_REL{$direction})) and ($BUTTONS_REL{$direction} ne ''))
  1072. {
  1073. $anchor_attributes .= " rel=\"$BUTTONS_REL{$direction}\"";
  1074. }
  1075. my $anchor = &$anchor('',
  1076. $Texi2HTML::HREF{$direction},
  1077. $Texi2HTML::NODE{$direction},
  1078. $anchor_attributes
  1079. )
  1080. ;
  1081. # i18n
  1082. $result = "$BUTTONS_TEXT{$direction}: $anchor";
  1083. }
  1084. return $result;
  1085. }
  1086. ######################################################################
  1087. # Frames: this is from "Richard Y. Kim" <ryk@coho.net>
  1088. # Should be improved to be more conforming to other _print* functions
  1089. # toc_file and main_file passed as args are relative to the texinfo manual
  1090. # location, and therefore are not used.
  1091. sub HTML_DEFAULT_print_frame
  1092. {
  1093. my $fh = shift;
  1094. my $toc_file = shift;
  1095. my $main_file = shift;
  1096. $main_file = $Texi2HTML::THISDOC{'filename'}->{'top'};
  1097. $toc_file = $Texi2HTML::THISDOC{'filename'}->{'toc_frame'};
  1098. my $doctype = get_conf('FRAMESET_DOCTYPE');
  1099. print $fh <<EOT;
  1100. $doctype
  1101. <html>
  1102. <head><title>$Texi2HTML::THISDOC{'fulltitle'}</title></head>
  1103. <frameset cols="140,*">
  1104. <frame name="toc" src="$toc_file">
  1105. <frame name="main" src="$main_file">
  1106. </frameset>
  1107. </html>
  1108. EOT
  1109. }
  1110. sub HTML_DEFAULT_print_toc_frame
  1111. {
  1112. my $fh = shift;
  1113. my $stoc_lines = shift;
  1114. &$print_page_head($fh);
  1115. print $fh <<EOT;
  1116. <h2>Content</h2>
  1117. EOT
  1118. print $fh map {s/\bhref=/target="main" href=/; $_;} @$stoc_lines;
  1119. print $fh "</body></html>\n";
  1120. }
  1121. ######################################################################
  1122. # About page
  1123. #
  1124. sub HTML_DEFAULT_about_body
  1125. {
  1126. #return undef if (!get_conf('HEADER_IN_TABLE'));
  1127. my $about = "<p>\n";
  1128. if (ref($PRE_ABOUT) eq 'CODE')
  1129. {
  1130. $about .= &$PRE_ABOUT();
  1131. }
  1132. else
  1133. {
  1134. $about .= $PRE_ABOUT;
  1135. }
  1136. $about .= <<EOT;
  1137. </p>
  1138. <p>
  1139. EOT
  1140. $about .= gdt(' The buttons in the navigation panels have the following meaning:') . "\n";
  1141. $about .= <<EOT;
  1142. </p>
  1143. <table border="1">
  1144. <tr>
  1145. EOT
  1146. $about .= ' <th> ' . gdt('Button') . " </th>\n" .
  1147. ' <th> ' . gdt('Name') . " </th>\n" .
  1148. ' <th> ' . gdt('Go to') . " </th>\n" .
  1149. ' <th> ' . gdt('From 1.2.3 go to') . "</th>\n" . " </tr>\n";
  1150. for my $button (@SECTION_BUTTONS)
  1151. {
  1152. next if $button eq ' ' || ref($button) eq 'CODE' || ref($button) eq 'SCALAR' || ref($button) eq 'ARRAY';
  1153. $about .= " <tr>\n <td align=\"center\">";
  1154. $about .=
  1155. (get_conf('ICONS') && $ACTIVE_ICONS{$button} ?
  1156. &$button_icon_img($BUTTONS_NAME{$button}, $ACTIVE_ICONS{$button}) :
  1157. ' [' . $NAVIGATION_TEXT{$button} . '] ');
  1158. $about .= "</td>\n";
  1159. $about .= <<EOT;
  1160. <td align="center">$BUTTONS_NAME{$button}</td>
  1161. <td>$BUTTONS_GOTO{$button}</td>
  1162. <td>$BUTTONS_EXAMPLE{$button}</td>
  1163. </tr>
  1164. EOT
  1165. }
  1166. $about .= <<EOT;
  1167. </table>
  1168. <p>
  1169. EOT
  1170. $about .= gdt(' where the @strong{ Example } assumes that the current position is at @strong{ Subsubsection One-Two-Three } of a document of the following structure:') . "\n";
  1171. # where the <strong> Example </strong> assumes that the current position
  1172. # is at <strong> Subsubsection One-Two-Three </strong> of a document of
  1173. # the following structure:
  1174. $about .= <<EOT;
  1175. </p>
  1176. <ul>
  1177. EOT
  1178. $about .= ' <li> 1. ' . gdt('Section One') . "\n" .
  1179. " <ul>\n" .
  1180. ' <li>1.1 ' . gdt('Subsection One-One') . "\n";
  1181. $about .= <<EOT;
  1182. <ul>
  1183. <li>...</li>
  1184. </ul>
  1185. </li>
  1186. EOT
  1187. $about .= ' <li>1.2 ' . gdt('Subsection One-Two') . "\n" .
  1188. " <ul>\n" .
  1189. ' <li>1.2.1 ' . gdt('Subsubsection One-Two-One') . "</li>\n" .
  1190. ' <li>1.2.2 ' . gdt('Subsubsection One-Two-Two') . "</li>\n" .
  1191. ' <li>1.2.3 ' . gdt('Subsubsection One-Two-Three') . " &nbsp; &nbsp;\n"
  1192. .
  1193. ' <strong>&lt;== ' . gdt('Current Position') . " </strong></li>\n" .
  1194. ' <li>1.2.4 ' . gdt('Subsubsection One-Two-Four') . "</li>\n" .
  1195. " </ul>\n" .
  1196. " </li>\n" .
  1197. ' <li>1.3 ' . gdt('Subsection One-Three') . "\n";
  1198. $about .= <<EOT;
  1199. <ul>
  1200. <li>...</li>
  1201. </ul>
  1202. </li>
  1203. EOT
  1204. $about .= ' <li>1.4 ' . gdt('Subsection One-Four') . "</li>\n";
  1205. $about .= <<EOT;
  1206. </ul>
  1207. </li>
  1208. </ul>
  1209. $AFTER_ABOUT
  1210. EOT
  1211. return $about;
  1212. }
  1213. sub HTML_DEFAULT_print_redirection_page()
  1214. {
  1215. #my $fh = shift;
  1216. my $longtitle = $html_default_title;
  1217. $longtitle .= ": $Texi2HTML::SIMPLE_TEXT{'This'}" if (defined ($Texi2HTML::SIMPLE_TEXT{'This'}) and ($Texi2HTML::SIMPLE_TEXT{'This'} !~ /^\s*$/) and ($html_default_title ne $Texi2HTML::SIMPLE_TEXT{'This'}));
  1218. my $description = get_conf('documentdescription');
  1219. $description = $longtitle if (!defined($description));
  1220. my $encoding = '';
  1221. $encoding = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".get_conf('ENCODING_NAME')."\">" if (defined(get_conf('ENCODING_NAME')) and (get_conf('ENCODING_NAME') ne ''));
  1222. my $href = &$anchor('', $Texi2HTML::HREF{'This'}, $Texi2HTML::NAME{'This'});
  1223. my $string = gdt('The node you are looking for is at {href}.',
  1224. { 'href' => $href });
  1225. my $doctype = get_conf('DOCTYPE');
  1226. my $css_text = '';
  1227. $css_text = get_conf('CSS_LINES') if (defined(get_conf('CSS_LINES')));
  1228. my $today = get_conf('today');
  1229. my $bodytext = get_conf('BODYTEXT');
  1230. my $result = <<EOT;
  1231. $doctype
  1232. <html>
  1233. <!-- Created by $Texi2HTML::THISDOC{'program_and_version'}, $Texi2HTML::THISDOC{'program_homepage'} -->
  1234. <!-- This file redirects to the location of a node or anchor -->
  1235. <head>
  1236. <title>$longtitle</title>
  1237. <meta name="description" content="$description">
  1238. <meta name="keywords" content="$longtitle">
  1239. <meta name="resource-type" content="document">
  1240. <meta name="distribution" content="global">
  1241. <meta name="Generator" content="$Texi2HTML::THISDOC{'program'}">
  1242. $encoding
  1243. $css_text
  1244. <meta http-equiv="Refresh" content="2; url=$Texi2HTML::HREF{'This'}">
  1245. $EXTRA_HEAD
  1246. </head>
  1247. <body $bodytext>
  1248. $AFTER_BODY_OPEN
  1249. <p>$string</p>
  1250. </body>
  1251. EOT
  1252. return $result;
  1253. }
  1254. sub html_default_uref($$)
  1255. {
  1256. shift;
  1257. my $args = shift;
  1258. my $url = shift @$args;
  1259. my $text = shift @$args;
  1260. my $replacement = shift @$args;
  1261. $url = main::normalise_space($url);
  1262. $replacement = '' if (!defined($replacement));
  1263. $replacement = main::normalise_space($replacement);
  1264. $text = '' if (!defined($text));
  1265. $text = main::normalise_space($text);
  1266. $text = $replacement if ($replacement ne '');
  1267. $text = $url unless ($text ne '');
  1268. return $text if ($url eq '');
  1269. return &$anchor('', $url, $text);
  1270. }
  1271. sub html_default_math($$)
  1272. {
  1273. shift;
  1274. my $args = shift;
  1275. my $text = shift @$args;
  1276. return "<em>$text</em>";
  1277. }
  1278. sub html_default_email($$)
  1279. {
  1280. my $command = shift;
  1281. my $args = shift;
  1282. my $mail = shift @$args;
  1283. my $text = shift @$args;
  1284. $mail = main::normalise_space($mail);
  1285. $text = $mail unless (defined($text) and ($text ne ''));
  1286. $text = main::normalise_space($text);
  1287. return $text if ($mail eq '');
  1288. return &$anchor('', "mailto:$mail", $text);
  1289. }
  1290. sub html_default_attribute_class($$)
  1291. {
  1292. my $element = shift;
  1293. my $class = shift;
  1294. return "<$element" if (!defined($class) or $class eq '' or get_conf('NO_CSS'));
  1295. my $style = '';
  1296. if (get_conf('INLINE_CSS_STYLE') and defined($css_map{"$element.$class"}))
  1297. {
  1298. $style = ' style="'.$css_map{"$element.$class"}.'"';
  1299. }
  1300. return "<$element class=\"$class\"$style";
  1301. }
  1302. # this is called each time a format begins. Here it is used to keep a
  1303. # record of the multitables to have a faithful count of the cell nr.
  1304. sub html_default_begin_format_texi($$$)
  1305. {
  1306. my $command = shift;
  1307. my $line = shift;
  1308. my $state = shift;
  1309. # first array element is the number of cell in a row
  1310. # second is the number of paragraphs in a cell
  1311. push (@html_default_multitable_stack, [-1,-1]) if ($command eq 'multitable');
  1312. return $line;
  1313. }
  1314. sub html_default_caption_shortcaption($)
  1315. {
  1316. my $float = shift;
  1317. my $caption_lines;
  1318. my $shortcaption_lines;
  1319. my $style = $float->{'style_texi'};
  1320. if (defined($float->{'nr'}))
  1321. {
  1322. my $nr = $float->{'nr'};
  1323. if ($style ne '')
  1324. {
  1325. $style = gdt('{style} {number}', { 'style' => $style, 'number' => $nr});
  1326. }
  1327. else
  1328. {
  1329. $style = $nr;
  1330. }
  1331. }
  1332. if (defined($float->{'caption_texi'}))
  1333. {
  1334. @$caption_lines = @{$float->{'caption_texi'}};
  1335. $caption_lines->[0] =~ s/^\s*//;
  1336. if (defined($style))
  1337. {
  1338. $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . gdt('{style}: {caption_first_line}', { 'style' => $style, 'caption_first_line' => $caption_lines->[0] });
  1339. }
  1340. else
  1341. {
  1342. $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $caption_lines->[0];
  1343. }
  1344. push @$caption_lines, "}\n";
  1345. }
  1346. elsif (defined($style))
  1347. {
  1348. $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $style . '}' . "\n";
  1349. }
  1350. if (defined($float->{'shortcaption_texi'}))
  1351. {
  1352. @$shortcaption_lines = @{$float->{'shortcaption_texi'}};
  1353. if (defined($style))
  1354. {
  1355. $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' . gdt('{style}: {shortcaption_first_line}', { 'style' => $style, 'shortcaption_first_line' => $shortcaption_lines->[0] });
  1356. }
  1357. else
  1358. {
  1359. $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $shortcaption_lines->[0];
  1360. }
  1361. push @$shortcaption_lines, "}\n";
  1362. }
  1363. elsif (defined($style))
  1364. {
  1365. $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $style . '}' . "\n";
  1366. }
  1367. return ($caption_lines, $shortcaption_lines);
  1368. }
  1369. # everything is done in &$float
  1370. sub html_default_caption_shortcaption_command($$$$)
  1371. {
  1372. my $command = shift;
  1373. my $text = shift;
  1374. my $texi_lines = shift;
  1375. my $float_element = shift;
  1376. return '';
  1377. }
  1378. sub html_default_float($$$$$)
  1379. {
  1380. my $text = shift;
  1381. my $float = shift;
  1382. my $caption = shift;
  1383. my $shortcaption = shift;
  1384. my $label = '';
  1385. if (exists($float->{'id'}))
  1386. {
  1387. $label = &$anchor($float->{'id'});
  1388. }
  1389. my $caption_text = '';
  1390. if (defined($float->{'caption_texi'}))
  1391. {
  1392. $caption_text = $caption;
  1393. }
  1394. elsif (defined($float->{'shortcaption_texi'}))
  1395. {
  1396. $caption_text = $shortcaption;
  1397. }
  1398. elsif (defined($caption))
  1399. {
  1400. $caption_text = $caption;
  1401. }
  1402. return html_default_attribute_class('div','float'). '>' . "$label\n" . $text . '</div>' . $caption_text;
  1403. }
  1404. sub html_default_listoffloats_float_style($$)
  1405. {
  1406. my $style_texi = shift;
  1407. my $float = shift;
  1408. my $style = $float->{'style_texi'};
  1409. #print STDERR "listoffloat/float style mismatch $style_texi $style\n" if ($style_texi ne $style);
  1410. if (defined($float->{'nr'}))
  1411. {
  1412. my $nr = $float->{'nr'};
  1413. if ($style ne '')
  1414. {
  1415. $style = gdt('{style} {number}', { 'style' => $style, 'number' => $nr});
  1416. }
  1417. else
  1418. {
  1419. $style = $nr;
  1420. }
  1421. }
  1422. return $style;
  1423. }
  1424. sub html_default_listoffloats_caption($)
  1425. {
  1426. my $float = shift;
  1427. if (defined($float->{'shortcaption_texi'}))
  1428. {
  1429. return ([ @{$float->{'shortcaption_texi'}} ], 'shortcaption');
  1430. }
  1431. elsif (defined($float->{'caption_texi'}))
  1432. {
  1433. return ([ @{$float->{'caption_texi'}} ], 'caption');
  1434. }
  1435. return ([ ], undef);
  1436. }
  1437. sub html_default_listoffloats_entry($$$$)
  1438. {
  1439. my $style_texi = shift;
  1440. my $float = shift;
  1441. my $float_style = shift;
  1442. my $caption = shift;
  1443. my $href = shift;
  1444. return '<dt>' . &$anchor('', $href, $float_style) . '</dt><dd>' . $caption
  1445. . '</dd>' . "\n";
  1446. }
  1447. sub html_default_listoffloats($$$)
  1448. {
  1449. my $style_texi = shift;
  1450. my $style = shift;
  1451. my $float_entries = shift;
  1452. my $result = html_default_attribute_class('dl', 'listoffloats').">\n" ;
  1453. foreach my $float_entry (@$float_entries)
  1454. {
  1455. $result .= $float_entry;
  1456. }
  1457. return $result . "</dl>\n";
  1458. }
  1459. sub html_default_insertcopying($$$)
  1460. {
  1461. my $text = shift;
  1462. my $comment = shift;
  1463. my $simple_text = shift;
  1464. return $text;
  1465. }
  1466. sub html_default_protect_space_codebreak($$$$$)
  1467. {
  1468. my $text = shift;
  1469. my $in_raw_text = shift; # remove_texi
  1470. my $in_preformatted = shift;
  1471. my $in_code = shift;
  1472. my $style_stack = shift;
  1473. return $text if ($in_preformatted or $in_raw_text);
  1474. my $in_w = 1 if (in_cmd($style_stack, 'w'));
  1475. if ($in_w or ($in_code and get_conf('allowcodebreaks') eq 'false'))
  1476. {
  1477. my $class = 'nolinebreak';
  1478. $class = 'nocodebreak' if ($in_code and get_conf('allowcodebreaks') eq 'false');
  1479. my $open = html_default_attribute_class('span', $class).'>';
  1480. # protect spaces in the html leading attribute in case we are in 'w'
  1481. $open =~ s/ /\x{1F}/g if ($in_w);
  1482. $text =~ s/(\S*[_-]\S*)/${open}$1<\/span>/g;
  1483. }
  1484. if ($in_w)
  1485. {
  1486. $text .= '&nbsp;' if (chomp($text));
  1487. # protect spaces within text
  1488. $text =~ s/ /&nbsp;/g;
  1489. # revert protected spaces in leading html attribute
  1490. $text =~ s/\x{1F}/ /g;
  1491. }
  1492. return $text;
  1493. }
  1494. sub html_default_normal_text($$$$$$$;$)
  1495. {
  1496. my @initial_args = @_;
  1497. my $text = shift;
  1498. my $in_raw_text = shift; # remove_texi
  1499. my $in_preformatted = shift;
  1500. my $in_code = shift;
  1501. my $in_math = shift;
  1502. my $in_simple = shift;
  1503. my $style_stack = shift;
  1504. my $state = shift;
  1505. # like utf8.pm
  1506. if (get_conf('ENABLE_ENCODING') and !get_conf('ENABLE_ENCODING_USE_ENTITY') and defined(get_conf('ENCODING_NAME')) and get_conf('ENCODING_NAME') eq 'utf-8')
  1507. {
  1508. my $result = &t2h_utf8_normal_text(@initial_args);
  1509. $result = html_default_protect_space_codebreak($result, $in_raw_text, $in_preformatted, $in_code, $style_stack);
  1510. return $result;
  1511. }
  1512. $text = uc($text) if (in_cmd($style_stack, 'sc'));
  1513. $text = &$protect_text($text) unless($in_raw_text);
  1514. #$text =~ s/ /&nbsp;/g
  1515. # if (!$in_raw_text and !$in_preformatted and in_cmd($style_stack, 'w'));
  1516. if (! $in_code and !$in_preformatted)
  1517. {
  1518. if (get_conf('USE_ISO') and !$in_raw_text)
  1519. {
  1520. $text =~ s/---/\&mdash\;/g;
  1521. $text =~ s/--/\&ndash\;/g;
  1522. $text =~ s/``/\&ldquo\;/g;
  1523. $text =~ s/''/\&rdquo\;/g;
  1524. }
  1525. else
  1526. {
  1527. if ($in_raw_text) #FIXME really do that ? It is done by makeinfo
  1528. {
  1529. $text =~ s/``/"/g;
  1530. $text =~ s/''/"/g;
  1531. }
  1532. else
  1533. {
  1534. $text =~ s/``/&quot;/g;
  1535. $text =~ s/''/&quot;/g;
  1536. # to be like texinfo
  1537. #$text =~ s/'/\&rsquo\;/g;
  1538. #$text =~ s/`/\&lsquo\;/g;
  1539. }
  1540. # FIXME really do that in raw text?
  1541. $text =~ s/---/\x{1F}/g;
  1542. $text =~ s/--/-/g;
  1543. $text =~ s/\x{1F}/--/g;
  1544. }
  1545. }
  1546. $text = html_default_protect_space_codebreak($text, $in_raw_text, $in_preformatted, $in_code, $style_stack);
  1547. $text = t2h_text_substitutions($text, $in_raw_text, ($in_preformatted or $in_code), $in_simple);
  1548. return $text;
  1549. }
  1550. # This function produces an anchor
  1551. #
  1552. # arguments:
  1553. # $name : anchor name
  1554. # $href : anchor href
  1555. # text : text displayed
  1556. # extra_attribs : added to anchor attributes list
  1557. sub html_default_anchor($;$$$)
  1558. {
  1559. my $name = shift;
  1560. my $href = shift;
  1561. my $text = shift;
  1562. my $attributes = shift;
  1563. my $class = '';
  1564. #print STDERR "!$name!$href!$text!$attributes!\n";
  1565. if (!defined($attributes) or ($attributes !~ /\S/))
  1566. {
  1567. $attributes = '';
  1568. }
  1569. else
  1570. {
  1571. if ($attributes =~ s/^class=\"([^\"]+)\"//)
  1572. {
  1573. $class = $1;
  1574. }
  1575. $attributes = ' ' . $attributes if ($attributes ne '');
  1576. }
  1577. $name = '' if (!defined($name) or ($name !~ /\S/));
  1578. $href = '' if (!defined($href) or ($href !~ /\S/));
  1579. $text = '' if (!defined($text));
  1580. return $text if (($name eq '') and ($href eq ''));
  1581. $name = "name=\"$name\"" if ($name ne '');
  1582. $href = "href=\"$href\"" if ($href ne '');
  1583. $href = ' ' . $href if (($name ne '') and ($href ne ''));
  1584. #print STDERR "!!!$name!$href!$text!$attributes!\n";
  1585. return html_default_attribute_class('a', $class). " ${name}${href}${attributes}>$text</a>";
  1586. }
  1587. # This function is used to format the text associated with a @deff/@end deff
  1588. #
  1589. # argument:
  1590. # text
  1591. #
  1592. # DEF_TABLE should be used to distinguish between @def formatted as table
  1593. # and as definition lists.
  1594. sub html_default_def_item($$$)
  1595. {
  1596. my $text = shift;
  1597. my $only_inter_item_commands = shift;
  1598. my $command = shift;
  1599. if ($text =~ /\S/)
  1600. {
  1601. if (! get_conf('DEF_TABLE'))
  1602. {
  1603. return '<dd>' . $text . '</dd>';# unless $only_inter_item_commands;
  1604. #return $text; # invalid without dd in ul
  1605. }
  1606. else
  1607. {
  1608. return '<tr><td colspan="2">' . $text . '</td></tr>';
  1609. }
  1610. }
  1611. return '';
  1612. }
  1613. # format the container for the @deffn line and text
  1614. #
  1615. # argument
  1616. # text of the whole @def, line and associated text.
  1617. #
  1618. # DEF_TABLE should be used.
  1619. sub html_default_def($$)
  1620. {
  1621. my $text = shift;
  1622. my $command = shift;
  1623. if ($text =~ /\S/)
  1624. {
  1625. if (! get_conf('DEF_TABLE'))
  1626. {
  1627. return "<dl>\n" . $text . "</dl>\n";
  1628. }
  1629. else
  1630. {
  1631. return "<table width=\"100%\">\n" . $text . "</table>\n";
  1632. }
  1633. }
  1634. return '';
  1635. }
  1636. # a whole menu
  1637. #
  1638. # argument:
  1639. # the whole menu text (entries and menu comments)
  1640. #
  1641. # argument:
  1642. # whole menu text.
  1643. sub html_default_menu_command($$$)
  1644. {
  1645. my $format = shift;
  1646. my $text = shift;
  1647. my $in_preformatted = shift;
  1648. $html_menu_entry_index=0;
  1649. my $begin_row = '';
  1650. my $end_row = '';
  1651. if ($in_preformatted)
  1652. {
  1653. $begin_row = '<tr><td>';
  1654. $end_row = '</td></tr>';
  1655. }
  1656. if ($text =~ /\S/)
  1657. {
  1658. return '' if ($format eq 'direntry');
  1659. return $text if ($format eq 'detailmenu');
  1660. return html_default_attribute_class('table', 'menu')." border=\"0\" cellspacing=\"0\">${begin_row}\n"
  1661. . $text . "${end_row}</table>\n";
  1662. }
  1663. }
  1664. # formats a menu entry link pointing to a node or section
  1665. #
  1666. # arguments:
  1667. # the entry text
  1668. # the state, a hash reference holding informations about the context, with a
  1669. # usefull entry, 'preformatted', true if we are in a preformatted format
  1670. # (a format keeping space between words). In that case a function
  1671. # of the main program, main::do_preformatted($text, $state) might
  1672. # be used to format the text with the current format style.
  1673. # href is optionnal. It is the reference to the section or the node anchor
  1674. # which should be used to make the link (typically it is the argument
  1675. # of a href= attribute in a <a> element).
  1676. sub html_default_menu_link($$$$$$$$)
  1677. {
  1678. my $element_name = shift;
  1679. my $state = shift;
  1680. my $href = shift;
  1681. my $node = shift;
  1682. my $title = shift;
  1683. my $ending = shift;
  1684. my $has_title = shift;
  1685. my $command_stack = shift;
  1686. my $preformatted = shift;
  1687. my $in_commands = 0;
  1688. $in_commands = 1 if ($command_stack->[-1] and $command_stack->[-1] ne 'menu' and $command_stack->[-1] ne 'detailmenu' and $command_stack->[-1] ne 'direntry');
  1689. $title = '' unless ($has_title);
  1690. #print STDERR "MENU_LINK($in_commands)($state->{'preformatted'})\n";
  1691. my $entry;
  1692. my $symbol = '';
  1693. if ($preformatted)
  1694. {
  1695. $title .= ':' if ($title ne '');
  1696. $entry = "$MENU_SYMBOL$title$node";
  1697. }
  1698. elsif ($element_name eq '' or get_conf('NODE_NAME_IN_MENU'))
  1699. {
  1700. if ($has_title)
  1701. {
  1702. $entry = "$title";
  1703. }
  1704. else
  1705. {
  1706. $entry = "$node";
  1707. }
  1708. $entry =~ s/^\s*//;
  1709. $symbol = "$MENU_SYMBOL ";
  1710. }
  1711. else
  1712. {
  1713. $entry = $element_name;
  1714. }
  1715. $html_menu_entry_index++;
  1716. my $accesskey;
  1717. $accesskey = "accesskey=\"$html_menu_entry_index\"" if (get_conf('USE_ACCESSKEY') and ($html_menu_entry_index < 10));
  1718. $entry = &$anchor ('', $href, $entry, $accesskey) if (defined($href));
  1719. return $entry.$ending if ($preformatted);
  1720. # FIXME conditionalise to not having a description
  1721. return "$symbol$entry$MENU_ENTRY_COLON" .'&nbsp;' if ($in_commands);
  1722. return "<tr><td align=\"left\" valign=\"top\">$symbol$entry$MENU_ENTRY_COLON</td><td>&nbsp;&nbsp;</td>";
  1723. }
  1724. sub html_simplify_text($)
  1725. {
  1726. my $text = shift;
  1727. $text =~ s/[^\w]//og;
  1728. return $text;
  1729. }
  1730. # formats a menu entry description, ie the text appearing after the node
  1731. # specification in a menu entry an spanning until there is another
  1732. # menu entry, or empty line
  1733. #
  1734. # arguments:
  1735. # the description text
  1736. # the state. See menu_entry.
  1737. # the heading of the element associated with the node.
  1738. sub html_default_menu_description($$$$)
  1739. {
  1740. my $text = shift;
  1741. my $state = shift;
  1742. my $element_text = shift;
  1743. my $command_stack = shift;
  1744. my $preformatted = shift;
  1745. my $in_commands = 0;
  1746. $in_commands = 1 if ($command_stack->[-1] and $command_stack->[-1] ne 'menu' and $command_stack->[-1] ne 'detailmenu' and $command_stack->[-1] ne 'direntry');
  1747. return $text if ($preformatted);
  1748. return $text."<br>" if ($in_commands);
  1749. if (get_conf('AVOID_MENU_REDUNDANCY'))
  1750. {
  1751. $text = '' if (html_simplify_text($element_text) eq html_simplify_text($text));
  1752. }
  1753. #$text =~ s/^\s*//;
  1754. return "<td align=\"left\" valign=\"top\">$text</td></tr>\n";
  1755. }
  1756. sub html_teletyped_in_stack($)
  1757. {
  1758. my $stack = shift;
  1759. foreach my $element(reverse(@$stack))
  1760. {
  1761. return 1 if ($complex_format_map{$element} and
  1762. $complex_format_map{$element}->{'style'} and
  1763. $complex_format_map{$element}->{'style'} eq 'code');
  1764. }
  1765. return 0;
  1766. }
  1767. # text after @item in table, vtable and ftable
  1768. sub html_default_table_item($$$$$$$)
  1769. {
  1770. my $text = shift;
  1771. my $index_label = shift;
  1772. my $format = shift;
  1773. my $command = shift;
  1774. # my $formatted_command = shift;
  1775. my $style_stack = shift;
  1776. # my $text_formatted = shift;
  1777. # my $text_formatted_leading_spaces = shift;
  1778. # my $text_formatted_trailing_spaces = shift;
  1779. my $item_cmd = shift;
  1780. my $formatted_index_entry = shift;
  1781. # if (defined($text_formatted) and !exists $special_list_commands{$format}->{$command})
  1782. # {
  1783. # $text = $text_formatted_leading_spaces . $text_formatted .$text_formatted_trailing_spaces;
  1784. # }
  1785. # $formatted_command = '' if (!defined($formatted_command) or
  1786. # exists($special_list_commands{$format}->{$command}));
  1787. if (html_teletyped_in_stack($style_stack))
  1788. {
  1789. # $text .= '</tt>';
  1790. # $formatted_command = '<tt>' . $formatted_command;
  1791. $text = '<tt>' . $text . '</tt>';
  1792. }
  1793. $text .= "\n" . $index_label if (defined($index_label));
  1794. # return '<dt>' . $formatted_command . $text . '</dt>' . "\n";
  1795. return '<dt>' . $text . '</dt>' . "\n";
  1796. }
  1797. # format text on the line following the @item line (in table, vtable and ftable)
  1798. sub html_default_table_line($$$)
  1799. {
  1800. my $text = shift;
  1801. my $only_inter_item_commands = shift;
  1802. my $before_items = shift;
  1803. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  1804. if ($text =~ /\S/)
  1805. {
  1806. return '<dd>' . $text . '</dd>' . "\n";# unless ($only_inter_item_commands);
  1807. #return $text; # invalid without dd in ul
  1808. }
  1809. return '';
  1810. }
  1811. #my $cell_nr = -1;
  1812. # row in multitable
  1813. sub html_default_row($$$$$$$$)
  1814. {
  1815. my $text = shift;
  1816. my $macro = shift;
  1817. my $columnfractions = shift;
  1818. my $prototype_row = shift;
  1819. my $prototype_lengths = shift;
  1820. my $column_number = shift;
  1821. my $only_inter_item_commands = shift;
  1822. my $before_items = shift;
  1823. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  1824. # this is used to keep the cell number
  1825. $html_default_multitable_stack[-1]->[0] = -1;
  1826. if ($text =~ /\S/)
  1827. {
  1828. if ($macro eq 'headitem')
  1829. {
  1830. return '<thead><tr>' . $text . '</tr></thead>' . "\n";
  1831. }
  1832. return '<tr>' . $text . '</tr>' . "\n";
  1833. }
  1834. return '';
  1835. }
  1836. # cell in multitable
  1837. sub html_default_cell($$$$$$$$)
  1838. {
  1839. my $text = shift;
  1840. my $row_macro = shift;
  1841. my $columnfractions = shift;
  1842. my $prototype_row = shift;
  1843. my $prototype_lengths = shift;
  1844. my $column_number = shift;
  1845. my $only_inter_item_commands = shift;
  1846. my $before_items = shift;
  1847. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  1848. $html_default_multitable_stack[-1]->[0]++;
  1849. my $cell_nr = $html_default_multitable_stack[-1]->[0];
  1850. my $fractions = '';
  1851. if (defined($columnfractions) and (ref($columnfractions) eq 'ARRAY')
  1852. and exists($columnfractions->[$cell_nr]))
  1853. {
  1854. my $fraction = sprintf('%d', 100*$columnfractions->[$cell_nr]);
  1855. $fractions = " width=\"$fraction%\"";
  1856. }
  1857. # in constructs like
  1858. # @strong{
  1859. # @multitable ....
  1860. # }
  1861. # the space won't be removed since the <strong> is put before the space.
  1862. $text =~ s/^\s*//;
  1863. $text =~ s/\s*$//;
  1864. if ($row_macro eq 'headitem')
  1865. {
  1866. return "<th${fractions}>" . $text . '</th>';
  1867. }
  1868. return "<td${fractions}>" . $text . '</td>';
  1869. }
  1870. sub html_default_format_list_item_texi($$$$$)
  1871. {
  1872. my $format = shift;
  1873. my $line = shift;
  1874. my $prepended = shift;
  1875. my $command = shift;
  1876. my $number = shift;
  1877. my $result_line;
  1878. my $open_command = 0;
  1879. if (defined($command) and $command ne '' and !exists $special_list_commands{$format}->{$command} and $format ne 'itemize')
  1880. {
  1881. #@*table
  1882. $open_command = 1;
  1883. $line =~ s/^\s*//;
  1884. $line =~ s/\s*$//;
  1885. if (exists ($style_map{$command}))
  1886. {
  1887. $result_line = "\@$command\{$line\}\n";
  1888. }
  1889. elsif (exists ($things_map{$command}))
  1890. {
  1891. $result_line = "\@$command\{\} $line\n";
  1892. }
  1893. else
  1894. {
  1895. $result_line = "\@$command $line\n";
  1896. }
  1897. }
  1898. elsif (defined($prepended) and $prepended ne '')
  1899. {
  1900. $prepended =~ s/^\s*//;
  1901. $prepended =~ s/\s*$//;
  1902. $line =~ s/^\s*//;
  1903. $result_line = $prepended . ' ' . $line;
  1904. }
  1905. return ($result_line, $open_command);
  1906. }
  1907. # format an item in a list
  1908. #
  1909. # argument:
  1910. # text of the item
  1911. # format of the list (itemize or enumerate)
  1912. # command passed as argument to the format
  1913. # formatted_command leading command formatted, if it is a thing command
  1914. sub html_default_list_item($$$$$$$$$$$)
  1915. {
  1916. my $text = shift;
  1917. my $format = shift;
  1918. my $command = shift;
  1919. my $formatted_command = shift;
  1920. my $item_nr = shift;
  1921. my $enumerate_style = shift;
  1922. my $number = shift;
  1923. my $prepended = shift;
  1924. my $prepended_formatted = shift;
  1925. my $only_inter_item_commands = shift;
  1926. my $before_items = shift;
  1927. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  1928. $formatted_command = '' if (!defined($formatted_command) or
  1929. exists($special_list_commands{$format}->{$command}));
  1930. my $prepend = '';
  1931. # if (defined($prepended) and $prepended ne '')
  1932. # {
  1933. # $prepend = $prepended;
  1934. # }
  1935. # elsif ($formatted_command ne '')
  1936. if ($formatted_command ne '')
  1937. {
  1938. $prepend = $formatted_command;
  1939. }
  1940. if ($text =~ /\S/)
  1941. {
  1942. return '<li>' . $prepend . $text . '</li>';
  1943. }
  1944. return '';
  1945. }
  1946. sub html_default_table_list($$$$$$$$$)
  1947. {
  1948. my $format_command = shift;
  1949. my $text = shift;
  1950. my $command = shift;
  1951. my $formatted_command = shift;
  1952. # enumerate
  1953. my $item_nr = shift;
  1954. my $enumerate_style = shift;
  1955. # itemize
  1956. my $prepended = shift;
  1957. my $prepended_formatted = shift;
  1958. # multitable
  1959. my $columnfractions = shift;
  1960. my $prototype_row = shift;
  1961. my $prototype_lengths = shift;
  1962. my $column_number = shift;
  1963. # my $number = shift;
  1964. $formatted_command = '' if (!defined($formatted_command) or
  1965. exists($special_list_commands{$format}->{$command}));
  1966. if ($format_command eq 'itemize')
  1967. {
  1968. return "<ul>\n" . $text . "</ul>\n" if (($command eq 'bullet') or (($command eq '') and ($prepended eq '')));
  1969. return html_default_attribute_class('ul',$NO_BULLET_LIST_CLASS).">\n" . $text . "</ul>\n";
  1970. }
  1971. elsif ($format_command eq 'multitable')
  1972. {
  1973. pop @html_default_multitable_stack;
  1974. return &$format('multitable', 'table', $text);
  1975. }
  1976. }
  1977. # a paragraph
  1978. # arguments:
  1979. # $text of the paragraph
  1980. # $align for the alignement
  1981. # $indent for the indent style (indent or noindent)
  1982. # The following is usefull if the paragraph is in an itemize.
  1983. # $paragraph_command is the leading formatting command (like @minus)
  1984. # $paragraph_command_formatted is the leading formatting command formatted
  1985. # $paragraph_number is a reference on the number of paragraphs appearing
  1986. # in the format. The value should be increased if a paragraph is done
  1987. # $format is the format name (@itemize)
  1988. sub html_default_paragraph($$$$$$$$$$$$)
  1989. {
  1990. my $text = shift;
  1991. my $align = shift;
  1992. my $indent = shift;
  1993. my $paragraph_command = shift;
  1994. my $paragraph_command_formatted = shift;
  1995. my $paragraph_number = shift;
  1996. my $format = shift;
  1997. my $item_nr = shift;
  1998. my $enumerate_style = shift;
  1999. my $number = shift;
  2000. my $command_stack_at_end = shift;
  2001. my $command_stack_at_begin = shift;
  2002. #print STDERR "format: $format\n" if (defined($format));
  2003. #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
  2004. # $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
  2005. # exists($special_list_commands{$format}->{$paragraph_command}));
  2006. return '' if ($text =~ /^\s*$/);
  2007. if (defined($paragraph_number) and defined($$paragraph_number))
  2008. {
  2009. $$paragraph_number++;
  2010. return $text if (($format eq 'itemize' or $format eq 'enumerate') and
  2011. ($$paragraph_number == 1));
  2012. }
  2013. my $top_stack = '';
  2014. $top_stack = $command_stack_at_begin->[-1] if (scalar (@$command_stack_at_begin));
  2015. if ($top_stack eq 'multitable')
  2016. {
  2017. $html_default_multitable_stack[-1]->[1]++;
  2018. if ($html_default_multitable_stack[-1]->[1] == 0)
  2019. {
  2020. return $text;
  2021. }
  2022. }
  2023. my $open = '<p>';
  2024. if ($align)
  2025. {
  2026. $open = "<p align=\"$paragraph_style{$align}\">";
  2027. }
  2028. return $open.$text.'</p>';
  2029. }
  2030. # a preformatted region
  2031. # arguments:
  2032. # $text of the preformatted region
  2033. # $pre_style css style
  2034. # $class identifier for the preformatted region (example, menu-comment)
  2035. # The following is usefull if the preformatted is in an itemize.
  2036. # $leading_command is the leading formatting command (like @minus)
  2037. # $leading_command_formatted is the leading formatting command formatted
  2038. # $preformatted_number is a reference on the number of preformatteds appearing
  2039. # in the format. The value should be increased if a preformatted is done
  2040. sub html_default_preformatted($$$$$$$$$$$$)
  2041. {
  2042. my $text = shift;
  2043. my $pre_style = shift;
  2044. my $class = shift;
  2045. my $leading_command = shift;
  2046. my $leading_command_formatted = shift;
  2047. my $preformatted_number = shift;
  2048. my $format = shift;
  2049. my $item_nr = shift;
  2050. my $enumerate_style = shift;
  2051. my $number = shift;
  2052. my $command_stack_at_end = shift;
  2053. my $command_stack_at_begin = shift;
  2054. #print STDERR "preformatted @$command_stack_at_end; @$command_stack_at_begin\n";
  2055. return '' if ($text eq '');
  2056. $leading_command_formatted = '' if (!defined($leading_command_formatted) or
  2057. exists($special_list_commands{$format}->{$leading_command}));
  2058. if (defined($preformatted_number) and defined($$preformatted_number))
  2059. {
  2060. $$preformatted_number++;
  2061. }
  2062. my $top_stack = '';
  2063. $top_stack = $command_stack_at_begin->[-1] if (scalar (@$command_stack_at_begin));
  2064. if ($top_stack eq 'multitable')
  2065. {
  2066. $text =~ s/^\s*//;
  2067. $text =~ s/\s*$//;
  2068. }
  2069. return html_default_attribute_class('pre', $class).">".$text."</pre>";
  2070. }
  2071. sub html_default_heading_text($$$)
  2072. {
  2073. my $command = shift;
  2074. my $text = shift;
  2075. my $level = shift;
  2076. return '' if ($text !~ /\S/);
  2077. # FIXME use a class=*contents?
  2078. my $class = '';
  2079. if ($command =~ /^@/ and $command !~ /^@.*contents$/)
  2080. {
  2081. $class = $command;
  2082. $class =~ s/^@//;
  2083. $class = 'node-heading' if ($command eq '@node');
  2084. }
  2085. my $align = '';
  2086. $align = ' align="center"' if ($command eq '@centerchap' or $command eq '@settitle');
  2087. $level = 1 if ($level == 0);
  2088. my $result = html_default_attribute_class ("h$level", $class) ."$align>$text</h$level>";
  2089. # FIXME titlefont appears inline in text, so no end of line is
  2090. # added. The end of line should be added by the user if needed.
  2091. $result .= "\n" unless ($command eq '@titlefont');
  2092. $result .= $DEFAULT_RULE . "\n" if ($command eq '@part' and defined($DEFAULT_RULE) and $DEFAULT_RULE ne '');
  2093. return $result;
  2094. }
  2095. sub html_default_heading_text_preformatted($$$)
  2096. {
  2097. my $command = shift;
  2098. my $text = shift;
  2099. my $level = shift;
  2100. return '' if ($text !~ /\S/);
  2101. return '<strong>'.$text.'</strong>'."\n";
  2102. }
  2103. # formatting of raw regions
  2104. # if L2H is true another mechanism is used for tex
  2105. sub html_default_raw($$;$)
  2106. {
  2107. my $style = shift;
  2108. my $text = shift;
  2109. my $line_nr = shift;
  2110. my $expanded = 1 if (grep {$style eq $_} @EXPAND);
  2111. if ($style eq 'verbatim' or $style eq 'verbatiminclude' or ($style eq 'tex' and $expanded))
  2112. {
  2113. $style = 'verbatim' if ($style eq 'verbatiminclude');
  2114. return html_default_attribute_class('pre', $style).">" . &$protect_text($text) . '</pre>';
  2115. }
  2116. elsif ($style eq 'html' and $expanded)
  2117. {
  2118. chomp ($text);
  2119. return $text;
  2120. }
  2121. elsif ($expanded)
  2122. {
  2123. main::line_warn (sprintf(__("Raw format %s is not converted"), $style), $line_nr);
  2124. return &$protect_text($text);
  2125. }
  2126. else
  2127. {
  2128. return '';
  2129. }
  2130. }
  2131. # This function formats a footnote reference and the footnote text associated
  2132. # with a given footnote.
  2133. # The footnote reference is the text appearing in the main document pointing
  2134. # to the footnote text.
  2135. #
  2136. # arguments:
  2137. # absolute number of the footnote (in the document)
  2138. # relative number of the footnote (in the page)
  2139. # identifier for the footnote
  2140. # identifier for the footnote reference in the main document
  2141. # main document file
  2142. # footnote text file
  2143. # array with the footnote text lines
  2144. # the state. See menu entry.
  2145. #
  2146. # returns:
  2147. # reference on an array containing the footnote text lines which should
  2148. # have been updated
  2149. # the text for the reference pointing on the footnote text
  2150. sub html_default_foot_line_and_ref($$$$$$$$$)
  2151. {
  2152. my $number_in_doc = shift;
  2153. my $number_in_page = shift;
  2154. my $footnote_id = shift;
  2155. my $place_id = shift;
  2156. my $document_file = shift;
  2157. my $footnote_file = shift;
  2158. my $lines = shift;
  2159. my $document_state = shift;
  2160. if ($document_file eq $footnote_file)
  2161. {
  2162. $document_file = $footnote_file = '';
  2163. }
  2164. $number_in_doc = $NO_NUMBER_FOOTNOTE_SYMBOL if (!get_conf('NUMBER_FOOTNOTES'));
  2165. unshift (@$lines, '<h3>' .
  2166. &$anchor($footnote_id, $document_file . "#$place_id",
  2167. "($number_in_doc)")
  2168. . "</h3>\n");
  2169. # this is a bit obscure, this allows to add an anchor only if formatted
  2170. # as part of the document.
  2171. #$place_id = '' if ($document_state->{'outside_document'} or $document_state->{'multiple_pass'} or $document_state->{'expansion'});
  2172. $place_id = '' if ($document_state->{'outside_document'} or (defined($document_state->{'multiple_pass'}) and $document_state->{'multiple_pass'} > 0));
  2173. return ($lines, &$anchor($place_id, $footnote_file . "#$footnote_id",
  2174. "($number_in_doc)"));
  2175. }
  2176. # formats a group of footnotes.
  2177. #
  2178. # argument:
  2179. # array reference on the footnotes texts lines
  2180. #
  2181. # returns an array reference on the group of footnotes lines
  2182. sub html_default_foot_section($)
  2183. {
  2184. my $lines = shift;
  2185. unshift (@$lines, html_default_attribute_class('div', 'footnote').">\n" ,"$DEFAULT_RULE\n",
  2186. &$heading_text('footnotes', gdt('Footnotes'), 3)
  2187. );
  2188. push (@$lines, "</div>\n");
  2189. return $lines;
  2190. }
  2191. # format an image
  2192. #
  2193. # arguments:
  2194. # image file name with path
  2195. # image basename
  2196. # a boolean true if we are in a preformatted format
  2197. # image file name without path
  2198. # alt text
  2199. # width
  2200. # height
  2201. # raw alt
  2202. # extension
  2203. # path to working dir
  2204. # path to file relative from working dir
  2205. sub html_default_image($$$$$$$$$$$$$$$$$)
  2206. {
  2207. my $file = shift;
  2208. my $base = shift;
  2209. my $preformatted = shift;
  2210. my $file_name = shift;
  2211. my $alt = shift;
  2212. my $width = shift;
  2213. my $height = shift;
  2214. my $raw_alt = shift;
  2215. my $extension = shift;
  2216. my $working_dir = shift;
  2217. my $file_path = shift;
  2218. my $in_paragraph = shift;
  2219. my $file_locations = shift;
  2220. my $base_simple_format = shift;
  2221. my $extension_simple_format = shift;
  2222. my $file_name_simple_format = shift;
  2223. my $line_nr = shift;
  2224. if (!defined($file_path) or $file_path eq '')
  2225. {
  2226. if (defined($extension) and $extension ne '')
  2227. {
  2228. $file = "$base.$extension";
  2229. }
  2230. else
  2231. {
  2232. $file = "$base.jpg";
  2233. }
  2234. main::line_warn (sprintf(__("\@image file `%s' (for HTML) not found, using `%s'"), $base, $file), $line_nr);
  2235. }
  2236. elsif (! get_conf('COMPLETE_IMAGE_PATHS'))
  2237. {
  2238. $file = $file_name;
  2239. }
  2240. $alt = &$protect_text($base) if (!defined($alt) or ($alt eq ''));
  2241. return "[ $alt ]" if ($preformatted);
  2242. # it is possible that $file_name is more correct as it allows the user
  2243. # to chose the relative path.
  2244. $file = &$protect_text($file);
  2245. return "<img src=\"$file\" alt=\"$alt\">";
  2246. }
  2247. # format a target in the main document for an index entry.
  2248. #
  2249. # arguments:
  2250. # target identifier
  2251. # boolean true if in preformatted format
  2252. # FIXME document the remaining
  2253. sub html_default_index_entry_label($$$$$$$$$)
  2254. {
  2255. my $identifier = shift;
  2256. my $preformatted = shift;
  2257. my $entry = shift;
  2258. my $index_name = shift;
  2259. my $index_command = shift;
  2260. my $texi_entry = shift;
  2261. my $formatted_entry = shift;
  2262. my $in_region_not_in_output = shift;
  2263. my $index_entry_ref = shift;
  2264. return '' if (!defined($identifier) or ($identifier !~ /\S/));
  2265. my $label = &$anchor($identifier);
  2266. return $label . "\n" if (!$preformatted);
  2267. return $label;
  2268. }
  2269. sub html_default_index_entry_command($$$$$$)
  2270. {
  2271. my $command = shift;
  2272. my $index_name = shift;
  2273. my $label = shift;
  2274. my $entry_texi = shift;
  2275. my $entry_formatted = shift;
  2276. my $index_entry_ref = shift;
  2277. return $label;
  2278. }
  2279. # process definition commands line @deffn for example
  2280. sub html_default_def_line($$$$$$$$$$$$$$$$)
  2281. {
  2282. my $category_prepared = shift;
  2283. my $name = shift;
  2284. my $type = shift;
  2285. my $arguments = shift;
  2286. my $index_label = shift;
  2287. my $arguments_array = shift;
  2288. my $arguments_type_array = shift;
  2289. my $unformatted_arguments_array = shift;
  2290. my $command = shift;
  2291. my $class_name = shift;
  2292. my $category = shift;
  2293. my $class = shift;
  2294. my $style = shift;
  2295. my $original_command = shift;
  2296. $index_label = '' if (!defined($index_label));
  2297. chomp($index_label);
  2298. $category_prepared = '' if (!defined($category_prepared) or ($category_prepared =~ /^\s*$/));
  2299. $name = '' if (!defined($name) or ($name =~ /^\s*$/));
  2300. $type = '' if (!defined($type) or $type =~ /^\s*$/);
  2301. if (!defined($arguments) or $arguments =~ /^\s*$/)
  2302. {
  2303. $arguments = '';
  2304. }
  2305. else
  2306. {
  2307. chomp ($arguments);
  2308. $arguments = '<em>' . $arguments . '</em>';
  2309. }
  2310. my $type_name = '';
  2311. $type_name = " <em>$type</em>" if ($type ne '');
  2312. $type_name .= ' <strong>' . $name . '</strong>' if ($name ne '');
  2313. $type_name .= $arguments;
  2314. if (! get_conf('DEF_TABLE'))
  2315. {
  2316. return '<dt>'. $index_label. $category_prepared . ':' . $type_name . "</dt>\n";
  2317. }
  2318. else
  2319. {
  2320. return "<tr><td align=\"left\">" . $type_name .
  2321. "</td><td align=\"right\">" . $category_prepared . $index_label . "</td></tr>\n";
  2322. }
  2323. }
  2324. # a cartouche
  2325. sub html_default_cartouche($$)
  2326. {
  2327. my $text = shift;
  2328. if ($text =~ /\S/)
  2329. {
  2330. return html_default_attribute_class('table', 'cartouche')." border=\"1\"><tr><td>\n" . $text . "</td></tr></table>\n";
  2331. }
  2332. return '';
  2333. }
  2334. sub html_default_sp($$)
  2335. {
  2336. my $number = shift;
  2337. my $preformatted = shift;
  2338. return "<br>\n" x $number if (!$preformatted);
  2339. return "\n" x $number;
  2340. }
  2341. sub html_default_acronym_like($$$$$$)
  2342. {
  2343. my $command = shift;
  2344. my $acronym_texi = shift;
  2345. my $acronym_text = shift;
  2346. my $with_explanation = shift;
  2347. my $explanation_lines = shift;
  2348. my $explanation_text = shift;
  2349. my $explanation_simply_formatted = shift;
  2350. my $attribute = $command;
  2351. my $opening = "<$attribute>";
  2352. if (defined($explanation_simply_formatted))
  2353. {
  2354. $opening = "<$attribute title=\"$explanation_simply_formatted\">";
  2355. }
  2356. if ($with_explanation)
  2357. {
  2358. return gdt('{acronym_like} ({explanation})', {'acronym_like' => $opening . $acronym_text . "</$attribute>", 'explanation' => $explanation_text},{'duplicate'=>1})
  2359. }
  2360. else
  2361. {
  2362. return $opening . $acronym_text . "</$attribute>";
  2363. }
  2364. }
  2365. sub html_default_quotation($$$$$)
  2366. {
  2367. my $command = shift;
  2368. my $text = shift;
  2369. my $argument_text = shift;
  2370. my $argument_text_texi = shift;
  2371. my $authors = shift;
  2372. my $class = '';
  2373. $class = $command if ($command ne 'quotation');
  2374. my $attribution = '';
  2375. if ($authors)
  2376. {
  2377. foreach my $author (@$authors)
  2378. {
  2379. my $author_texi = $author->{'author_texi'};
  2380. chomp($author_texi);
  2381. $attribution .= gdt("\@center --- \@emph{{author}}\n", {'author' => $author_texi}, {'duplicate' => 1, 'allow_paragraph' => 1});
  2382. }
  2383. }
  2384. return html_default_attribute_class('blockquote', $class).">\n" . $text ."</blockquote>\n" . $attribution;
  2385. }
  2386. # format a whole index
  2387. #
  2388. # argument:
  2389. # index text
  2390. # index name
  2391. sub html_default_print_index($$)
  2392. {
  2393. my $text = shift;
  2394. my $name = shift;
  2395. return '' if (!defined($text));
  2396. return html_default_attribute_class('table', "index-$name")." border=\"0\">\n" .
  2397. "<tr><td></td><th align=\"left\">" . gdt('Index Entry') . "</th><td>&nbsp;</td><th align=\"left\"> " . gdt('Section') . "</th></tr>\n"
  2398. . "<tr><td colspan=\"4\"> $DEFAULT_RULE</td></tr>\n" . $text .
  2399. "</table>\n";
  2400. }
  2401. # format a letter entry in an index page. The letter entry contains
  2402. # the index entries for the words beginning with that letter. It is
  2403. # a target for links pointing from the summary of the index.
  2404. #
  2405. # arguments:
  2406. # the letter
  2407. # identifier for the letter entry. This should be used to make the target
  2408. # identifier
  2409. # text of the index entries
  2410. sub html_default_index_letter($$$)
  2411. {
  2412. my $letter = shift;
  2413. my $id = shift;
  2414. my $text = shift;
  2415. return $text if ($letter =~ /^\s*$/);
  2416. return '<tr><th>' . &$anchor($id,'',&$normal_text($letter, 0, 0, 0, 0, 0, [])) .
  2417. "</th><td></td><td></td></tr>\n" . $text .
  2418. "<tr><td colspan=\"4\"> $DEFAULT_RULE</td></tr>\n";
  2419. }
  2420. # format an index entry (in a letter entry).
  2421. #
  2422. # arguments:
  2423. # href to the main text, linking to the place where the index entry appears
  2424. # entry text
  2425. # href to the main text, linking to the section or node where the index
  2426. # entry appears
  2427. # section or node heading
  2428. sub html_default_index_entry($$$$$$$$$$)
  2429. {
  2430. my $text_href = shift;
  2431. my $entry = shift;
  2432. my $element_href = shift;
  2433. my $element_text = shift;
  2434. my $entry_file = shift;
  2435. my $current_element_file = shift;
  2436. my $entry_target = shift;
  2437. my $entry_element_target = shift;
  2438. my $in_region_not_in_output = shift;
  2439. my $index_entry_ref = shift;
  2440. return '' if ($entry !~ /\S/);
  2441. my $element = $index_entry_ref->{'real_element'};
  2442. if (defined($element))
  2443. {
  2444. my $element_set = 0;
  2445. if (get_conf('NODE_NAME_IN_INDEX'))
  2446. {
  2447. if ($element->{'node'})
  2448. {
  2449. $element_set = 1;
  2450. }
  2451. elsif ($element->{'with_node'})
  2452. {
  2453. $element = $element->{'with_node'};
  2454. $element_set = 1;
  2455. }
  2456. }
  2457. elsif (defined(get_conf('NODE_NAME_IN_INDEX')))
  2458. {
  2459. if (!$element->{'node'})
  2460. {
  2461. $element_set = 1;
  2462. }
  2463. elsif ($element->{'with_section'})
  2464. {
  2465. $element = $element->{'with_section'};
  2466. $element_set = 1;
  2467. }
  2468. }
  2469. if ($element_set)
  2470. {
  2471. $element_href = main::href($element, $Texi2HTML::THIS_ELEMENT->{'file'},
  2472. $Texi2HTML::THISDOC{'line_nr'});
  2473. $element_text = $element->{'text'};
  2474. }
  2475. }
  2476. return '<tr><td></td><td valign="top">' . &$anchor('', $text_href, $entry)
  2477. . $INDEX_ENTRY_COLON . '</td><td>&nbsp;</td><td valign="top">' . &$anchor('', $element_href, $element_text)
  2478. . "</td></tr>\n";
  2479. }
  2480. # format an index summary. This is a list of letters linking to the letter
  2481. # entries.
  2482. #
  2483. # arguments:
  2484. # array reference containing the formatted alphabetical letters
  2485. # array reference containing the formatted non lphabetical letters
  2486. sub html_default_index_summary($$)
  2487. {
  2488. my $alpha = shift;
  2489. my $nonalpha = shift;
  2490. my $join = '';
  2491. my $nonalpha_text = '';
  2492. my $alpha_text = '';
  2493. $join = " &nbsp; \n<br>\n" if (@$nonalpha and @$alpha);
  2494. if (@$nonalpha)
  2495. {
  2496. $nonalpha_text = join("\n &nbsp; \n", @$nonalpha) . "\n";
  2497. }
  2498. if (@$alpha)
  2499. {
  2500. $alpha_text = join("\n &nbsp; \n", @$alpha) . "\n &nbsp; \n";
  2501. }
  2502. return "<table><tr><th valign=\"top\">" . gdt('Jump to') .": &nbsp; </th><td>" .
  2503. $nonalpha_text . $join . $alpha_text . "</td></tr></table>\n";
  2504. }
  2505. sub html_default_element_label($$$$)
  2506. {
  2507. my $id = shift;
  2508. my $element = shift;
  2509. my $command = shift;
  2510. my $line = shift;
  2511. return &$anchor($id) . "\n";
  2512. }
  2513. sub html_default_misc_element_label($$)
  2514. {
  2515. my $id = shift;
  2516. my $misc_page_name = shift;
  2517. return &$anchor($id) . "\n";
  2518. }
  2519. sub html_default_anchor_label($$$$)
  2520. {
  2521. my $id = shift;
  2522. my $anchor_text = shift;
  2523. my $anchor_reference = shift;
  2524. my $in_special_region = shift;
  2525. return &$anchor($id);
  2526. }
  2527. sub html_default_tab_item_texi($$$$$$)
  2528. {
  2529. my $command = shift;
  2530. my $commands_stack = shift;
  2531. my $stack = shift;
  2532. my $state = shift;
  2533. my $line = shift;
  2534. my $line_nr = shift;
  2535. if (defined($commands_stack) and @$commands_stack and $commands_stack->[-1] eq 'multitable' and @html_default_multitable_stack)
  2536. {
  2537. $html_default_multitable_stack[-1]->[1] = -1;
  2538. }
  2539. return undef;
  2540. }
  2541. sub html_default_line_command($$$$)
  2542. {
  2543. my $command = shift;
  2544. my $arg_text = shift;
  2545. my $arg_texi = shift;
  2546. my $state = shift;
  2547. return '' if ($arg_text eq '' or ($command eq 'author' and (!$state->{'region'} or $state->{'region'} ne 'titlepage')));
  2548. my $style = $line_command_map{$command};
  2549. if ($style)
  2550. {
  2551. my $attribute_text = '';
  2552. if ($style =~ /^(\w+)(\s+.*)/)
  2553. {
  2554. $style = $1;
  2555. $attribute_text = $2;
  2556. }
  2557. $arg_text = "<${style}$attribute_text>$arg_text</$style>";
  2558. }
  2559. $arg_text .= "<br>" if ($command eq 'author');
  2560. $arg_text .= "\n";
  2561. return $arg_text;
  2562. }
  2563. 1;