texi2html.pm 216 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394
  1. # -*-perl-*-
  2. # vim: set filetype=perl:
  3. ######################################################################
  4. # File: texi2html.pm
  5. #
  6. # Default values for command-line arguments and for various customizable
  7. # procedures are set in this file.
  8. #
  9. # A copy of this file is pasted into the beginning of texi2html by
  10. # running './configure'.
  11. #
  12. # Copy this file, rename it and make changes to it, if you like.
  13. # Afterwards, load the file with command-line
  14. # option --init-file <your_init_file>
  15. #
  16. # This file is in the public domain. Thus it may easily be used as an
  17. # example for further customizations.
  18. #
  19. # Originally written by Olaf Bachmann in 2000.
  20. #
  21. # Those values may be overrided by values set in $sysconfdir/texi2html/Config
  22. # and then by values set in $HOME/texi2html/Config.
  23. #
  24. # $Id$
  25. ##################################################################
  26. # The following variables can also be set by command-line options
  27. #
  28. # command line switches may override these values, and values set in files
  29. # specified by --init-file are also taken into account.
  30. #
  31. # options common with makeinfo
  32. # -I
  33. # add a directory to the list of directories where @include files are
  34. # searched for (besides the directory of the file). additional '-I'
  35. # args are appended to this list.
  36. # (APA: Don't implicitely search ., to conform with the docs!)
  37. # my @INCLUDE_DIRS = (".");
  38. use strict;
  39. @INCLUDE_DIRS = ();
  40. # -P
  41. # prepend a directory to the list of directories where @include files are
  42. # searched for before the directory of the file. additional '-P'
  43. # args are prepended to this list.
  44. @PREPEND_DIRS = ();
  45. # --split section|chapter|node|none
  46. # if $SPLIT is set to 'section' (resp. 'chapter') one html file per section
  47. # (resp. chapter) is generated. If $SPLIT is set to 'node' one html file per
  48. # node or sectioning element is generated. In all these cases separate pages
  49. # for Top, Table of content (Toc), Overview and About are generated.
  50. # Otherwise a monolithic html file that contains the whole document is
  51. # created.
  52. set_default('SPLIT', '');
  53. # --separated-footnotes
  54. # if this is set footnotes are on a separated page. Otherwise they are at
  55. # the end of each file (if the document is split).
  56. set_default('footnotestyle', 'end');
  57. # --fill-column
  58. set_default('FILLCOLUMN', 72);
  59. # --number | --no-number
  60. # if this is set the sections are numbered, and section names and numbers
  61. # are used in references and menus (instead of node names).
  62. set_default('NUMBER_SECTIONS', 1);
  63. # --headers
  64. # if this is set then navigation panels are printed at the beginning of each
  65. # section.
  66. # If the document is split at nodes then navigation panels are
  67. # printed at the end if there were more than WORDS_IN_PAGE words on page.
  68. #
  69. # Navigation panels are always printed at the beginning of output files.
  70. #
  71. # This is most useful if you do not want to have section navigation
  72. # with --split chapter. There will be chapter navigation panel at the
  73. # beginning and at the end of chapters anyway.
  74. # this is mostly not used in the default case, important for html.
  75. set_default('HEADERS', 0);
  76. # -o filename
  77. # If this is set a monolithic document is outputted into $filename.
  78. set_default('OUT', undef);
  79. set_default('OUTFILE', undef);
  80. # --split-size
  81. # if undef, the info output is not split
  82. set_default('SPLIT_SIZE', 300000);
  83. # --internal-links
  84. set_default('INTERNAL_LINKS', undef);
  85. # --no-validate
  86. # suppress node cross-reference validation
  87. set_default('novalidate', 0);
  88. # --documentlanguage
  89. # use gdt('my string') if you want to have translations of 'my string'.
  90. # Translations are in texinfo/po_document/
  91. # This is used for the initial language, it is overriden during
  92. # document processing if there is a @documentlanguage.
  93. # It is ignored if the language is passed on the command line.
  94. set_default('documentlanguage', 'en');
  95. # --transliterate-file-names
  96. # transliterate node names for external refs (and internal if NODE_FILES)
  97. set_default('TRANSLITERATE_FILE_NAMES', 1);
  98. # --error-limit
  99. # quit after NUM errors (default 100).
  100. set_default('ERROR_LIMIT', 100);
  101. # --css-include
  102. # All the specified css files are used. More precisely the @import sections
  103. # are added to the beginning of the CSS_LINES the remaining is added at
  104. # the end of the CSS_LINES (after the css rules generated by the program).
  105. # cf texinfo manual for more info.
  106. # - means STDIN
  107. @CSS_FILES = ();
  108. # --css-ref
  109. # the specified url are used as stylesheet links
  110. @CSS_REFS = ();
  111. # --paragraph-indent
  112. set_default('paragraphindent',3);
  113. # --enable-encoding
  114. set_default('ENABLE_ENCODING', 0);
  115. # --force
  116. set_default('FORCE', 0);
  117. # --no-warn
  118. set_default('NO_WARN', 0);
  119. # --number-footnotes
  120. set_default('NUMBER_FOOTNOTES', 1);
  121. # --batch
  122. set_default('BATCH', 0);
  123. # --silent/--quiet
  124. set_default('SILENT', 0);
  125. # --Xopt
  126. @TEXI2DVI_ARGUMENTS = ();
  127. # not in makeinfo but in texi2dvi
  128. # --command
  129. @COMMANDS = ();
  130. ##################################################################
  131. # option specific of texi2html
  132. # --debug
  133. # The integer value specifies what kind of debugging output is generated.
  134. set_default('DEBUG', 0);
  135. # --doctype
  136. # The value is the 'SystemLiteral' which identifies the canonical DTD
  137. # for the document.
  138. # Definition: The SystemLiteral is called the entity's system
  139. # identifier. It is a URI, which may be used to retrieve the entity.
  140. # See http://www.xml.com/axml/target.html#NT-ExternalID
  141. set_default('DOCTYPE', '');
  142. # --frameset-doctype
  143. # When frames are used, this SystemLiteral identifies the DTD used for
  144. # the file containing the frame description.
  145. set_default('FRAMESET_DOCTYPE', '');
  146. # --test
  147. # If this value is true, some variables which should be dynamically generated
  148. # (the date, the user running texi2html, the version of texi2html) are set to
  149. # fix and given values. This is usefull in case the resulting manual is
  150. # compared with a reference. For example this is used in the tests.
  151. set_default('TEST', 0);
  152. # --dump-texi
  153. # This value is usefull for debugging purposes. The result of the first pass is
  154. # put in <document name>.passtexi, the result of the second pass is put in
  155. # <document name>.passfirst.
  156. set_default('DUMP_TEXI', 0);
  157. # --expand
  158. # the @EXPAND array contains the expanded section names.
  159. @EXPAND = ();
  160. # --iso
  161. # if this value is true, ISO8859 characters are used for quotes.
  162. # --iso does more than what USE_ISO does.
  163. set_default('USE_ISO', 0);
  164. # --conf-dir
  165. # append to the files searched for init files.
  166. @CONF_DIRS = ();
  167. # --top-file
  168. # This file name is used for the top-level file.
  169. # The extension is set appropriately, if necessary.
  170. # If empty, <basename of document>.html is used.
  171. # Typically, you would set this to "index.html".
  172. set_default('TOP_FILE', '');
  173. # --toc-file
  174. # This file name is used for the table of contents. The
  175. # extension is set appropriately, if necessary.
  176. # If empty, <basename of document>_toc.html is used.
  177. set_default('TOC_FILE', '');
  178. # --frames
  179. # if the value is true, HTML 4.0 "frames" are used.
  180. # A file describing the frame layout is generated, together with a file
  181. # with the short table of contents.
  182. set_default('FRAMES', 0);
  183. # --menu | --no-menu
  184. # if the value is true the Texinfo menus are shown.
  185. # this is defined in all the formats
  186. set_default('SHOW_MENU', 1);
  187. # --use-nodes
  188. # if this is set the nodes are used as sectioning elements.
  189. # Otherwise the nodes are incorporated in sections.
  190. set_default('USE_NODES', 1);
  191. # --node-files
  192. # if this is set one file per node is generated, which can be a target for
  193. # cross manual references.
  194. set_default('NODE_FILES', undef);
  195. # --toc-links
  196. # if this is set, links from headings to toc entries are created.
  197. set_default('TOC_LINKS', 0);
  198. # --subdir
  199. # If this is set, then put result files into the specified directory.
  200. # If not set, then result files are put into the current directory.
  201. #$SUBDIR = 'html';
  202. set_default('SUBDIR', undef);
  203. # --short-extn
  204. # If this is set, then all HTML files will have extension ".htm" instead of
  205. # ".html". This is helpful when shipping the document to DOS-based systems.
  206. set_default('SHORTEXTN', 0);
  207. # --prefix
  208. # This set the output file prefix, prepended to all .html, .gif and .pl files.
  209. # By default, this is the basename of the document.
  210. set_default('PREFIX', '');
  211. # --short-ref
  212. # if this is set cross-references are given without section.
  213. set_default('SHORT_REF', 1);
  214. # --idx-sum
  215. # if value is set, then for each @printindex <index name>
  216. # <document name>_<index name>.idx is created which contains lines of the form
  217. # key ref sorted alphabetically (case matters).
  218. set_default('IDX_SUMMARY', 0);
  219. # --def-table
  220. # If this is set a table construction for @def.... instead of definition
  221. # lists.
  222. # (New Option: 27.07.2000 Karl Heinz Marbaise)
  223. set_default('DEF_TABLE', 0);
  224. # --verbose
  225. # if this is set chatter about what we are doing.
  226. set_default('VERBOSE', '');
  227. # --ignore-preamble-text
  228. # If this is set the text before @node and sectioning commands is ignored.
  229. set_default('IGNORE_PREAMBLE_TEXT', 0);
  230. # --html-xref-prefix
  231. # base directory for external manuals. Obsolete.
  232. set_default('EXTERNAL_DIR', undef);
  233. # --l2h
  234. # if this is set, latex2html is used for generation of math content.
  235. set_default('L2H', '');
  236. # --monolithic
  237. # output only one file including ToC. It only makes sense when not split
  238. set_default('MONOLITHIC', 1);
  239. ######################
  240. # The following options are only relevant if $L2H is set
  241. #
  242. # --l2h-l2h
  243. # name/location of latex2html program
  244. set_default('L2H_L2H', 'latex2html');
  245. # --l2h-skip
  246. # If this is set the actual call to latex2html is skipped. The previously
  247. # generated content is reused, instead.
  248. # If set to 0, the cache is not used.
  249. # If undef the cache is used for as many tex fragments as possible
  250. # and for the remaining the command is run.
  251. set_default('L2H_SKIP', undef);
  252. # --l2h-tmp
  253. # If this is set l2h uses the specified directory for temporary files. The path
  254. # leading to this directory may not contain a dot (i.e., a ".");
  255. # otherwise, l2h will fail.
  256. set_default('L2H_TMP', '');
  257. # --l2h-file
  258. # If set, l2h uses the file as latex2html init file
  259. set_default('L2H_FILE', undef);
  260. # --l2h-clean
  261. # if this is set the intermediate files generated by texi2html in relation with
  262. # latex2html are cleaned (they all have the prefix <document name>_l2h_).
  263. set_default('L2H_CLEAN', 1);
  264. ##############################################################################
  265. #
  266. # The following can only be set in the init file
  267. #
  268. ##############################################################################
  269. @INPUT_FILE_SUFFIXES = ('.txi','.texinfo','.texi','.txinfo','');
  270. set_default('firstparagraphindent', 'none');
  271. @T2H_FORMAT_EXPAND = ('plaintext');
  272. # In file encoding. The @documentencoding allows autodetection of
  273. # that variable.
  274. set_default('documentencoding', undef);
  275. # In file encoding, understandable by perl. Set according to documentencoding
  276. set_default('IN_ENCODING', undef);
  277. # Formatted document encoding name. If undef, set in init_out based on
  278. # OUT_ENCODING or documentencoding if they are defined
  279. set_default('ENCODING_NAME', undef);
  280. # Out files encoding, understandable by perl. If undef, set in init_out
  281. # using ENCODING_NAME or IN_ENCODING if they are defined
  282. set_default('OUT_ENCODING', undef);
  283. # if undef set to @documentdescription. If there is no @documentdescription,
  284. # set in page_head.
  285. set_default('documentdescription', undef);
  286. # EXTERNAL_CROSSREF_SPLIT at the document level set to 1 if SPLIT,
  287. # to 0 otherwise
  288. set_default('EXTERNAL_CROSSREF_SPLIT', undef);
  289. # output as @today, and also as the date. Set automatically if not set
  290. # otherwise.
  291. set_default('today', undef);
  292. # simple headers formatting, not in a table and using node names.
  293. set_default('HEADER_IN_TABLE', 0);
  294. # output the generation date in the header.
  295. set_default('DATE_IN_HEADER', 0);
  296. # use table for indentation of complex formats
  297. set_default('COMPLEX_FORMAT_IN_TABLE', 0);
  298. # if set, node names are used to construct file names
  299. # if undef, it is set if split at node, or NODE_FILES is set.
  300. set_default('NODE_FILENAMES', undef);
  301. # If true do table of contents even if there is no @content
  302. set_default('contents', undef);
  303. # If true do short table of contents even if there is no @shortcontent
  304. set_default('shortcontents', undef);
  305. # set by @setcontentsaftertitlepage/@setshortcontentsaftertitlepage
  306. set_default('setcontentsaftertitlepage', undef);
  307. set_default('setshortcontentsaftertitlepage', undef);
  308. # corresponds with @kbdinputstyle
  309. set_default('kbdinputstyle', 'distinct');
  310. # corresponds with @frenchspacing
  311. set_default('frenchspacing', 'off');
  312. # correspond with @allowcodebreaks
  313. set_default('allowcodebreaks', 'true');
  314. # corresponds with @setfilename. Set with caution.
  315. set_default('setfilename', undef);
  316. # if unset, don't show a title
  317. set_default('SHOW_TITLE', 1);
  318. # if set style is added in attribute.
  319. set_default('INLINE_CSS_STYLE', 0);
  320. # if set, no css is used.
  321. set_default('NO_CSS', 0);
  322. # if set, the image files are completed to be relative from the
  323. # document directory, to the source manual directory and then to
  324. # the image
  325. set_default('COMPLETE_IMAGE_PATHS', 0);
  326. # if true, begin outputting at @setfilename, if this command is present.
  327. set_default('IGNORE_BEFORE_SETFILENAME', 1);
  328. # if true the link in Overview link to the corresponding Toc entry.
  329. set_default('OVERVIEW_LINK_TO_TOC', 1);
  330. # if set, use node anchors for sections targets
  331. set_default('USE_NODE_TARGET', 1);
  332. # new style for crossrefs
  333. set_default('NEW_CROSSREF_STYLE', 1);
  334. # top heading is always at the beginning of the element.
  335. # FIXME looks like a no-op
  336. set_default('TOP_HEADING_AT_BEGINNING', 0);
  337. # use titlepage for the title instead of a simplest title
  338. set_default('USE_TITLEPAGE_FOR_TITLE', 0);
  339. # used as identation for block enclosing command @example, etc
  340. # If not empty, must be enclosed in <td></td>
  341. $EXAMPLE_INDENT_CELL = '';
  342. # same as above, only for @small
  343. $SMALL_EXAMPLE_INDENT_CELL = '';
  344. # unused
  345. $SMALL_FONT_SIZE = '-1';
  346. # horizontal rules
  347. # not used
  348. $SMALL_RULE = '';
  349. $MIDDLE_RULE = '';
  350. # used in html
  351. $DEFAULT_RULE = '';
  352. $BIG_RULE = '';
  353. # output the program name in the footer
  354. set_default('PROGRAM_NAME_IN_FOOTER', 0);
  355. # if non-empty, and no @..heading appeared in Top node, then
  356. # use this as header for top node/section, otherwise use value of
  357. # @settitle or @shorttitle (in that order)
  358. $TOP_HEADING = '';
  359. # if set, use this chapter for 'Index' button, else
  360. # use first chapter with @printindex
  361. $INDEX_CHAPTER = '';
  362. set_default('SIMPLE_MENU', 1);
  363. set_default('OPEN_QUOTE_SYMBOL', '`');
  364. set_default('CLOSE_QUOTE_SYMBOL', "'");
  365. $NO_NUMBER_FOOTNOTE_SYMBOL = '*';
  366. # if true put a $MENU_SYMBOL before unnumbered in menus
  367. $UNNUMBERED_SYMBOL_IN_MENU = 0;
  368. # extension for nodes files when NODE_FILES is true
  369. set_default('NODE_FILE_EXTENSION', 'txt');
  370. # extension
  371. set_default('EXTENSION', 'txt');
  372. # file name used for Top node when NODE_FILES is true
  373. #TOP_NODE_FILE = 'index';
  374. set_default('TOP_NODE_FILE', undef);
  375. # file name used for Top node in references
  376. set_default('TOP_NODE_FILE_TARGET', 'index');
  377. # file used as document basename, when input file is -
  378. $STDIN_DOCU_NAME = 'stdin';
  379. # file used as document output basename, when output file is -
  380. $STDOUT_DOCU_NAME = 'stdout';
  381. # node name used for Top node when automatic node directions are used
  382. set_default('TOP_NODE_UP', '(dir)');
  383. # this controls the pre style for menus
  384. $MENU_PRE_STYLE = 'font-family: serif';
  385. # on bug-texinfo is has been said the the style is not code_style
  386. # for menus (except for the node name).
  387. # this controls the menu preformatted format
  388. # FIXME this is not dynamic, so change in MENU_PRE_STYLE is not taken
  389. # into account.
  390. # This is used if the menu appears within a preformatted format (which
  391. # is certainly an invalid construct), and SIMPLE_MENU is not set.
  392. $MENU_PRE_COMPLEX_FORMAT = {
  393. 'class' => 'menu-preformatted',
  394. # 'style' => 'code'
  395. };
  396. # This controls the ul style for toc
  397. $NO_BULLET_LIST_STYLE = '';
  398. $NO_BULLET_LIST_ATTRIBUTE = '';
  399. # These lines are inserted before and after the shortcontents
  400. $BEFORE_OVERVIEW = "";
  401. $AFTER_OVERVIEW = "";
  402. # These lines are inserted before and after the contents
  403. $BEFORE_TOC_LINES = "";
  404. $AFTER_TOC_LINES = "";
  405. # text inserted after <body ...>
  406. $AFTER_BODY_OPEN = '';
  407. # text inserted before </body>, this will be automatically inside <p></p>
  408. $PRE_BODY_CLOSE = '';
  409. # this is added inside <head></head> after <title> and some <meta name>
  410. # stuff, it can be used for eg. <style>, <script>, <meta> etc. tags.
  411. $EXTRA_HEAD = '';
  412. # Specifies the minimum page length required before a navigation panel
  413. # is placed at the bottom of a page
  414. # FIXME this is not true:
  415. # THIS_WORDS_IN_PAGE holds number of words of current page
  416. set_default('WORDS_IN_PAGE', 300);
  417. # if this is set a vertical navigation panel is used.
  418. set_default('VERTICAL_HEAD_NAVIGATION', 0);
  419. # html version for latex2html
  420. set_default('L2H_HTML_VERSION', "4.0");
  421. # use icons.
  422. set_default('ICONS', 0);
  423. # use old framework for translations
  424. set_default('I18N_PERL_HASH', 0);
  425. # command name to invoke when used as a texi2dvi wrapper
  426. set_default('TEXI2DVI', 'texi2dvi');
  427. # this resets some defaults, those that are also set in formats and
  428. # not set in every formats.
  429. #
  430. # this is called below after %default_style_map_texi is defined
  431. sub t2h_default_set_variables_default()
  432. {
  433. $CAPTION_STYLE = 'strong';
  434. # if this variable is true, @setfilename is used if found to determine the
  435. # out file name
  436. set_default('USE_SETFILENAME', 1);
  437. # if true, use the filename and extension from setfilename. For Info.
  438. set_default('USE_SETFILENAME_EXTENSION', 0);
  439. # FIXME is this right?
  440. # default used in init_out for the setting of the ENCODING_NAME variable
  441. set_default('DEFAULT_ENCODING', 'utf8');
  442. # if set and menu entry equals menu description, then do not print
  443. # menu description.
  444. # Likewise, if node name equals entry name, do not print entry name.
  445. set_default('AVOID_MENU_REDUNDANCY', 0);
  446. # if true, use the original command if the result is an entity
  447. set_default('ENABLE_ENCODING_USE_ENTITY', 0);
  448. # if set, output the contents where the command is located
  449. # This is ignored if set*contentsaftertitlepage is set
  450. set_default('INLINE_CONTENTS', 1);
  451. # if set, do redirection files for renamed nodes
  452. set_default('RENAMED_NODES_REDIRECTIONS', undef);
  453. # if set, do about
  454. set_default('DO_ABOUT', 0);
  455. # symbol put at the beginning of nodes entry in menu (and optionnaly of
  456. # unnumbered in menus, see UNNUMBERED_SYMBOL_IN_MENU variable)
  457. $MENU_SYMBOL = '*';
  458. # symbol put at the end of nodes entry in menu
  459. $MENU_ENTRY_COLON = ':';
  460. # symbol put at the end of index entries
  461. $INDEX_ENTRY_COLON = ':';
  462. # if set, then use node names in menu entries, instead of section names
  463. set_default('NODE_NAME_IN_MENU', 1);
  464. # if set always separate description and menu link, even in
  465. # preformatted environment
  466. set_default('SEPARATE_DESCRIPTION', 0);
  467. # try up sections to complete the node directions
  468. set_default('USE_UP_FOR_ADJACENT_NODES', 0);
  469. # use accesskey in hrefs
  470. set_default('USE_ACCESSKEY', 1);
  471. # use rel= and rev= in hrefs. Currently only rel is used
  472. set_default('USE_REL_REV', 1);
  473. # generate <link> elements in head
  474. set_default('USE_LINKS', 1);
  475. # if this variable is true, numeric entities are used when there is no
  476. # corresponding textual entity.
  477. set_default('USE_NUMERIC_ENTITY', 0);
  478. # if set and SPLIT is set, then split index pages at the next letter
  479. # after they have more than that many entries
  480. set_default('SPLIT_INDEX', 0);
  481. # extensions used for images
  482. @IMAGE_EXTENSIONS = ('png','jpg', 'txt');
  483. set_default('USE_NODES', 1);
  484. set_default('USE_SECTIONS', 1);
  485. # also set by command line options
  486. set_default('footnotestyle', 'end');
  487. set_default('DOCTYPE', '');
  488. set_default('USE_ISO', 0);
  489. set_default('NUMBER_SECTIONS', 1);
  490. set_default('TOP_FILE', '');
  491. set_default('ENABLE_ENCODING', 0);
  492. #
  493. # Formatting functions
  494. #
  495. # They will be reset here between formats switch
  496. # if they are defined in this function.
  497. #
  498. # these are more or less the documented vanilla versions, so they
  499. # are reset
  500. $unknown = \&t2h_default_unknown;
  501. $unknown_style = \&t2h_default_unknown_style;
  502. $external_ref = \&t2h_default_external_ref;
  503. $internal_ref = \&t2h_default_internal_ref;
  504. $tab_item_texi = \&t2h_default_tab_item_texi;
  505. $complex_format = \&t2h_default_complex_format;
  506. $toc_body = \&T2H_DEFAULT_toc_body;
  507. $misc_command_line = \&t2h_default_misc_command_line;
  508. $misc_command_line_texi = \&t2h_default_misc_command_line;
  509. $print_title = \&T2H_DEFAULT_print_title;
  510. # reset in info and xml
  511. $element_heading = \&t2h_default_element_heading;
  512. # reset in html
  513. $inline_contents = \&T2H_DEFAULT_inline_contents;
  514. # reset in docbook and info.
  515. $style = \&T2H_GPL_style;
  516. $format = \&T2H_GPL_format;
  517. # reset in info
  518. $simple_command = \&t2h_default_simple_command;
  519. # reset in info
  520. $thing_command = \&t2h_default_thing_command;
  521. # reset in html and xml
  522. $caption_shortcaption = \&t2h_default_caption_shortcaption;
  523. $caption_shortcaption_command = \&t2h_default_caption_shortcaption_command;
  524. # reset in docbook and xml. Not really vanilla, but documented.
  525. $printindex = \&t2h_GPL_default_printindex;
  526. # reset by xml and html
  527. $misc_element_label = \&t2h_default_misc_element_label;
  528. # set in html
  529. $init_out = \&t2h_default_init_out;
  530. # set in info and xml
  531. $paragraph_style_command = \&t2h_default_paragraph_style_command;
  532. # set in info
  533. $colon_command = \&t2h_default_colon_command;
  534. # set in docbook
  535. $quotation_prepend_text = \&t2h_default_quotation_prepend_text;
  536. # set in info
  537. $copying_comment = \&t2h_default_copying_comment;
  538. # set in html and info
  539. $print_section = \&T2H_DEFAULT_print_section;
  540. # set in docbook and xml
  541. %colon_command_punctuation_characters = (
  542. '.' => '.',
  543. ':' => ':',
  544. '?' => '?',
  545. '!' => '!'
  546. );
  547. # in info
  548. $footnote_texi = undef;
  549. $begin_paragraph_texi = undef;
  550. $begin_style_texi = undef;
  551. $begin_special_region = undef;
  552. $end_special_region = undef;
  553. $empty_preformatted = undef;
  554. %line_command_map = (
  555. 'title' => '',
  556. 'subtitle' => '',
  557. 'author' => '',
  558. );
  559. %format_in_paragraph = (
  560. );
  561. # map mapping css specification to style
  562. %css_map =
  563. (
  564. );
  565. @text_substitutions_normal = ();
  566. @text_substitutions_texi = ();
  567. @text_substitutions_simple_format = ();
  568. @text_substitutions_pre = ();
  569. %region_formats_kept = ();
  570. %style_map_texi = ();
  571. t2h_default_copy_style_map (\%default_style_map_texi, \%style_map_texi);
  572. # reset in info
  573. %simple_map_texi = %default_simple_map;
  574. # modified in docbook
  575. %special_accents = (
  576. 'ringaccent' => 'aA',
  577. "'" => 'aeiouyAEIOUY',
  578. ',' => 'cC',
  579. '^' => 'aeiouAEIOU',
  580. '`' => 'aeiouAEIOU',
  581. '~' => 'nNaoAO',
  582. '"' => 'aeiouyAEIOU',
  583. # according to http://www2.lib.virginia.edu/small/vhp/download/ISO.txt
  584. # however this doesn't seems to work in firefox
  585. # 'ogonek' => 'aeiuAEIU',
  586. );
  587. # modified by info, xml, docbook
  588. # %no_paragraph_commands should not be reset since it has been
  589. # filled with defaults for many other commands.
  590. # FIXME this prevents the user from setting those entries.
  591. $no_paragraph_commands{'cindex'} = 1;
  592. $no_paragraph_commands{'float'} = 1;
  593. delete $no_paragraph_commands{'anchor'};
  594. # modified in docbook and xml
  595. %stop_paragraph_command = (
  596. 'titlefont' => 1,
  597. 'insertcopying' => 1,
  598. 'sp' => 1,
  599. 'verbatiminclude' => 1,
  600. 'page' => 1,
  601. # FIXME they also stop preformatted, so cannot be here.
  602. # 'printindex' => 1,
  603. # 'listoffloats' => 1
  604. );
  605. }
  606. sub t2h_default_raw_text_load()
  607. {
  608. set_default('SPLIT', '');
  609. # extension for nodes files when NODE_FILES is true
  610. set_default('NODE_FILE_EXTENSION', 'txt');
  611. # extension
  612. set_default('EXTENSION', 'txt');
  613. @T2H_FORMAT_EXPAND = ('plaintext');
  614. set_default('USE_TITLEPAGE_FOR_TITLE', 0);
  615. set_default('HEADERS', 0);
  616. set_default('SIMPLE_MENU', 1);
  617. set_default('INLINE_INSERTCOPYING', 0);
  618. # reset here, in case it was set to something else by another
  619. # format.
  620. set_default('TOP_NODE_FILE', undef);
  621. %simple_map = %default_simple_map;
  622. %simple_map_pre = %simple_map;
  623. %things_map = %default_things_map;
  624. %pre_map = %things_map;
  625. %style_map = ();
  626. %style_map_pre = ();
  627. t2h_default_copy_style_map (\%default_style_map, \%style_map);
  628. t2h_default_copy_style_map (\%default_style_map_pre, \%style_map_pre);
  629. # could also be t2h_default_set_iso_symbols()
  630. t2h_remove_text_substitutions("'", 1, 0, 0, 1);
  631. t2h_remove_text_substitutions('`', 1, 0, 0, 1);
  632. set_default('OPEN_QUOTE_SYMBOL', '`');
  633. set_default('CLOSE_QUOTE_SYMBOL', "'");
  634. $BEFORE_OVERVIEW = "";
  635. $AFTER_OVERVIEW = "";
  636. $BEFORE_TOC_LINES = "";
  637. $AFTER_TOC_LINES = "";
  638. foreach my $complex_format ('example', 'smallexample', 'display',
  639. 'smalldisplay', 'lisp', 'smalllisp', 'format', 'smallformat',
  640. 'menu', 'detailmenu', 'direntry', 'menu_comment')
  641. {
  642. $complex_format_map{$complex_format}->{'begin'} = '';
  643. $complex_format_map{$complex_format}->{'end'} = '';
  644. }
  645. %format_map = (
  646. # 'quotation' => 'blockquote',
  647. # lists
  648. # 'itemize' => 'ul',
  649. 'enumerate' => '',
  650. # 'multitable' => 'table',
  651. 'table' => '',
  652. 'vtable' => '',
  653. 'ftable' => '',
  654. 'group' => '',
  655. 'raggedright' => '',
  656. # 'detailmenu' => '',
  657. );
  658. #
  659. # Controls the layout
  660. #
  661. $print_page_head = \&T2H_DEFAULT_print_page_head;
  662. $contents = \&T2H_DEFAULT_contents;
  663. $shortcontents = \&T2H_DEFAULT_shortcontents;
  664. $one_section = \&T2H_DEFAULT_one_section;
  665. $print_Top = \&T2H_DEFAULT_print_Top;
  666. $print_Top_footer = \&T2H_DEFAULT_print_Top_footer;
  667. $print_misc_header = \&T2H_DEFAULT_print_misc_header;
  668. $print_misc_footer = \&T2H_DEFAULT_print_misc_footer;
  669. $print_section_footer = \&T2H_DEFAULT_print_section_footer;
  670. $print_chapter_header = \&T2H_DEFAULT_print_chapter_header;
  671. $print_section_header = \&T2H_DEFAULT_print_section_header;
  672. $print_chapter_footer = \&T2H_DEFAULT_print_chapter_footer;
  673. $print_page_foot = \&T2H_DEFAULT_print_page_foot;
  674. $print_head_navigation = \&T2H_DEFAULT_print_head_navigation;
  675. $print_foot_navigation = \&T2H_DEFAULT_print_foot_navigation;
  676. $end_section = \&T2H_DEFAULT_end_section;
  677. # changed in info
  678. $print_Footnotes = \&T2H_DEFAULT_print_Footnotes;
  679. # used if split
  680. $about_body = \&T2H_DEFAULT_about_body;
  681. $print_navigation = \&T2H_DEFAULT_print_navigation;
  682. #
  683. # Controls the formatting
  684. #
  685. $empty_line = \&t2h_default_empty_line;
  686. $anchor = \&t2h_default_anchor;
  687. $anchor_label = \&t2h_default_anchor_label;
  688. $image = \&t2h_default_image;
  689. $heading = \&t2h_default_heading;
  690. $heading_text = \&t2h_default_heading_text;
  691. $heading_text_preformatted = \&t2h_default_heading_text_preformatted;
  692. $element_label = \&t2h_default_element_label;
  693. $index_entry_label = \&t2h_default_index_entry_label;
  694. #$menu_command = \&t2h_default_menu_command;
  695. $menu_link = \&t2h_default_menu_link;
  696. #$menu_description = \&t2h_default_menu_description;
  697. $paragraph = \&t2h_default_paragraph;
  698. $preformatted = \&t2h_default_preformatted;
  699. $protect_text = \&t2h_default_protect_text;
  700. $normal_text = \&t2h_default_normal_text;
  701. $acronym_like = \&t2h_default_acronym_like;
  702. $sp = \&t2h_default_sp;
  703. $quotation = \&t2h_default_quotation;
  704. $table_list = \&t2h_default_table_list;
  705. $list_item = \&t2h_default_list_item;
  706. $table_line = \&t2h_default_table_line;
  707. $table_item = \&t2h_default_table_item;
  708. $cell = \&t2h_default_cell;
  709. $row = \&t2h_default_row;
  710. $def_item = \&t2h_default_def_item;
  711. $def = \&t2h_default_def;
  712. $def_line = \&t2h_default_def_line;
  713. $cartouche = \&t2h_default_cartouche;
  714. $raw = \&t2h_default_raw;
  715. $format_list_item_texi = \&t2h_default_format_list_item_texi;
  716. $print_index = \&t2h_default_print_index;
  717. $index_summary = \&t2h_default_index_summary;
  718. $index_entry = \&t2h_default_index_entry;
  719. $index_letter = \&t2h_default_index_letter;
  720. $foot_line_and_ref = \&t2h_default_foot_line_and_ref;
  721. $foot_section = \&t2h_default_foot_section;
  722. $tab_item_texi = \&t2h_default_tab_item_texi;
  723. $listoffloats = \&t2h_default_listoffloats;
  724. $listoffloats_entry = \&t2h_default_listoffloats_entry;
  725. $float = \&t2h_default_float;
  726. t2h_default_set_variables_default();
  727. }
  728. my %things_map_xml;
  729. my %pre_map_xml;
  730. sub t2h_default_set_variables_xml()
  731. {
  732. t2h_default_set_variables_default();
  733. set_default('ENABLE_ENCODING_USE_ENTITY', 1);
  734. set_default('EXTENSION', 'xml');
  735. t2h_default_set_iso_symbols(1);
  736. $empty_line = \&t2h_default_empty_line;
  737. $comment = \&xml_default_comment;
  738. $line_command = \&xml_default_line_command;
  739. %things_map = %things_map_xml;
  740. %pre_map = %pre_map_xml;
  741. %simple_format_texi_map = %pre_map;
  742. %simple_format_style_map_texi = ();
  743. t2h_default_copy_style_map (\%default_style_map_texi, \%simple_format_style_map_texi);
  744. foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents))
  745. {
  746. # $simple_format_style_map_texi{$accent_command}->{'args'} = ['normal'];
  747. $simple_format_style_map_texi{$accent_command}->{'function'} = \&xml_default_accent;
  748. }
  749. }
  750. sub t2h_default_set_variables_texi2html()
  751. {
  752. set_default('USE_SETFILENAME', 0);
  753. set_default('USE_SETFILENAME_EXTENSION', 0);
  754. set_default('footnotestyle', 'separate');
  755. set_default('INLINE_CONTENTS', 0);
  756. set_default('FORCE', 1);
  757. set_default('AVOID_MENU_REDUNDANCY', 1);
  758. set_default('TOP_HEADING_AT_BEGINNING', 1);
  759. set_default('TOP_FILE', '');
  760. set_default('USE_ACCESSKEY', 0);
  761. set_default('NODE_NAME_IN_MENU', 0);
  762. set_default('OVERVIEW_LINK_TO_TOC', 0);
  763. set_default('USE_UP_FOR_ADJACENT_NODES', 1);
  764. set_default('USE_REL_REV', 0);
  765. set_default('USE_LINKS', 0);
  766. set_default('USE_NODES', undef);
  767. set_default('USE_SECTIONS', 1);
  768. set_default('NODE_FILENAMES', 0);
  769. set_default('USE_NUMERIC_ENTITY', 1);
  770. set_default('SPLIT', '');
  771. set_default('SPLIT_INDEX', 100);
  772. set_default('PROGRAM_NAME_IN_FOOTER', 1);
  773. set_default('HEADER_IN_TABLE', 1);
  774. set_default('SHORT_REF', 0);
  775. set_default('USE_TITLEPAGE_FOR_TITLE', 1);
  776. set_default('DO_ABOUT', 1);
  777. $MENU_ENTRY_COLON = '';
  778. $INDEX_ENTRY_COLON = '';
  779. #@LINKS_BUTTONS =
  780. # (
  781. # 'Top', 'Index', 'Contents', 'About', 'Up', 'NextFile', 'PrevFile'
  782. # );
  783. set_default('ENABLE_ENCODING_USE_ENTITY', 1);
  784. }
  785. # specify in this array which "buttons" should appear in which order
  786. # in the navigation panel for sections; use ' ' for empty buttons (space)
  787. @SECTION_BUTTONS =
  788. (
  789. 'FastBack', 'Back', 'Up', 'Forward', 'FastForward',
  790. ' ', ' ', ' ', ' ',
  791. 'Top', 'Contents', 'Index', 'About',
  792. );
  793. # buttons for misc stuff
  794. @MISC_BUTTONS = ('Top', 'Contents', 'Index', 'About');
  795. @TOP_BUTTONS = ( 'Back', 'Forward', ' ','Contents', 'Index', 'About');
  796. #@TOP_BUTTONS = ('Top', 'Contents', 'Index', 'About');
  797. # buttons for chapter file footers
  798. # (and headers but only if HEADERS is false)
  799. @CHAPTER_BUTTONS =
  800. (
  801. 'FastBack', 'FastForward', ' ',
  802. ' ', ' ', ' ', ' ',
  803. 'Top', 'Contents', 'Index', 'About',
  804. );
  805. # buttons for section file footers
  806. @SECTION_FOOTER_BUTTONS =
  807. (
  808. 'FastBack', 'Back', 'Up', 'Forward', 'FastForward',
  809. );
  810. @NODE_FOOTER_BUTTONS = @SECTION_BUTTONS;
  811. @LINKS_BUTTONS =
  812. (
  813. 'Top', 'Index', 'Contents', 'About', 'Up', 'NextFile', 'PrevFile'
  814. );
  815. # insert here name of icon images for buttons
  816. # Icons are used, if ICONS and resp. value are set
  817. %ACTIVE_ICONS =
  818. (
  819. 'Top', '',
  820. 'Contents', '',
  821. 'Overview', '',
  822. 'Index', '',
  823. 'This', '',
  824. 'Back', '',
  825. 'FastBack', '',
  826. 'Prev', '',
  827. 'Up', '',
  828. 'Next', '',
  829. 'NodeUp', '',
  830. 'NodeNext', '',
  831. 'NodePrev', '',
  832. 'NodeForward', '',
  833. 'NodeBack', '',
  834. 'Forward', '',
  835. 'FastForward', '',
  836. 'About' , '',
  837. 'First', '',
  838. 'Last', '',
  839. 'NextFile', '',
  840. 'PrevFile', '',
  841. ' ', '',
  842. );
  843. # insert here name of icon images for these, if button is inactive
  844. %PASSIVE_ICONS =
  845. (
  846. 'Top', '',
  847. 'Contents', '',
  848. 'Overview', '',
  849. 'Index', '',
  850. 'This', '',
  851. 'Back', '',
  852. 'FastBack', '',
  853. 'Prev', '',
  854. 'Up', '',
  855. 'Next', '',
  856. 'NodeUp', '',
  857. 'NodeNext', '',
  858. 'NodePrev', '',
  859. 'NodeForward', '',
  860. 'NodeBack', '',
  861. 'Forward', '',
  862. 'FastForward', '',
  863. 'About', '',
  864. 'First', '',
  865. 'Last', '',
  866. 'NextFile', '',
  867. 'PrevFile', '',
  868. );
  869. %misc_pages_targets = (
  870. 'Overview' => 'SEC_Overview',
  871. 'Contents' => 'SEC_Contents',
  872. 'Footnotes' => 'SEC_Foot',
  873. 'About' => 'SEC_About'
  874. );
  875. # determine the null devices
  876. my $default_null_device = File::Spec->devnull();
  877. %null_device_file = (
  878. $default_null_device => 1
  879. );
  880. # special case, djgpp recognizes both null devices
  881. if ($Config{osname} eq 'dos' and $Config{osvers} eq 'djgpp')
  882. {
  883. $null_device_file{'/dev/null'} = 1;
  884. $null_device_file{'NUL'} = 1;
  885. }
  886. %texi2dvi_formats = (
  887. 'dvi' => 1,
  888. 'pdf' => 1,
  889. 'ps' => 1
  890. );
  891. $finish_out = \&t2h_default_finish_out;
  892. $translate_names = \&t2h_default_translate_names;
  893. sub t2h_default_translate_names()
  894. {
  895. # Names of text as alternative for icons
  896. # FIXME maybe get those in simple_format?
  897. %NAVIGATION_TEXT =
  898. (
  899. 'Top', gdt('Top'),
  900. 'Contents', gdt('Contents'),
  901. 'Overview', gdt('Overview'),
  902. 'Index', gdt('Index'),
  903. ' ', ' ',
  904. 'This', gdt('Current'),
  905. 'Back', ' < ',
  906. 'FastBack', ' << ',
  907. 'Prev', gdt('Previous'),
  908. 'Up', gdt('Up'),
  909. 'Next', gdt('Next'),
  910. 'NodeUp', gdt('Up'),
  911. 'NodeNext', gdt('Next'),
  912. 'NodePrev', gdt('Previous'),
  913. 'NodeForward', gdt('Forward node'),
  914. 'NodeBack', gdt('Back node'),
  915. 'Forward', ' > ',
  916. 'FastForward', ' >> ',
  917. 'About', ' ? ',
  918. 'First', ' |< ',
  919. 'Last', ' >| ',
  920. 'NextFile', gdt('Next file'),
  921. 'PrevFile', gdt('Previous file'),
  922. );
  923. %BUTTONS_TEXT = %NAVIGATION_TEXT;
  924. %BUTTONS_GOTO =
  925. (
  926. 'Top', gdt('Cover (top) of document'),
  927. 'Contents', gdt('Table of contents'),
  928. 'Overview', gdt('Short table of contents'),
  929. 'Index', gdt('Index'),
  930. 'This', gdt('Current section'),
  931. 'Back', gdt('Previous section in reading order'),
  932. 'FastBack', gdt('Beginning of this chapter or previous chapter'),
  933. 'Prev', gdt('Previous section on same level'),
  934. 'Up', gdt('Up section'),
  935. 'Next', gdt('Next section on same level'),
  936. 'NodeUp', gdt('Up node'),
  937. 'NodeNext', gdt('Next node'),
  938. 'NodePrev', gdt('Previous node'),
  939. 'NodeForward', gdt('Next node in node reading order'),
  940. 'NodeBack', gdt('Previous node in node reading order'),
  941. 'Forward', gdt('Next section in reading order'),
  942. 'FastForward', gdt('Next chapter'),
  943. 'About' , gdt('About (help)'),
  944. 'First', gdt('First section in reading order'),
  945. 'Last', gdt('Last section in reading order'),
  946. 'NextFile', gdt('Forward section in next file'),
  947. 'PrevFile', gdt('Back section in previous file'),
  948. );
  949. %BUTTONS_NAME =
  950. (
  951. 'Top', gdt('Top'),
  952. 'Contents', gdt('Contents'),
  953. 'Overview', gdt('Overview'),
  954. 'Index', gdt('Index'),
  955. ' ', ' ',
  956. 'This', gdt('This'),
  957. 'Back', gdt('Back'),
  958. 'FastBack', gdt('FastBack'),
  959. 'Prev', gdt('Prev'),
  960. 'Up', gdt('Up'),
  961. 'Next', gdt('Next'),
  962. 'NodeUp', gdt('NodeUp'),
  963. 'NodeNext', gdt('NodeNext'),
  964. 'NodePrev', gdt('NodePrev'),
  965. 'NodeForward', gdt('NodeForward'),
  966. 'NodeBack', gdt('NodeBack'),
  967. 'Forward', gdt('Forward'),
  968. 'FastForward', gdt('FastForward'),
  969. 'About', gdt('About'),
  970. 'First', gdt('First'),
  971. 'Last', gdt('Last'),
  972. 'NextFile', gdt('NextFile'),
  973. 'PrevFile', gdt('PrevFile'),
  974. );
  975. }
  976. sub t2h_default_set_iso_symbols($;$$)
  977. {
  978. my $value = shift;
  979. my $from_cmd_line = shift;
  980. my $from_document = shift;
  981. if ($from_cmd_line)
  982. {
  983. main::set_from_cmdline('USE_ISO', $value);
  984. }
  985. elsif ($from_document)
  986. {
  987. set_from_document('USE_ISO', $value);
  988. }
  989. else
  990. {
  991. set_default('USE_ISO', $value);
  992. }
  993. my ($open_quote, $close_quote);
  994. if ($value)
  995. {
  996. foreach my $association ([\%things_map, \%things_map_xml],
  997. [\%pre_map, \%pre_map_xml],
  998. [\%simple_format_simple_map_texi, \%pre_map_xml])
  999. {
  1000. foreach my $thing (keys(%{$association->[0]}))
  1001. {
  1002. if (defined($association->[0]->{$thing}) and $association->[0]->{$thing} !~ /^\&\w+\;$/ and defined($association->[1]->{$thing}) and $association->[1]->{$thing} =~ /^\&\w+\;$/)
  1003. {
  1004. $association->[0]->{$thing} = $association->[1]->{$thing};
  1005. }
  1006. }
  1007. }
  1008. t2h_add_text_substitutions(["'", '&rsquo;'], 1, 0, 0, 1);
  1009. t2h_add_text_substitutions(['`', '&lsquo;'], 1, 0, 0, 1);
  1010. $open_quote = '&lsquo;';
  1011. $close_quote = '&rsquo;';
  1012. }
  1013. else
  1014. {
  1015. foreach my $association ([\%things_map, \%default_things_map],
  1016. [\%pre_map, \%default_things_map],
  1017. [\%simple_format_simple_map_texi, \%default_things_map])
  1018. {
  1019. foreach my $thing (keys(%{$association->[0]}))
  1020. {
  1021. if (defined($association->[0]->{$thing}) and $association->[0]->{$thing} =~ /^\&\w+\;$/ and defined($association->[1]->{$thing}) and $association->[1]->{$thing} !~ /^\&\w+\;$/)
  1022. {
  1023. $association->[0]->{$thing} = &$protect_text($association->[1]->{$thing});
  1024. }
  1025. }
  1026. }
  1027. t2h_remove_text_substitutions("'", 1, 0, 0, 1);
  1028. t2h_remove_text_substitutions('`', 1, 0, 0, 1);
  1029. $open_quote = '`';
  1030. $close_quote = "'";
  1031. }
  1032. if ($from_cmd_line)
  1033. {
  1034. main::set_from_cmdline('OPEN_QUOTE_SYMBOL', $open_quote);
  1035. main::set_from_cmdline('CLOSE_QUOTE_SYMBOL', $close_quote);
  1036. }
  1037. elsif ($from_document)
  1038. {
  1039. main::set_from_document('OPEN_QUOTE_SYMBOL', $open_quote);
  1040. main::set_from_document('CLOSE_QUOTE_SYMBOL', $close_quote);
  1041. }
  1042. else
  1043. {
  1044. set_default('OPEN_QUOTE_SYMBOL', $open_quote);
  1045. set_default('CLOSE_QUOTE_SYMBOL', $close_quote);
  1046. }
  1047. }
  1048. # is used in main program for dumping texi too.
  1049. sub t2h_default_set_out_encoding()
  1050. {
  1051. # set in reverse order of precedence, such that later setting
  1052. # override the first settings.
  1053. my $out_encoding_from_documentencoding = main::encoding_alias (get_conf('documentencoding'), undef, 'determining encoding from documentencoding');
  1054. set_from_document('OUT_ENCODING', $out_encoding_from_documentencoding) if (defined($out_encoding_from_documentencoding));
  1055. set_from_document('OUT_ENCODING', get_conf('IN_ENCODING')) if (defined(get_conf('IN_ENCODING')));
  1056. my $out_encoding_from_encoding_name = main::encoding_alias (get_conf('ENCODING_NAME'), undef, 'determining encoding from default encoding');
  1057. set_from_document('OUT_ENCODING', $out_encoding_from_encoding_name) if (defined($out_encoding_from_encoding_name));
  1058. main::document_warn (__("Document encoding is utf8, but there is no unicode support")) if (defined(get_conf('OUT_ENCODING')) and get_conf('OUT_ENCODING') eq 'utf-8' and !get_conf('USE_UNICODE'));
  1059. set_from_document('ENCODING_NAME', 'us-ascii');
  1060. set_from_document('ENCODING_NAME', $perl_charset_to_html{get_conf('DEFAULT_ENCODING')}) if (defined(get_conf('DEFAULT_ENCODING')) and defined($perl_charset_to_html{get_conf('DEFAULT_ENCODING')}));
  1061. set_from_document('ENCODING_NAME', get_conf('documentencoding')) if (defined(get_conf('documentencoding')));
  1062. set_from_document('ENCODING_NAME', get_conf('IN_ENCODING')) if (defined(get_conf('IN_ENCODING')));
  1063. set_from_document('ENCODING_NAME', get_conf('OUT_ENCODING')) if (defined(get_conf('OUT_ENCODING')));
  1064. set_from_document('ENCODING_NAME', $perl_charset_to_html{get_conf('documentencoding')}) if (defined(get_conf('documentencoding')) and defined($perl_charset_to_html{get_conf('documentencoding')}));
  1065. set_from_document('ENCODING_NAME', $perl_charset_to_html{get_conf('IN_ENCODING')}) if (defined(get_conf('IN_ENCODING')) and defined($perl_charset_to_html{get_conf('IN_ENCODING')}));
  1066. set_from_document('ENCODING_NAME', $perl_charset_to_html{get_conf('OUT_ENCODING')}) if (defined(get_conf('OUT_ENCODING')) and defined($perl_charset_to_html{get_conf('OUT_ENCODING')}));
  1067. if (get_conf('VERBOSE'))
  1068. {
  1069. # verbose output
  1070. my $out_encoding = get_conf('OUT_ENCODING');
  1071. $out_encoding = 'UNDEF' if (!defined($out_encoding));
  1072. my $in_encoding = get_conf('IN_ENCODING');
  1073. $in_encoding = 'UNDEF' if (!defined($in_encoding));
  1074. my $document_encoding = get_conf('documentencoding');
  1075. $document_encoding = 'UNDEF' if (!defined($document_encoding));
  1076. my $encoding_name = get_conf('ENCODING_NAME');
  1077. print STDERR "# Encodings: doc $document_encoding, in $in_encoding out $out_encoding, name $encoding_name\n";
  1078. }
  1079. }
  1080. sub t2h_default_init_out()
  1081. {
  1082. &$translate_names;
  1083. # set external cross ref splitting like splitting.
  1084. if (get_conf('SPLIT'))
  1085. {
  1086. set_from_document('EXTERNAL_CROSSREF_SPLIT', 1);
  1087. }
  1088. else
  1089. {
  1090. set_from_document('EXTERNAL_CROSSREF_SPLIT', 0);
  1091. }
  1092. }
  1093. my %t2h_default_formats_load_table = (
  1094. 'html' => \&html_default_load,
  1095. 'info' => \&info_default_load,
  1096. 'docbook' => \&docbook_default_load,
  1097. 'xml' => \&xml_default_load,
  1098. 'plaintext' => \&plaintext_default_load,
  1099. 'raw-text' => \&t2h_default_raw_text_load,
  1100. );
  1101. sub t2h_default_load_format($;$)
  1102. {
  1103. my $format = shift;
  1104. my $from_command_line = shift;
  1105. if (defined($t2h_default_formats_load_table{$format}) or $texi2dvi_formats{$format})
  1106. {
  1107. $OUTPUT_FORMAT = $format;
  1108. &{$t2h_default_formats_load_table{$format}}($from_command_line) unless ($texi2dvi_formats{$format});
  1109. $Texi2HTML::THISDOC{'format_from_command_line'} = $format if ($from_command_line);
  1110. return 1;
  1111. }
  1112. else
  1113. {
  1114. return 0;
  1115. }
  1116. }
  1117. sub t2h_encoding_is_entity($)
  1118. {
  1119. my $text = shift;
  1120. return 0 if (!get_conf('ENABLE_ENCODING_USE_ENTITY'));
  1121. return 1 if ($text =~ /^&/ and $text =~ /;$/);
  1122. }
  1123. # this is for info.pm
  1124. use vars qw(%t2h_enable_encoding_default_accent);
  1125. my @t2h_enable_encoding_accents_stack;
  1126. my %t2h_enable_encoding_default_commands;
  1127. sub t2h_enable_encoding_load()
  1128. {
  1129. t2h_default_push_handler(\&t2h_enable_encoding_init, \@command_handler_names);
  1130. t2h_default_push_handler(\&t2h_enable_encoding_finish, \@command_handler_finish);
  1131. #push @command_handler_process, \&t2h_enable_encoding_init;
  1132. #push @command_handler_finish, \&t2h_enable_encoding_finish;
  1133. foreach my $key (keys(%unicode_accents), 'dotless')
  1134. {
  1135. $t2h_enable_encoding_default_accent{'normal'}->{$key} = $style_map{$key}->{'function'};
  1136. $t2h_enable_encoding_default_accent{'texi'}->{$key} = $style_map_texi{$key}->{'function'};
  1137. $t2h_enable_encoding_default_accent{'pre'}->{$key} = $style_map_pre{$key}->{'function'};
  1138. $style_map{$key}->{'function'} = \&t2h_enable_encoding_normal_accent;
  1139. $style_map_texi{$key}->{'function'} = \&t2h_enable_encoding_texi_accent;
  1140. $style_map_pre{$key}->{'function'} = \&t2h_enable_encoding_pre_accent;
  1141. }
  1142. foreach my $key (%things_map)
  1143. {
  1144. if (exists($unicode_map{$key}) and ($unicode_map{$key} ne ''))
  1145. {
  1146. $t2h_enable_encoding_default_commands{'normal'}->{$key} = $things_map{$key};
  1147. $t2h_enable_encoding_default_commands{'texi'}->{$key} = $texi_map{$key};
  1148. $t2h_enable_encoding_default_commands{'sorting'}->{$key} = $sorting_things_map{$key};
  1149. $t2h_enable_encoding_default_commands{'pre'}->{$key} = $pre_map{$key};
  1150. }
  1151. }
  1152. }
  1153. sub t2h_enable_encoding_finish()
  1154. {
  1155. foreach my $key (%things_map)
  1156. {
  1157. if (exists($unicode_map{$key}) and ($unicode_map{$key} ne ''))
  1158. {
  1159. $things_map{$key} = $t2h_enable_encoding_default_commands{'normal'}->{$key};
  1160. $texi_map{$key} = $t2h_enable_encoding_default_commands{'texi'}->{$key};
  1161. $sorting_things_map{$key} = $t2h_enable_encoding_default_commands{'sorting'}->{$key};
  1162. $pre_map{$key} = $t2h_enable_encoding_default_commands{'pre'}->{$key};
  1163. }
  1164. }
  1165. }
  1166. sub t2h_enable_encoding_init()
  1167. {
  1168. if (get_conf('ENCODING_NAME') eq 'utf-8')
  1169. {
  1170. foreach my $key (%things_map)
  1171. {
  1172. if (exists($unicode_map{$key}) and ($unicode_map{$key} ne ''))
  1173. {
  1174. $things_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($things_map{$key}));
  1175. $texi_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($texi_map{$key}));
  1176. $sorting_things_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($sorting_things_map{$key}));
  1177. $pre_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($pre_map{$key}));
  1178. }
  1179. }
  1180. }
  1181. elsif (exists($makeinfo_encoding_to_map{get_conf('ENCODING_NAME')}))
  1182. {
  1183. my $enc_map = $makeinfo_encoding_to_map{get_conf('ENCODING_NAME')};
  1184. foreach my $key (%things_map)
  1185. {
  1186. if (exists($unicode_map{$key}) and ($unicode_map{$key} ne '') and
  1187. exists($makeinfo_unicode_to_eight_bit{$enc_map}->{$unicode_map{$key}}))
  1188. { # we let perl handle the conversion
  1189. $things_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($things_map{$key}));
  1190. $texi_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($texi_map{$key}));
  1191. $sorting_things_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($sorting_things_map{$key}));
  1192. $pre_map{$key} = chr(hex($unicode_map{$key})) unless (t2h_encoding_is_entity($pre_map{$key}));
  1193. }
  1194. }
  1195. @t2h_enable_encoding_accents_stack = ();
  1196. }
  1197. }
  1198. sub t2h_default_string_width($)
  1199. {
  1200. my $string = shift;
  1201. if (get_conf('USE_UNICODE'))
  1202. {
  1203. my $width = 0;
  1204. foreach my $character(split '', $string)
  1205. {
  1206. if ($character =~ /\p{Unicode::EastAsianWidth::InFullwidth}/)
  1207. {
  1208. $width += 2;
  1209. }
  1210. else
  1211. {
  1212. $width += 1;
  1213. }
  1214. }
  1215. return $width;
  1216. }
  1217. else
  1218. {
  1219. return length($string);
  1220. }
  1221. }
  1222. sub t2h_default_finish_out()
  1223. {
  1224. }
  1225. ########################################################################
  1226. # Control of Page layout:
  1227. # You can make changes of the Page layout at two levels:
  1228. # 1.) For small changes, it is often enough to change the value of
  1229. # some global string/hash/array variables
  1230. # 2.) For larger changes, reimplement one of the T2H_DEFAULT_<fnc>* routines,
  1231. # give them another name, and assign them to the respective
  1232. # $<fnc> variable.
  1233. # As a general interface, the hashes Texi2HTML::HREF, Texi2HTML::NAME, Texi2HTML::NODE, Texi2HTML::NO_TEXI, Texi2HTML::SIMPLE_TEXT hold
  1234. # href, html-name, node-name, name after removal of texi commands of
  1235. # This -- current section (resp. html page)
  1236. # Top -- top element
  1237. # Contents -- Table of contents element
  1238. # Overview -- Short table of contents element
  1239. # Index -- Index page element
  1240. # About -- page which explain "navigation buttons" element
  1241. # First -- first node element
  1242. # Last -- last node element
  1243. #
  1244. # Whether or not the following hash values are set, depends on the context
  1245. # (all values are w.r.t. 'This' section)
  1246. # Next -- next element of texinfo
  1247. # Prev -- previous element of texinfo
  1248. # NodeUp -- up node of texinfo
  1249. # NodeForward -- next node in node reading order, taking menu into account
  1250. # NodeBack -- previous node in node reading order, taking menu into account
  1251. # Forward -- next node in reading order
  1252. # Back -- previous node in reading order
  1253. # Up -- parent given by sectioning commands
  1254. # FastForward -- if leave node, up and next, else next node
  1255. # FastBack -- if leave node, up and prev, else prev node
  1256. #
  1257. # Furthermore, the following global variabels are set:
  1258. # $Texi2HTML::THISDOC{'title'} -- title as set by @title...
  1259. # $Texi2HTML::THISDOC{'title_no_texi'} -- title without texi (without html elements)
  1260. # $Texi2HTML::THISDOC{'title_texi'} -- title with texinfo @-commands
  1261. # $Texi2HTML::THISDOC{'fulltitle'} -- full title as set by @title...
  1262. # $Texi2HTML::THISDOC{'subtitle'} -- subtitle as set by @subtitle
  1263. # $Texi2HTML::THISDOC{'author'} -- author as set by @author
  1264. # $Texi2HTML::THISDOC{'copying_comment'} -- text of @copying and @end copying in comment
  1265. #
  1266. # $Texi2HTML::THISDOC{'program'} -- name of program generating the output
  1267. # $Texi2HTML::THISDOC{'program_homepage'} -- homepage of program
  1268. # $Texi2HTML::THISDOC{'toc_file} -- table of contents file
  1269. # $Texi2HTML::THISDOC{'file_base_name'} -- base name of the texinfo manual file
  1270. # $Texi2HTML::THISDOC{'input_file_name'} -- name of the texinfo manual file
  1271. # $Texi2HTML::THISDOC{'destination_directory'}
  1272. # -- directory for the resulting files
  1273. # $Texi2HTML::THISDOC{'css_import_lines'} -- ref on @import lines in css files
  1274. # $Texi2HTML::THISDOC{'css_rule_lines'} -- ref on css rules lines
  1275. #
  1276. # and pointer to arrays of lines which need to be printed by main::print_lines
  1277. # $Texi2HTML::THIS_SECTION -- lines of 'This' section
  1278. # $Texi2HTML::OVERVIEW -- lines of short table of contents
  1279. # $Texi2HTML::TOC_LINES -- lines of table of contents
  1280. # $Texi2HTML::TITLEPAGE -- lines of title page
  1281. #
  1282. # $Texi2HTML::THIS_ELEMENT holds the element reference.
  1283. # most of the functions are either reset when switching format, in
  1284. # t2h_default_set_variables_default, or set in format, the simplest
  1285. # one being setup above in t2h_default_raw_text_load
  1286. #
  1287. # The following generic subs control the layout:
  1288. #
  1289. # misc element formatting functions. They are rather generic,
  1290. # their call is controlled by other variables (separate or not
  1291. # footnotes, about_body, handling of table of contents...).
  1292. # print_Footnotes is the only to be redefined, in info
  1293. $print_Toc = \&T2H_DEFAULT_print_Toc;
  1294. $print_Overview = \&T2H_DEFAULT_print_Overview;
  1295. $print_About = \&T2H_DEFAULT_print_About;
  1296. $print_misc = \&T2H_DEFAULT_print_misc;
  1297. # generic enough (call print_page_head if needed)
  1298. $print_Top_header = \&T2H_DEFAULT_print_Top_header;
  1299. # the following are less generic, but in case a specific format
  1300. # doesn't redefine them, the raw text functions are always defined.
  1301. $print_page_head = \&T2H_DEFAULT_print_page_head;
  1302. $contents = \&T2H_DEFAULT_contents;
  1303. $shortcontents = \&T2H_DEFAULT_shortcontents;
  1304. $one_section = \&T2H_DEFAULT_one_section;
  1305. $print_Top = \&T2H_DEFAULT_print_Top;
  1306. $print_Top_footer = \&T2H_DEFAULT_print_Top_footer;
  1307. $print_misc_header = \&T2H_DEFAULT_print_misc_header;
  1308. $print_misc_footer = \&T2H_DEFAULT_print_misc_footer;
  1309. $print_section_footer = \&T2H_DEFAULT_print_section_footer;
  1310. $print_chapter_header = \&T2H_DEFAULT_print_chapter_header;
  1311. $print_section_header = \&T2H_DEFAULT_print_section_header;
  1312. $print_chapter_footer = \&T2H_DEFAULT_print_chapter_footer;
  1313. $print_page_foot = \&T2H_DEFAULT_print_page_foot;
  1314. $print_head_navigation = \&T2H_DEFAULT_print_head_navigation;
  1315. $print_foot_navigation = \&T2H_DEFAULT_print_foot_navigation;
  1316. $end_section = \&T2H_DEFAULT_end_section;
  1317. # changed in info
  1318. $print_Footnotes = \&T2H_DEFAULT_print_Footnotes;
  1319. # used if split
  1320. $about_body = \&T2H_DEFAULT_about_body;
  1321. $print_navigation = \&T2H_DEFAULT_print_navigation;
  1322. #
  1323. # generic formatting functions
  1324. #
  1325. $button_icon_img = \&T2H_DEFAULT_button_icon_img;
  1326. # not really needed nor relevant except for html
  1327. $print_frame = \&T2H_DEFAULT_print_frame;
  1328. $print_toc_frame = \&T2H_DEFAULT_print_toc_frame;
  1329. # generic
  1330. $titlepage = \&T2H_DEFAULT_titlepage;
  1331. $css_lines = \&T2H_DEFAULT_css_lines;
  1332. $print_redirection_page = \&T2H_DEFAULT_print_redirection_page;
  1333. $node_file_name = \&T2H_DEFAULT_node_file_name;
  1334. $inline_contents = \&T2H_DEFAULT_inline_contents;
  1335. $program_string = \&T2H_DEFAULT_program_string;
  1336. $element_file_name = \&t2h_default_element_file_name;
  1337. ########################################################################
  1338. # Layout for every sections
  1339. #
  1340. sub T2H_DEFAULT_print_section($$$$)
  1341. {
  1342. my $fh = shift;
  1343. my $first_in_page = shift;
  1344. my $previous_is_top = shift;
  1345. my $element = shift;
  1346. my $nw = main::print_lines($fh);
  1347. }
  1348. sub T2H_DEFAULT_one_section($$)
  1349. {
  1350. my $fh = shift;
  1351. my $element = shift;
  1352. main::print_lines($fh);
  1353. &$print_page_foot($fh);
  1354. }
  1355. ###################################################################
  1356. # Layout of top-page. It is possible to use @ifnothtml, @ifhtml,
  1357. # @html within the Top texinfo node to specify content of top-level
  1358. # page.
  1359. #
  1360. sub T2H_DEFAULT_print_Top_header($$)
  1361. {
  1362. my $fh = shift;
  1363. my $do_page_head = shift;
  1364. &$print_page_head($fh) if ($do_page_head);
  1365. }
  1366. sub T2H_DEFAULT_print_Top_footer($$$)
  1367. {
  1368. my $fh = shift;
  1369. my $end_page = shift;
  1370. my $element = shift;
  1371. if ($end_page)
  1372. {
  1373. &$print_page_foot($fh);
  1374. }
  1375. }
  1376. sub T2H_DEFAULT_print_Top($$$)
  1377. {
  1378. my $fh = shift;
  1379. my $has_top_heading = shift;
  1380. my $element = shift;
  1381. if (get_conf('setshortcontentsaftertitlepage'))
  1382. {
  1383. my $shortcontents = &$inline_contents($fh, 'shortcontents');
  1384. print $fh "".join('',@$shortcontents) if (defined($shortcontents));
  1385. }
  1386. if (get_conf('setcontentsaftertitlepage'))
  1387. {
  1388. my $contents = &$inline_contents($fh, 'contents');
  1389. print $fh "".join('',@$contents) if (defined($contents));
  1390. }
  1391. main::print_lines($fh, $Texi2HTML::THIS_SECTION);
  1392. }
  1393. ###################################################################
  1394. # Layout of Toc, Overview, and Footnotes pages
  1395. # By default, we use "normal" layout
  1396. # Texi2HTML::HREF of Next, Prev, Up, Forward, Back, etc are not defined
  1397. # redefine \@MISC_BUTTONS to change the navigation
  1398. sub T2H_DEFAULT_print_Toc
  1399. {
  1400. return &$print_misc(@_);
  1401. }
  1402. sub T2H_DEFAULT_print_Overview
  1403. {
  1404. return &$print_misc(@_);
  1405. }
  1406. sub T2H_DEFAULT_print_Footnotes
  1407. {
  1408. return &$print_misc(@_);
  1409. }
  1410. sub T2H_DEFAULT_print_About
  1411. {
  1412. return &$print_misc(@_);
  1413. }
  1414. sub T2H_DEFAULT_print_misc_header($$$$)
  1415. {
  1416. my $fh = shift;
  1417. my $buttons = shift;
  1418. my $new_file = shift;
  1419. my $misc_page = shift;
  1420. &$print_page_head($fh) if ($new_file);
  1421. }
  1422. sub T2H_DEFAULT_print_misc_footer($$$)
  1423. {
  1424. my $fh = shift;
  1425. my $buttons = shift;
  1426. my $new_file = shift;
  1427. if ($new_file)
  1428. {
  1429. &$print_page_foot($fh);
  1430. }
  1431. }
  1432. use vars qw(
  1433. %t2h_default_underline_symbol
  1434. );
  1435. %t2h_default_underline_symbol = (
  1436. 0 => '*',
  1437. 1 => '*',
  1438. 2 => '=',
  1439. 3 => '-',
  1440. 4 => '.'
  1441. );
  1442. sub t2h_default_heading_text($$$)
  1443. {
  1444. my $command = shift;
  1445. my $text = shift;
  1446. my $level = shift;
  1447. return '' if ($text !~ /\S/);
  1448. my $result = $text ."\n";
  1449. # as seen in encodings/nodetest_utf8_no_unicode, the length can be in
  1450. # bytes (certainly) when there hasn't been a require Encode
  1451. #$result .=($t2h_default_underline_symbol{$level} x length($text))."\n";
  1452. $result .=($t2h_default_underline_symbol{$level} x t2h_default_string_width($text))."\n";
  1453. return $result;
  1454. }
  1455. sub t2h_default_heading_text_preformatted($$$)
  1456. {
  1457. my $command = shift;
  1458. my $text = shift;
  1459. my $level = shift;
  1460. return t2h_default_heading_text($command, $text, $level);
  1461. }
  1462. sub T2H_DEFAULT_print_misc($$$)
  1463. {
  1464. my $fh = shift;
  1465. my $new_file = shift;
  1466. my $misc_page = shift;
  1467. my $buttons = \@MISC_BUTTONS;
  1468. &$print_misc_header($fh, $buttons, $new_file, $misc_page);
  1469. print $fh "".&$heading_text('misc heading', $Texi2HTML::NAME{This}, 1) . "\n";
  1470. main::print_lines($fh);
  1471. &$print_misc_footer($fh, $buttons, $new_file);
  1472. }
  1473. ##################################################################
  1474. # section_footer is only called if SPLIT eq 'section'
  1475. # section_footer: after print_section of last section, before print_page_foot
  1476. #
  1477. sub T2H_DEFAULT_print_section_footer
  1478. {
  1479. my $fh = shift;
  1480. my $element = shift;
  1481. }
  1482. ###################################################################
  1483. # chapter_header and chapter_footer are only called if
  1484. # SPLIT eq 'chapter'
  1485. # chapter_header: after print_page_head, before print_section
  1486. # chapter_footer: after print_section of last section, before print_page_foot
  1487. sub T2H_DEFAULT_print_chapter_header($$)
  1488. {
  1489. my $fh = shift;
  1490. my $element = shift;
  1491. }
  1492. sub T2H_DEFAULT_print_chapter_footer($$)
  1493. {
  1494. my $fh = shift;
  1495. my $element = shift;
  1496. }
  1497. sub T2H_DEFAULT_print_section_header($$)
  1498. {
  1499. my $fh = shift;
  1500. my $element = shift;
  1501. }
  1502. ###################################################################
  1503. # Layout of standard header and footer
  1504. #
  1505. sub T2H_DEFAULT_print_page_head($)
  1506. {
  1507. my $fh = shift;
  1508. }
  1509. sub T2H_DEFAULT_program_string()
  1510. {
  1511. my $date = get_conf('today');
  1512. $date = '' if (!defined($date));
  1513. if ($date ne '')
  1514. {
  1515. return gdt('This document was generated on @emph{{date}} using @uref{{program_homepage}, @emph{{program}}}.', {
  1516. 'date' => $date, 'program_homepage' => $Texi2HTML::THISDOC{'program_homepage'}, 'program' => $Texi2HTML::THISDOC{'program_and_version'} },{'duplicate'=>1});
  1517. }
  1518. return gdt('This document was generated using @uref{{program_homepage}, @emph{{program}}}.', {
  1519. 'program_homepage' => $Texi2HTML::THISDOC{'program_homepage'}, 'program'
  1520. => $Texi2HTML::THISDOC{'program_and_version'} },{'duplicate'=>1});
  1521. }
  1522. sub T2H_DEFAULT_end_section($$$)
  1523. {
  1524. my $fh = shift;
  1525. my $misc_or_top_and_section_separation = shift;
  1526. my $element = shift;
  1527. }
  1528. sub T2H_DEFAULT_print_page_foot($)
  1529. {
  1530. my $fh = shift;
  1531. }
  1532. ###################################################################
  1533. # Layout of navigation panel
  1534. sub T2H_DEFAULT_print_head_navigation($$$$$)
  1535. {
  1536. my $fh = shift;
  1537. my $buttons = shift;
  1538. my $first_in_page = shift;
  1539. my $previous_is_top = shift;
  1540. my $element = shift;
  1541. return '';
  1542. }
  1543. sub T2H_DEFAULT_print_foot_navigation($$$$$;$)
  1544. {
  1545. my $fh = shift;
  1546. my $buttons = shift;
  1547. my $rule = shift;
  1548. my $print_navigation_panel = shift;
  1549. my $element = shift;
  1550. my $maybe_in_page = shift;
  1551. $rule = '' if (!defined($rule));
  1552. print $fh "$rule\n" if ($rule ne '');
  1553. }
  1554. ######################################################################
  1555. # navigation panel
  1556. #
  1557. # how to create IMG tag
  1558. # this is only used in html, and only if ICONS is set and the button
  1559. # is active.
  1560. sub T2H_DEFAULT_button_icon_img
  1561. {
  1562. my $button = shift;
  1563. my $icon = shift;
  1564. my $name = shift;
  1565. return '' if (!defined($icon));
  1566. $button = "" if (!defined ($button));
  1567. $name = '' if (!defined($name));
  1568. my $alt = '';
  1569. if ($name ne '')
  1570. {
  1571. if ($button ne '')
  1572. {
  1573. $alt = "$button: $name";
  1574. }
  1575. else
  1576. {
  1577. $alt = $name;
  1578. }
  1579. }
  1580. else
  1581. {
  1582. $alt = $button;
  1583. }
  1584. return "$icon $alt";
  1585. }
  1586. sub T2H_DEFAULT_print_navigation
  1587. {
  1588. my $buttons = shift;
  1589. my $vertical = shift;
  1590. return '';
  1591. }
  1592. ######################################################################
  1593. # Frames: this is from "Richard Y. Kim" <ryk@coho.net>
  1594. # Should be improved to be more conforming to other _print* functions
  1595. # toc_file and main_file passed as args are relative to the texinfo manual
  1596. # location, and therefore are not used.
  1597. # no-ops in the default case, doesn't really make sense if output is
  1598. # not html
  1599. sub T2H_DEFAULT_print_frame
  1600. {
  1601. my $fh = shift;
  1602. my $toc_file = shift;
  1603. my $main_file = shift;
  1604. $main_file = $Texi2HTML::THISDOC{'filename'}->{'top'};
  1605. $toc_file = $Texi2HTML::THISDOC{'filename'}->{'toc_frame'};
  1606. }
  1607. sub T2H_DEFAULT_print_toc_frame
  1608. {
  1609. my $fh = shift;
  1610. my $stoc_lines = shift;
  1611. }
  1612. # This subroutine is intended to fill @Texi2HTML::TOC_LINES and
  1613. # @Texi2HTML::OVERVIEW with the table of contents and short table of
  1614. # contents.
  1615. #
  1616. # arguments:
  1617. # ref on an array containing all the elements
  1618. # each element is a reference on a hash. The following keys might be of
  1619. # use:
  1620. # 'top': true if this is the top element
  1621. # 'toc_level': level of the element in the table of content. Highest level
  1622. # is 1 for the @top element and for chapters, appendix and so on,
  1623. # 2 for section, unnumberedsec and so on...
  1624. # 'tocid': label used for reference linking to the element in table of
  1625. # contents
  1626. # 'file': the file containing the element, usefull to do href to that file
  1627. # in case the document is split.
  1628. # 'text': text of the element, with section number
  1629. # 'text_nonumber': text of the element, without section number
  1630. # Relevant configuration variables are:
  1631. # $NO_BULLET_LIST_ATTRIBUTE: usefull in case a list is used
  1632. # $FRAMES: @Texi2HTML::OVERVIEW is used in one of the frames.
  1633. # $BEFORE_OVERVIEW
  1634. # $AFTER_OVERVIEW
  1635. # $BEFORE_TOC_LINES
  1636. # $AFTER_TOC_LINES
  1637. # get_conf('contents')
  1638. # get_conf('shortcontents')
  1639. sub T2H_DEFAULT_contents($$)
  1640. {
  1641. my $elements = shift;
  1642. my $toc_file = shift;
  1643. my @result;
  1644. return unless (get_conf('contents'));
  1645. foreach my $element (@$elements)
  1646. {
  1647. my $level = $element->{'toc_level'};
  1648. $level = 1 if ($level < 1);
  1649. my $text = $element->{'text'};
  1650. my $result = (' ' x ($level - 1)) . $text ."\n";
  1651. push @result, $result;
  1652. }
  1653. if (@result)
  1654. {
  1655. unshift @result, $BEFORE_TOC_LINES;
  1656. push @result, $AFTER_TOC_LINES;
  1657. }
  1658. return \@result;
  1659. }
  1660. sub T2H_DEFAULT_shortcontents($$)
  1661. {
  1662. my $elements = shift;
  1663. my $stoc_file = shift;
  1664. my @result;
  1665. return unless (get_conf('shortcontents'));
  1666. foreach my $element (@$elements)
  1667. {
  1668. my $level = $element->{'toc_level'};
  1669. next if ($level > 1);
  1670. $level = 1 if ($level < 1);
  1671. my $text = $element->{'text'};
  1672. push @result, $text ."\n";
  1673. }
  1674. if (@result)
  1675. {
  1676. unshift @result, $BEFORE_OVERVIEW;
  1677. push @result, $AFTER_OVERVIEW;
  1678. }
  1679. return \@result;
  1680. }
  1681. sub T2H_DEFAULT_print_title()
  1682. {
  1683. my $element = shift;
  1684. return undef unless (get_conf('SHOW_TITLE'));
  1685. if (get_conf('USE_TITLEPAGE_FOR_TITLE'))
  1686. {
  1687. my ($titlepage_text, $titlepage_no_texi, $titlepage_simple_format) = main::do_special_region_lines('titlepage',$Texi2HTML::THISDOC{'state'});
  1688. &$titlepage([],$titlepage_text, $titlepage_no_texi, $titlepage_simple_format);
  1689. return $Texi2HTML::TITLEPAGE;
  1690. }
  1691. else
  1692. {
  1693. my $title = '';
  1694. $title = $Texi2HTML::THISDOC{'simpletitle'} if (defined($Texi2HTML::THISDOC{'simpletitle'}) and $Texi2HTML::THISDOC{'simpletitle'} !~ /^\s*$/);
  1695. if ($title ne '')
  1696. {
  1697. return &$heading_text('@settitle', $title, 0) . "\n";
  1698. }
  1699. }
  1700. }
  1701. sub T2H_DEFAULT_toc_body($)
  1702. {
  1703. my $elements_list = shift;
  1704. my $toc_lines = &$contents($elements_list, $Texi2HTML::THISDOC{'toc_file'});
  1705. @{$Texi2HTML::TOC_LINES} = @$toc_lines if ($toc_lines);
  1706. my $stoc_lines = &$shortcontents($elements_list, $Texi2HTML::THISDOC{'stoc_file'});
  1707. @{$Texi2HTML::OVERVIEW} = @$stoc_lines if ($stoc_lines);
  1708. }
  1709. # element and elements_list may not be undef when called from the
  1710. # main program, but may be if called from other customization function,
  1711. # for example, here, print_Top.
  1712. sub T2H_DEFAULT_inline_contents($$$$)
  1713. {
  1714. my $fh = shift;
  1715. my $command = shift;
  1716. my $element = shift;
  1717. my $elements_list = shift;
  1718. my $name;
  1719. my $lines;
  1720. my $toc_file;
  1721. $toc_file = $element->{'file'} if (defined($element));
  1722. my $result = undef;
  1723. if ($command eq 'contents')
  1724. {
  1725. $name = $Texi2HTML::NAME{'Contents'};
  1726. $toc_file = $Texi2HTML::THISDOC{'toc_file'} if (!defined($toc_file));
  1727. if (defined($elements_list))
  1728. {
  1729. $lines = &$contents($elements_list, $toc_file);
  1730. }
  1731. else
  1732. {
  1733. $lines = $Texi2HTML::TOC_LINES;
  1734. }
  1735. }
  1736. else
  1737. {
  1738. $name = $Texi2HTML::NAME{'Overview'};
  1739. $toc_file = $Texi2HTML::THISDOC{'stoc_file'} if (!defined($toc_file));
  1740. if (defined($elements_list))
  1741. {
  1742. $lines = &$shortcontents($elements_list, $toc_file);
  1743. }
  1744. else
  1745. {
  1746. $lines = $Texi2HTML::OVERVIEW;
  1747. }
  1748. }
  1749. if ($lines and @{$lines})
  1750. {
  1751. $result = [ &$heading_text("\@$command", $name, 1), "\n" ];
  1752. my $contents_anchor = &$anchor($element->{'id'});
  1753. if (defined($contents_anchor) and $contents_anchor =~ /\S/)
  1754. {
  1755. unshift @$result, $contents_anchor."\n";
  1756. }
  1757. push @$result, (@$lines, "\n");
  1758. }
  1759. return $result;
  1760. }
  1761. sub T2H_DEFAULT_css_lines ($$)
  1762. {
  1763. my $import_lines = shift;
  1764. my $rule_lines = shift;
  1765. return if ((!@$rule_lines and !@$import_lines and !keys(%css_map) and !@CSS_REFS) or get_conf('NO_CSS'));
  1766. my $css_text = "<style type=\"text/css\">\n<!--\n";
  1767. $css_text .= join('',@$import_lines) . "\n" if (@$import_lines);
  1768. foreach my $css_rule (sort(keys(%css_map)))
  1769. {
  1770. next unless ($css_map{$css_rule});
  1771. $css_text .= "$css_rule {$css_map{$css_rule}}\n";
  1772. }
  1773. $css_text .= join('',@$rule_lines) . "\n" if (@$rule_lines);
  1774. $css_text .= "-->\n</style>\n";
  1775. foreach my $ref (@CSS_REFS)
  1776. {
  1777. $css_text .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"$ref\">\n";
  1778. }
  1779. set_from_document('CSS_LINES', $css_text);
  1780. }
  1781. ######################################################################
  1782. # About page
  1783. #
  1784. # PRE_ABOUT can be a function reference or a scalar.
  1785. # Note that if it is a scalar, T2H_InitGlobals has not been called,
  1786. # and all global variables like $ADDRESS are not available.
  1787. $PRE_ABOUT = sub
  1788. {
  1789. return ' ' . &$program_string() . "\n";
  1790. };
  1791. # If customizing $AFTER_ABOUT, be sure to put the content inside <p></p>.
  1792. $AFTER_ABOUT = '';
  1793. %BUTTONS_EXAMPLE =
  1794. (
  1795. 'Top', ' ',
  1796. 'Contents', ' ',
  1797. 'Overview', ' ',
  1798. 'Index', ' ',
  1799. 'This', '1.2.3',
  1800. 'Back', '1.2.2',
  1801. 'FastBack', '1',
  1802. 'Prev', '1.2.2',
  1803. 'Up', '1.2',
  1804. 'Next', '1.2.4',
  1805. 'NodeUp', '1.2',
  1806. 'NodeNext', '1.2.4',
  1807. 'NodePrev', '1.2.2',
  1808. 'NodeForward', '1.2.4',
  1809. 'NodeBack', '1.2.2',
  1810. 'Forward', '1.2.4',
  1811. 'FastForward', '2',
  1812. 'About', ' ',
  1813. 'First', '1.',
  1814. 'Last', '1.2.4',
  1815. 'NextFile', ' ',
  1816. 'PrevFile', ' ',
  1817. );
  1818. sub T2H_DEFAULT_about_body
  1819. {
  1820. my $about = "";
  1821. if (ref($PRE_ABOUT) eq 'CODE')
  1822. {
  1823. $about .= &$PRE_ABOUT();
  1824. }
  1825. else
  1826. {
  1827. $about .= $PRE_ABOUT;
  1828. }
  1829. return $about;
  1830. }
  1831. # return value is currently ignored
  1832. sub T2H_DEFAULT_titlepage($$$$)
  1833. {
  1834. my $titlepage_lines = shift;
  1835. my $titlepage_text = shift;
  1836. my $titlepage_no_texi = shift;
  1837. my $titlepage_simple_format = shift;
  1838. $Texi2HTML::TITLEPAGE = $titlepage_text;
  1839. if ($titlepage_text eq '')
  1840. {
  1841. my $title = '';
  1842. $title = $Texi2HTML::THISDOC{'simpletitle'} if (defined($Texi2HTML::THISDOC{'simpletitle'}) and $Texi2HTML::THISDOC{'simpletitle'} !~ /^\s*$/);
  1843. if ($title ne '')
  1844. {
  1845. $Texi2HTML::TITLEPAGE = &$heading_text('@settitle', $title, 0);
  1846. $Texi2HTML::TITLEPAGE .= "$DEFAULT_RULE\n";
  1847. }
  1848. }
  1849. else
  1850. {
  1851. $Texi2HTML::TITLEPAGE .= "$DEFAULT_RULE\n";
  1852. }
  1853. if (get_conf('setcontentsaftertitlepage') and (defined($Texi2HTML::THISDOC{'inline_contents'}->{'contents'})) and @{$Texi2HTML::THISDOC{'inline_contents'}->{'contents'}})
  1854. {
  1855. foreach my $line(@{$Texi2HTML::THISDOC{'inline_contents'}->{'contents'}})
  1856. {
  1857. $Texi2HTML::TITLEPAGE .= $line;
  1858. }
  1859. $Texi2HTML::TITLEPAGE .= "$DEFAULT_RULE\n";
  1860. }
  1861. if (get_conf('setshortcontentsaftertitlepage') and (defined($Texi2HTML::THISDOC{'inline_contents'}->{'shortcontents'})) and @{$Texi2HTML::THISDOC{'inline_contents'}->{'shortcontents'}})
  1862. {
  1863. foreach my $line(@{$Texi2HTML::THISDOC{'inline_contents'}->{'shortcontents'}})
  1864. {
  1865. $Texi2HTML::TITLEPAGE .= $line;
  1866. }
  1867. $Texi2HTML::TITLEPAGE .= "$DEFAULT_RULE\n";
  1868. }
  1869. return $Texi2HTML::TITLEPAGE;
  1870. }
  1871. sub T2H_DEFAULT_print_redirection_page()
  1872. {
  1873. #return "Redirection files are not of use for the current format.\n";
  1874. return undef;
  1875. }
  1876. sub T2H_DEFAULT_node_file_name($$)
  1877. {
  1878. my $node = shift;
  1879. my $type = shift;
  1880. return undef if ($node->{'external_node'}
  1881. or ($type eq 'top' and !get_conf('NEW_CROSSREF_STYLE')));
  1882. my $node_file_base;
  1883. if ($type eq 'top' and defined(get_conf('TOP_NODE_FILE')))
  1884. {
  1885. $node_file_base = get_conf('TOP_NODE_FILE');
  1886. }
  1887. elsif (get_conf('NEW_CROSSREF_STYLE'))
  1888. {
  1889. if (get_conf('TRANSLITERATE_FILE_NAMES'))
  1890. {
  1891. $node_file_base = $node->{'cross_manual_file'};
  1892. }
  1893. else
  1894. {
  1895. $node_file_base = $node->{'cross_manual_target'};
  1896. }
  1897. }
  1898. else
  1899. {
  1900. $node_file_base = main::remove_texi($node->{'texi'});
  1901. $node_file_base =~ s/[^\w\.\-]/-/g;
  1902. }
  1903. if (defined(get_conf('NODE_FILE_EXTENSION')) and get_conf('NODE_FILE_EXTENSION') ne '')
  1904. {
  1905. return ($node_file_base . '.' . get_conf('NODE_FILE_EXTENSION'));
  1906. }
  1907. return $node_file_base;
  1908. }
  1909. ########################################################################
  1910. # Control of formatting:
  1911. # 1.) For some changes, it is often enough to change the value of
  1912. # some global map. It might necessitate building a little
  1913. # function along with the change in hash, if the change is the use
  1914. # of another function (in style_map).
  1915. # 2.) For other changes, reimplement one of the t2h_default_<fnc>* routines,
  1916. # give them another name, and assign them to the respective
  1917. # $<fnc> variable (below).
  1918. %deprecated_commands = (
  1919. 'ctrl' => '',
  1920. 'allow-recursion' => N__('recursion is always allowed'),
  1921. 'quote-arg' => N__('arguments are quoted by default'),
  1922. );
  1923. #
  1924. # This hash should have keys corresponding with the nonletter command accent
  1925. # whose following character is considered to be the argument
  1926. # This hash associates an accent macro to the ISO name for the accent if any.
  1927. # The customary use of this map is to find the ISO name appearing in html
  1928. # entity (like &eacute;) associated with a texinfo accent macro.
  1929. #
  1930. # The keys of the hash are
  1931. # ": umlaut
  1932. # ~: tilda accent
  1933. # ^: circumflex accent
  1934. # `: grave accent
  1935. # ': acute accent
  1936. # =: macron accent
  1937. %accent_map = (
  1938. '"', 'uml',
  1939. '~', 'tilde',
  1940. '^', 'circ',
  1941. '`', 'grave',
  1942. "'", 'acute',
  1943. ",", 'cedil',
  1944. '=', '',
  1945. 'ringaccent', 'ring',
  1946. 'H', '',
  1947. 'dotaccent', '',
  1948. 'u', '',
  1949. 'ubaraccent', '',
  1950. 'udotaccent', '',
  1951. 'v', '',
  1952. 'ogonek', 'ogon',
  1953. );
  1954. #
  1955. # ascii representation of texinfo "simple things" @-commands
  1956. %default_simple_map = (
  1957. '*', "\n",
  1958. ' ', ' ',
  1959. "\t", ' ',
  1960. "\n", ' ',
  1961. '-', '', # hyphenation hint
  1962. '|', '', # used in formatting commands @evenfooting and friends
  1963. '/', '',
  1964. ':', '',
  1965. '!', '!',
  1966. '?', '?',
  1967. '.', '.',
  1968. '@', '@',
  1969. '}', '}',
  1970. '{', '{',
  1971. );
  1972. # texinfo "simple things" @-commands
  1973. %simple_map = %default_simple_map;
  1974. # this map is used in preformatted text
  1975. %simple_map_pre = %simple_map;
  1976. # This map is used when texi elements are removed and replaced
  1977. # by simple text
  1978. %simple_map_texi = %default_simple_map;
  1979. # maps for the math specific commands
  1980. %simple_map_math = (
  1981. '\\', '\\'
  1982. );
  1983. #%simple_map_pre_math = %simple_map_math;
  1984. #%simple_map_texi_math = %simple_map_math;
  1985. $punctuation_characters = '.?!';
  1986. $after_punctuation_characters = '"\')]';
  1987. %default_things_map = (
  1988. 'TeX' => 'TeX',
  1989. 'LaTeX' => 'LaTeX',
  1990. 'bullet' => '*',
  1991. 'copyright' => '(C)',
  1992. 'registeredsymbol' => '(R)',
  1993. 'dots' => '...',
  1994. 'enddots' => '...',
  1995. 'equiv' => '==',
  1996. # FIXME i18n
  1997. 'error' => 'error-->',
  1998. 'expansion' => '==>',
  1999. 'arrow' => '->',
  2000. 'minus' => '-',
  2001. 'point' => '-!-',
  2002. 'print' => '-|',
  2003. 'result' => '=>',
  2004. 'today' => '',
  2005. 'aa' => 'aa',
  2006. 'AA' => 'AA',
  2007. 'ae' => 'ae',
  2008. 'oe' => 'oe',
  2009. 'AE' => 'AE',
  2010. 'OE' => 'OE',
  2011. 'o' => '/o',
  2012. 'O' => '/O',
  2013. 'ss' => 'ss',
  2014. 'l' => '/l',
  2015. 'L' => '/L',
  2016. 'DH' => 'D',
  2017. 'dh' => 'd',
  2018. 'TH' => 'TH', # http://www.evertype.com/standards/wynnyogh/thorn.html
  2019. 'th' => 'th',
  2020. 'exclamdown' => '!',
  2021. 'questiondown' => '?',
  2022. 'pounds' => '#',
  2023. 'ordf' => 'a',
  2024. 'ordm' => 'o',
  2025. 'comma' => ',',
  2026. 'euro' => 'Euro',
  2027. 'geq' => '>=',
  2028. 'leq' => '<=',
  2029. 'tie' => ' ',
  2030. 'textdegree' => 'o',
  2031. 'quotedblleft' => '``',
  2032. 'quotedblright' => "''",
  2033. 'quoteleft' => '`',
  2034. 'quoteright' => "'",
  2035. 'quotedblbase' => ',,',
  2036. 'quotesinglbase' => ',',
  2037. 'guillemetleft' => '<<',
  2038. 'guillemetright' => '>>',
  2039. 'guillemotleft' => '<<',
  2040. 'guillemotright' => '>>',
  2041. 'guilsinglleft' => '<',
  2042. 'guilsinglright' => '>',
  2043. );
  2044. %things_map = %default_things_map;
  2045. # This map is used in preformatted environments
  2046. %pre_map = %things_map;
  2047. # used in math. If not found, pre_map is used.
  2048. %math_map = ();
  2049. # text replacing macros when texi commands are removed and plain text is
  2050. # produced.
  2051. %texi_map = %default_things_map;
  2052. # used for index sorting.
  2053. %sorting_things_map = %default_things_map;
  2054. foreach my $accent_letter ('o','O','l','L')
  2055. {
  2056. $sorting_things_map{$accent_letter} = $accent_letter;
  2057. }
  2058. $sorting_things_map{'copyright'} = 'C';
  2059. $sorting_things_map{'registeredsymbol'} = 'R';
  2060. $sorting_things_map{'today'} = 't';
  2061. %default_texi_map = %texi_map;
  2062. #
  2063. # texinfo "things" (@foo{}) to XML ones
  2064. #
  2065. %things_map_xml = (
  2066. 'TeX' => 'TeX',
  2067. 'LaTeX' => 'LaTeX',
  2068. # pertusus: unknown by makeinfo, not in texinfo manual (@* is the right thing)
  2069. # 'br', '<br>', # paragraph break
  2070. 'bullet' => '&bull;',
  2071. # #'copyright' => '(C)',
  2072. 'copyright' => '&copy;',
  2073. 'registeredsymbol' => '&reg;',
  2074. 'dots' => '&hellip;',
  2075. 'enddots' => '...',
  2076. 'equiv' => '&equiv;',
  2077. # FIXME i18n
  2078. 'error' => 'error--&gt;',
  2079. 'expansion' => '&rarr;',
  2080. 'arrow' => '&rarr;',
  2081. 'minus' => '-',
  2082. 'point' => '&lowast;',
  2083. 'print' => '-|',
  2084. 'result' => '&rArr;',
  2085. # set in code using the language
  2086. # 'today', &pretty_date,
  2087. 'today' => '',
  2088. 'aa' => '&aring;',
  2089. 'AA' => '&Aring;',
  2090. 'ae' => '&aelig;',
  2091. 'oe' => '&oelig;', #pertusus: also &#156;. &oelig; not in html 3.2
  2092. 'AE' => '&AElig;',
  2093. 'OE' => '&OElig;', #pertusus: also &#140;. &OElig; not in html 3.2
  2094. 'o' => '&oslash;',
  2095. 'O' => '&Oslash;',
  2096. 'ss' => '&szlig;',
  2097. 'DH' => '&ETH;',
  2098. 'dh' => '&eth;',
  2099. 'TH' => '&THORN;',
  2100. 'th' => '&thorn;',
  2101. 'l' => '&#322;',
  2102. 'L' => '&#321;',
  2103. 'exclamdown' => '&iexcl;',
  2104. 'questiondown' => '&iquest;',
  2105. 'pounds' => '&pound;',
  2106. 'ordf' => '&ordf;',
  2107. 'ordm' => '&ordm;',
  2108. 'comma' => ',',
  2109. 'euro' => '&euro;',
  2110. 'geq' => '&ge;',
  2111. 'leq' => '&le;',
  2112. 'tie' => '&nbsp;',
  2113. 'textdegree' => '&deg;',
  2114. 'quotedblleft' => '&ldquo;',
  2115. 'quotedblright' => '&rdquo;',
  2116. 'quoteleft' => '&lsquo;',
  2117. 'quoteright' => '&rsquo;',
  2118. 'quotedblbase' => '&bdquo;',
  2119. 'quotesinglbase' => '&sbquo;',
  2120. 'guillemetleft' => '&laquo;',
  2121. 'guillemetright' => '&raquo;',
  2122. 'guillemotleft' => '&laquo;',
  2123. 'guillemotright' => '&raquo;',
  2124. 'guilsinglleft' => '&lsaquo;',
  2125. 'guilsinglright' => '&rsaquo;',
  2126. );
  2127. # This map is used in preformatted environments
  2128. %pre_map_xml = %things_map_xml;
  2129. # taken from
  2130. #Latin extended additionnal
  2131. #http://www.alanwood.net/unicode/latin_extended_additional.html
  2132. #C1 Controls and Latin-1 Supplement
  2133. #http://www.alanwood.net/unicode/latin_1_supplement.html
  2134. #Latin Extended-A
  2135. #http://www.alanwood.net/unicode/latin_extended_a.html
  2136. #Latin Extended-B
  2137. #http://www.alanwood.net/unicode/latin_extended_b.html
  2138. #dotless i: 0131
  2139. #http://www.alanwood.net/unicode/arrows.html 21**
  2140. #http://www.alanwood.net/unicode/general_punctuation.html 20**
  2141. #http://www.alanwood.net/unicode/mathematical_operators.html 22**
  2142. %unicode_map = (
  2143. 'bullet' => '2022',
  2144. 'copyright' => '00A9',
  2145. 'registeredsymbol' => '00AE',
  2146. 'dots' => '2026',
  2147. 'enddots' => '',
  2148. 'equiv' => '2261',
  2149. 'error' => '',
  2150. 'expansion' => '2192',
  2151. 'arrow' => '2192',
  2152. 'minus' => '2212', # in mathematical operators
  2153. # 'minus' => '002D', # in latin1
  2154. 'point' => '2605',
  2155. 'print' => '22A3',
  2156. 'result' => '21D2',
  2157. 'today' => '',
  2158. 'aa' => '00E5',
  2159. 'AA' => '00C5',
  2160. 'ae' => '00E6',
  2161. 'oe' => '0153',
  2162. 'AE' => '00C6',
  2163. 'OE' => '0152',
  2164. 'o' => '00F8',
  2165. 'O' => '00D8',
  2166. 'ss' => '00DF',
  2167. 'DH' => '00D0',
  2168. 'dh' => '00F0',
  2169. 'TH' => '00DE',
  2170. 'th' => '00FE',
  2171. 'l' => '0142',
  2172. 'L' => '0141',
  2173. 'exclamdown' => '00A1',
  2174. 'questiondown' => '00BF',
  2175. 'pounds' => '00A3',
  2176. 'ordf' => '00AA',
  2177. 'ordm' => '00BA',
  2178. 'comma' => '002C',
  2179. 'euro' => '20AC',
  2180. 'geq' => '2265',
  2181. 'leq' => '2264',
  2182. 'tie' => '',
  2183. # 'tie' => '0020',
  2184. 'textdegree' => '00B0',
  2185. 'quotedblleft' => '201C',
  2186. 'quotedblright' => '201D',
  2187. 'quoteleft' => '2018',
  2188. 'quoteright' => '2019',
  2189. 'quotedblbase' => '201E',
  2190. 'quotesinglbase' => '201A',
  2191. 'guillemetleft' => '00AB',
  2192. 'guillemetright' => '00BB',
  2193. 'guillemotleft' => '00AB',
  2194. 'guillemotright' => '00BB',
  2195. 'guilsinglleft' => '2039',
  2196. 'guilsinglright' => '203A',
  2197. );
  2198. %makeinfo_encoding_to_map = (
  2199. "iso-8859-1", 'iso8859_1',
  2200. "iso-8859-2", 'iso8859_2',
  2201. "iso-8859-15", 'iso8859_15',
  2202. "koi8-r", 'koi8',
  2203. "koi8-u", 'koi8',
  2204. );
  2205. foreach my $encoding (keys(%makeinfo_encoding_to_map))
  2206. {
  2207. $t2h_encoding_aliases{$encoding} = $encoding;
  2208. $t2h_encoding_aliases{$makeinfo_encoding_to_map{$encoding}} = $encoding;
  2209. }
  2210. # cut and pasted from eigth_bit_makeinfo_maps.pl, in turn generated with
  2211. # ./parse_8bit_makeinfo_maps.pl
  2212. %makeinfo_unicode_to_eight_bit = (
  2213. 'iso8859_1' => {
  2214. '00A0' => 'A0',
  2215. '00A1' => 'A1',
  2216. '00A2' => 'A2',
  2217. '00A3' => 'A3',
  2218. '00A4' => 'A4',
  2219. '00A5' => 'A5',
  2220. '00A6' => 'A6',
  2221. '00A7' => 'A7',
  2222. '00A8' => 'A8',
  2223. '00A9' => 'A9',
  2224. '00AA' => 'AA',
  2225. '00AB' => 'AB',
  2226. '00AC' => 'AC',
  2227. '00AD' => 'AD',
  2228. '00AE' => 'AE',
  2229. '00AF' => 'AF',
  2230. '00B0' => 'B0',
  2231. '00B1' => 'B1',
  2232. '00B2' => 'B2',
  2233. '00B3' => 'B3',
  2234. '00B4' => 'B4',
  2235. '00B5' => 'B5',
  2236. '00B6' => 'B6',
  2237. '00B7' => 'B7',
  2238. '00B8' => 'B8',
  2239. '00B9' => 'B9',
  2240. '00BA' => 'BA',
  2241. '00BB' => 'BB',
  2242. '00BC' => 'BC',
  2243. '00BD' => 'BD',
  2244. '00BE' => 'BE',
  2245. '00BF' => 'BF',
  2246. '00C0' => 'C0',
  2247. '00C1' => 'C1',
  2248. '00C2' => 'C2',
  2249. '00C3' => 'C3',
  2250. '00C4' => 'C4',
  2251. '00C5' => 'C5',
  2252. '00C6' => 'C6',
  2253. '00C7' => 'C7',
  2254. '00C7' => 'C7',
  2255. '00C8' => 'C8',
  2256. '00C9' => 'C9',
  2257. '00CA' => 'CA',
  2258. '00CB' => 'CB',
  2259. '00CC' => 'CC',
  2260. '00CD' => 'CD',
  2261. '00CE' => 'CE',
  2262. '00CF' => 'CF',
  2263. '00D0' => 'D0',
  2264. '00D1' => 'D1',
  2265. '00D2' => 'D2',
  2266. '00D3' => 'D3',
  2267. '00D4' => 'D4',
  2268. '00D5' => 'D5',
  2269. '00D6' => 'D6',
  2270. '00D7' => 'D7',
  2271. '00D8' => 'D8',
  2272. '00D9' => 'D9',
  2273. '00DA' => 'DA',
  2274. '00DB' => 'DB',
  2275. '00DC' => 'DC',
  2276. '00DD' => 'DD',
  2277. '00DE' => 'DE',
  2278. '00DF' => 'DF',
  2279. '00E0' => 'E0',
  2280. '00E1' => 'E1',
  2281. '00E2' => 'E2',
  2282. '00E3' => 'E3',
  2283. '00E4' => 'E4',
  2284. '00E5' => 'E5',
  2285. '00E6' => 'E6',
  2286. '00E7' => 'E7',
  2287. '00E8' => 'E8',
  2288. '00E9' => 'E9',
  2289. '00EA' => 'EA',
  2290. '00EB' => 'EB',
  2291. '00EC' => 'EC',
  2292. '00ED' => 'ED',
  2293. '00EE' => 'EE',
  2294. '00EF' => 'EF',
  2295. '00F0' => 'F0',
  2296. '00F1' => 'F1',
  2297. '00F2' => 'F2',
  2298. '00F3' => 'F3',
  2299. '00F4' => 'F4',
  2300. '00F5' => 'F5',
  2301. '00F6' => 'F6',
  2302. '00F7' => 'F7',
  2303. '00F8' => 'F8',
  2304. '00F9' => 'F9',
  2305. '00FA' => 'FA',
  2306. '00FB' => 'FB',
  2307. '00FC' => 'FC',
  2308. '00FD' => 'FD',
  2309. '00FE' => 'FE',
  2310. '00FF' => 'FF',
  2311. },
  2312. 'iso8859_15' => {
  2313. '00A0' => 'A0',
  2314. '00A1' => 'A1',
  2315. '00A2' => 'A2',
  2316. '00A3' => 'A3',
  2317. '20AC' => 'A4',
  2318. '00A5' => 'A5',
  2319. '0160' => 'A6',
  2320. '00A7' => 'A7',
  2321. '0161' => 'A8',
  2322. '00A9' => 'A9',
  2323. '00AA' => 'AA',
  2324. '00AB' => 'AB',
  2325. '00AC' => 'AC',
  2326. '00AD' => 'AD',
  2327. '00AE' => 'AE',
  2328. '00AF' => 'AF',
  2329. '00B0' => 'B0',
  2330. '00B1' => 'B1',
  2331. '00B2' => 'B2',
  2332. '00B3' => 'B3',
  2333. '017D' => 'B4',
  2334. '00B5' => 'B5',
  2335. '00B6' => 'B6',
  2336. '00B7' => 'B7',
  2337. '017E' => 'B8',
  2338. '00B9' => 'B9',
  2339. '00BA' => 'BA',
  2340. '00BB' => 'BB',
  2341. '0152' => 'BC',
  2342. '0153' => 'BD',
  2343. '0178' => 'BE',
  2344. '00BF' => 'BF',
  2345. '00C0' => 'C0',
  2346. '00C1' => 'C1',
  2347. '00C2' => 'C2',
  2348. '00C3' => 'C3',
  2349. '00C4' => 'C4',
  2350. '00C5' => 'C5',
  2351. '00C6' => 'C6',
  2352. '00C7' => 'C7',
  2353. '00C8' => 'C8',
  2354. '00C9' => 'C9',
  2355. '00CA' => 'CA',
  2356. '00CB' => 'CB',
  2357. '00CC' => 'CC',
  2358. '00CD' => 'CD',
  2359. '00CE' => 'CE',
  2360. '00CF' => 'CF',
  2361. '00D0' => 'D0',
  2362. '00D1' => 'D1',
  2363. '00D2' => 'D2',
  2364. '00D3' => 'D3',
  2365. '00D4' => 'D4',
  2366. '00D5' => 'D5',
  2367. '00D6' => 'D6',
  2368. '00D7' => 'D7',
  2369. '00D8' => 'D8',
  2370. '00D9' => 'D9',
  2371. '00DA' => 'DA',
  2372. '00DB' => 'DB',
  2373. '00DC' => 'DC',
  2374. '00DD' => 'DD',
  2375. '00DE' => 'DE',
  2376. '00DF' => 'DF',
  2377. '00E0' => 'E0',
  2378. '00E1' => 'E1',
  2379. '00E2' => 'E2',
  2380. '00E3' => 'E3',
  2381. '00E4' => 'E4',
  2382. '00E5' => 'E5',
  2383. '00E6' => 'E6',
  2384. '00E7' => 'E7',
  2385. '00E8' => 'E8',
  2386. '00E9' => 'E9',
  2387. '00EA' => 'EA',
  2388. '00EB' => 'EB',
  2389. '00EC' => 'EC',
  2390. '00ED' => 'ED',
  2391. '00EE' => 'EE',
  2392. '00EF' => 'EF',
  2393. '00F0' => 'F0',
  2394. '00F1' => 'F1',
  2395. '00F2' => 'F2',
  2396. '00F3' => 'F3',
  2397. '00F4' => 'F4',
  2398. '00F5' => 'F5',
  2399. '00F6' => 'F6',
  2400. '00F7' => 'F7',
  2401. '00F8' => 'F8',
  2402. '00F9' => 'F9',
  2403. '00FA' => 'FA',
  2404. '00FB' => 'FB',
  2405. '00FC' => 'FC',
  2406. '00FD' => 'FD',
  2407. '00FE' => 'FE',
  2408. '00FF' => 'FF',
  2409. },
  2410. 'iso8859_2' => {
  2411. '00A0' => 'A0',
  2412. '0104' => 'A1',
  2413. '02D8' => 'A2',
  2414. '0141' => 'A3',
  2415. '00A4' => 'A4',
  2416. '013D' => 'A5',
  2417. '015A' => 'A6',
  2418. '00A7' => 'A7',
  2419. '00A8' => 'A8',
  2420. '015E' => 'AA',
  2421. '0164' => 'AB',
  2422. '0179' => 'AC',
  2423. '00AD' => 'AD',
  2424. '017D' => 'AE',
  2425. '017B' => 'AF',
  2426. '00B0' => 'B0',
  2427. '0105' => 'B1',
  2428. '02DB' => 'B2',
  2429. '0142' => 'B3',
  2430. '00B4' => 'B4',
  2431. '013E' => 'B5',
  2432. '015B' => 'B6',
  2433. '02C7' => 'B7',
  2434. '00B8' => 'B8',
  2435. '0161' => 'B9',
  2436. '015F' => 'BA',
  2437. '0165' => 'BB',
  2438. '017A' => 'BC',
  2439. '02DD' => 'BD',
  2440. '017E' => 'BE',
  2441. '017C' => 'BF',
  2442. '0154' => 'C0',
  2443. '00C1' => 'C1',
  2444. '00C2' => 'C2',
  2445. '0102' => 'C3',
  2446. '00C4' => 'C4',
  2447. '0139' => 'C5',
  2448. '0106' => 'C6',
  2449. '00C7' => 'C7',
  2450. '010C' => 'C8',
  2451. '00C9' => 'C9',
  2452. '0118' => 'CA',
  2453. '00CB' => 'CB',
  2454. '011A' => 'CC',
  2455. '00CD' => 'CD',
  2456. '00CE' => 'CE',
  2457. '010E' => 'CF',
  2458. '0110' => 'D0',
  2459. '0143' => 'D1',
  2460. '0147' => 'D2',
  2461. '00D3' => 'D3',
  2462. '00D4' => 'D4',
  2463. '0150' => 'D5',
  2464. '00D6' => 'D6',
  2465. '00D7' => 'D7',
  2466. '0158' => 'D8',
  2467. '016E' => 'D9',
  2468. '00DA' => 'DA',
  2469. '0170' => 'DB',
  2470. '00DC' => 'DC',
  2471. '00DD' => 'DD',
  2472. '0162' => 'DE',
  2473. '00DF' => 'DF',
  2474. '0155' => 'E0',
  2475. '00E1' => 'E1',
  2476. '00E2' => 'E2',
  2477. '0103' => 'E3',
  2478. '00E4' => 'E4',
  2479. '013A' => 'E5',
  2480. '0107' => 'E6',
  2481. '00E7' => 'E7',
  2482. '010D' => 'E8',
  2483. '00E9' => 'E9',
  2484. '0119' => 'EA',
  2485. '00EB' => 'EB',
  2486. '011B' => 'EC',
  2487. '00ED' => 'ED',
  2488. '00EE' => 'EE',
  2489. '010F' => 'EF',
  2490. '0111' => 'F0',
  2491. '0144' => 'F1',
  2492. '0148' => 'F2',
  2493. '00F3' => 'F3',
  2494. '00F4' => 'F4',
  2495. '0151' => 'F5',
  2496. '00F6' => 'F6',
  2497. '00F7' => 'F7',
  2498. '0159' => 'F8',
  2499. '016F' => 'F9',
  2500. '00FA' => 'FA',
  2501. '0171' => 'FB',
  2502. '00FC' => 'FC',
  2503. '00FD' => 'FD',
  2504. '0163' => 'FE',
  2505. '02D9' => 'FF',
  2506. },
  2507. 'koi8' => {
  2508. '0415' => 'A3',
  2509. '0454' => 'A4',
  2510. '0456' => 'A6',
  2511. '0457' => 'A7',
  2512. '04D7' => 'B3',
  2513. '0404' => 'B4',
  2514. '0406' => 'B6',
  2515. '0407' => 'B7',
  2516. '042E' => 'C0',
  2517. '0430' => 'C1',
  2518. '0431' => 'C2',
  2519. '0446' => 'C3',
  2520. '0434' => 'C4',
  2521. '0435' => 'C5',
  2522. '0444' => 'C6',
  2523. '0433' => 'C7',
  2524. '0445' => 'C8',
  2525. '0438' => 'C9',
  2526. '0439' => 'CA',
  2527. '043A' => 'CB',
  2528. '043B' => 'CC',
  2529. '043C' => 'CD',
  2530. '043D' => 'CE',
  2531. '043E' => 'CF',
  2532. '043F' => 'D0',
  2533. '044F' => 'D1',
  2534. '0440' => 'D2',
  2535. '0441' => 'D3',
  2536. '0442' => 'D4',
  2537. '0443' => 'D5',
  2538. '0436' => 'D6',
  2539. '0432' => 'D7',
  2540. '044C' => 'D8',
  2541. '044B' => 'D9',
  2542. '0437' => 'DA',
  2543. '0448' => 'DB',
  2544. '044D' => 'DC',
  2545. '0449' => 'DD',
  2546. '0447' => 'DE',
  2547. '044A' => 'DF',
  2548. '042D' => 'E0',
  2549. '0410' => 'E1',
  2550. '0411' => 'E2',
  2551. '0426' => 'E3',
  2552. '0414' => 'E4',
  2553. '0415' => 'E5',
  2554. '0424' => 'E6',
  2555. '0413' => 'E7',
  2556. '0425' => 'E8',
  2557. '0418' => 'E9',
  2558. '0419' => 'EA',
  2559. '041A' => 'EB',
  2560. '041B' => 'EC',
  2561. '041C' => 'ED',
  2562. '041D' => 'EE',
  2563. '041E' => 'EF',
  2564. '041F' => 'F0',
  2565. '042F' => 'F1',
  2566. '0420' => 'F2',
  2567. '0421' => 'F3',
  2568. '0422' => 'F4',
  2569. '0423' => 'F5',
  2570. '0416' => 'F6',
  2571. '0412' => 'F7',
  2572. '042C' => 'F8',
  2573. '042B' => 'F9',
  2574. '0417' => 'FA',
  2575. '0428' => 'FB',
  2576. '042D' => 'FC',
  2577. '0429' => 'FD',
  2578. '0427' => 'FE',
  2579. '042A' => 'FF',
  2580. },
  2581. );
  2582. %eight_bit_to_unicode = ();
  2583. foreach my $encoding (keys(%makeinfo_encoding_to_map))
  2584. {
  2585. my $unicode_to_eight = $makeinfo_unicode_to_eight_bit{$makeinfo_encoding_to_map{$encoding}};
  2586. #print STDERR "$encoding, $makeinfo_encoding_to_map{$encoding}, $unicode_to_eight\n";
  2587. foreach my $utf8_key (keys(%{$unicode_to_eight}))
  2588. {
  2589. $eight_bit_to_unicode{$encoding}->{$unicode_to_eight->{$utf8_key}} =
  2590. $utf8_key;
  2591. }
  2592. }
  2593. # currently unused
  2594. my %makeinfo_transliterate_map = (
  2595. '0416' => 'ZH',
  2596. '0447' => 'ch',
  2597. '00EB' => 'e',
  2598. '0414' => 'D',
  2599. '0159' => 'r',
  2600. '00E6' => 'ae',
  2601. '042B' => 'Y',
  2602. '00FA' => 'u',
  2603. '043B' => 'l',
  2604. '00DE' => 'TH',
  2605. '00D9' => 'U',
  2606. '00C4' => 'A',
  2607. '0148' => 'n',
  2608. '00F6' => 'o',
  2609. '0434' => 'd',
  2610. '041E' => 'O',
  2611. '041B' => 'L',
  2612. '044B' => 'y',
  2613. '0107' => 'c',
  2614. '0415' => 'E',
  2615. '00C1' => 'A',
  2616. '00D3' => 'O',
  2617. '00DB' => 'U',
  2618. '016E' => 'U',
  2619. '013A' => 'l',
  2620. '017B' => 'Z',
  2621. '00F1' => 'n',
  2622. '0428' => 'SH',
  2623. '0153' => 'oe',
  2624. '00F4' => 'o',
  2625. '0144' => 'n',
  2626. '0404' => 'IE',
  2627. '0427' => 'CH',
  2628. '0162' => 'T',
  2629. '017A' => 'z',
  2630. '0448' => 'sh',
  2631. '0436' => 'zh',
  2632. '00F9' => 'u',
  2633. '0406' => 'I',
  2634. '0103' => 'a',
  2635. '0422' => 'T',
  2636. '0160' => 'S',
  2637. '0165' => 't',
  2638. '017E' => 'z',
  2639. '00F0' => 'd',
  2640. '043E' => 'o',
  2641. '043D' => 'n',
  2642. '013E' => 'l',
  2643. '0412' => 'V',
  2644. '0111' => 'd',
  2645. '0155' => 's',
  2646. '017C' => 'z',
  2647. '00CE' => 'I',
  2648. '042D' => 'E',
  2649. '00C8' => 'E',
  2650. '00F8' => 'oe',
  2651. '00F2' => 'o',
  2652. '00FF' => 'y',
  2653. '0420' => 'R',
  2654. '0119' => 'e',
  2655. '00D2' => 'O',
  2656. '043C' => 'm',
  2657. '00D0' => 'DH',
  2658. '0179' => 'Z',
  2659. '0110' => 'D',
  2660. '043F' => 'p',
  2661. '0170' => 'U',
  2662. '011A' => 'E',
  2663. '010C' => 'C',
  2664. '015A' => 'S',
  2665. '0433' => 'g',
  2666. '00E1' => 'a',
  2667. '010D' => 'c',
  2668. '00CC' => 'I',
  2669. '016F' => 'u',
  2670. '0457' => 'yi',
  2671. '00C2' => 'A',
  2672. '0438' => 'i',
  2673. '00E3' => 'a',
  2674. '0435' => 'e',
  2675. '0440' => 'r',
  2676. '042A' => 'W',
  2677. '0431' => 'b',
  2678. '00EE' => 'i',
  2679. '0150' => 'O',
  2680. '00E8' => 'e',
  2681. '0418' => 'I',
  2682. '00CF' => 'I',
  2683. '015F' => 's',
  2684. '0142' => 'l',
  2685. '0147' => 'N',
  2686. '00DF' => 'ss',
  2687. '00E5' => 'aa',
  2688. '00C3' => 'A',
  2689. '0106' => 'C',
  2690. '0141' => 'L',
  2691. '0164' => 'T',
  2692. '017D' => 'Z',
  2693. '00EC' => 'i',
  2694. '041C' => 'M',
  2695. '00C9' => 'E',
  2696. '00E0' => 'a',
  2697. '043A' => 'k',
  2698. '00F5' => 'o',
  2699. '042C' => 'X',
  2700. '0449' => 'shch',
  2701. '0444' => 'f',
  2702. '0139' => 'L',
  2703. '0158' => 'R',
  2704. '00F3' => 'o',
  2705. '00FB' => 'u',
  2706. '0424' => 'F',
  2707. '0446' => 'c',
  2708. '0423' => 'U',
  2709. '0442' => 't',
  2710. '00FD' => 'y',
  2711. '0102' => 'A',
  2712. '0104' => 'A',
  2713. '00CB' => 'E',
  2714. '0426' => 'C',
  2715. '00CD' => 'I',
  2716. '0437' => 'z',
  2717. '0178' => 'y',
  2718. '00D4' => 'O',
  2719. '044D' => 'e',
  2720. '0432' => 'v',
  2721. '013D' => 'L',
  2722. '0163' => 't',
  2723. '0456' => 'i',
  2724. '011B' => 'e',
  2725. '044F' => 'ya',
  2726. '0429' => 'SHCH',
  2727. '0411' => 'B',
  2728. '044A' => 'w',
  2729. '00C6' => 'AE',
  2730. '041D' => 'N',
  2731. '00DA' => 'U',
  2732. '00C0' => 'A',
  2733. '0152' => 'OE',
  2734. '00DD' => 'Y',
  2735. '0154' => 'R',
  2736. '00E9' => 'e',
  2737. '00D5' => 'O',
  2738. '041F' => 'P',
  2739. '0161' => 's',
  2740. '0430' => 'a',
  2741. '0445' => 'h',
  2742. '00E2' => 'a',
  2743. '00D6' => 'O',
  2744. '0407' => 'YI',
  2745. '00CA' => 'E',
  2746. '0439' => 'i',
  2747. '0171' => 'u',
  2748. '00DC' => 'U',
  2749. '042F' => 'YA',
  2750. '0425' => 'H',
  2751. '00FE' => 'th',
  2752. '00D1' => 'N',
  2753. '044C' => 'x',
  2754. '010F' => 'd',
  2755. '0410' => 'A',
  2756. '0443' => 'u',
  2757. '00EF' => 'i',
  2758. '0105' => 'a',
  2759. '00EA' => 'e',
  2760. '00E4' => 'a',
  2761. '015E' => 'S',
  2762. '0417' => 'Z',
  2763. '00ED' => 'i',
  2764. '00FC' => 'u',
  2765. '04D7' => 'IO',
  2766. '00D8' => 'OE',
  2767. '0419' => 'I',
  2768. '0421' => 'S',
  2769. '0143' => 'N',
  2770. '010E' => 'D',
  2771. '0413' => 'G',
  2772. '015B' => 's',
  2773. '0151' => 'o',
  2774. '00E7' => 'c',
  2775. '00C5' => 'AA',
  2776. '0441' => 's',
  2777. '0118' => 'E',
  2778. '00C7' => 'C',
  2779. '041A' => 'K',
  2780. '0454' => 'ie',
  2781. '042E' => 'yu',
  2782. );
  2783. %transliterate_map = (
  2784. '00C5' => 'AA',
  2785. '00E5' => 'aa',
  2786. '00D8' => 'O',
  2787. '00F8' => 'o',
  2788. '00E6' => 'ae',
  2789. '0153' => 'oe',
  2790. '00C6' => 'AE',
  2791. '0152' => 'OE',
  2792. '00DF' => 'ss',
  2793. '0141' => 'L',
  2794. '0142' => 'l',
  2795. '00D0' => 'D',
  2796. '00F0' => 'd',
  2797. '00DE' => 'TH',
  2798. '00FE' => 'th',
  2799. '0415' => 'E',
  2800. '0435' => 'e',
  2801. '0426' => 'C',
  2802. '042A' => 'W',
  2803. '044A' => 'w',
  2804. '042C' => 'X',
  2805. '044C' => 'x',
  2806. '042E' => 'yu',
  2807. '042F' => 'YA',
  2808. '044F' => 'ya',
  2809. '0433' => 'g',
  2810. '0446' => 'c',
  2811. '04D7' => 'IO',
  2812. '00DD' => 'Y', # unidecode gets this wrong ?
  2813. # following appears in tests, this is required to have
  2814. # the same output with and without unidecode
  2815. '4E2D' => 'Zhong',
  2816. '6587' => 'Wen',
  2817. '793A' => 'Shi',
  2818. '4F8B' => 'Li',
  2819. '7B2C' => 'Di',
  2820. '7AE0' => 'Zhang',
  2821. '53E6' => 'Ling',
  2822. '4E2A' => 'Ge',
  2823. # in http://www.cantonese.sheik.co.uk/dictionary/characters/7/
  2824. # unidecode certainly gets it wrong
  2825. '4E00' => 'Yi',
  2826. 'FF08' => '(',
  2827. 'FF09' => ')',
  2828. 'FF0C' => ',',
  2829. '5B66' => 'Xue',
  2830. '7FD2' => 'Xi',
  2831. '30DE' => 'ma',
  2832. '30CB' => 'ni',
  2833. '30E5' => 'yu',
  2834. '30A2' => 'a',
  2835. '30EB' => 'ru',
  2836. );
  2837. foreach my $symbol(keys(%unicode_map))
  2838. {
  2839. if ($unicode_map{$symbol} ne '' and !exists($transliterate_map{$symbol}))
  2840. {
  2841. $no_transliterate_map{$unicode_map{$symbol}} = 1;
  2842. }
  2843. }
  2844. %ascii_character_map = (
  2845. ' ' => '0020',
  2846. '!' => '0021',
  2847. '"' => '0022',
  2848. '#' => '0023',
  2849. '$' => '0024',
  2850. '%' => '0025',
  2851. '&' => '0026',
  2852. "'" => '0027',
  2853. '(' => '0028',
  2854. ')' => '0029',
  2855. '*' => '002A',
  2856. '+' => '002B',
  2857. ',' => '002C',
  2858. '-' => '002D',
  2859. '.' => '002E',
  2860. '/' => '002F',
  2861. ':' => '003A',
  2862. ';' => '003B',
  2863. '<' => '003C',
  2864. '=' => '003D',
  2865. '>' => '003E',
  2866. '?' => '003F',
  2867. '@' => '0040',
  2868. '[' => '005B',
  2869. '\\' => '005C',
  2870. ']' => '005D',
  2871. '^' => '005E',
  2872. '_' => '005F',
  2873. '`' => '0060',
  2874. '{' => '007B',
  2875. '|' => '007C',
  2876. '}' => '007D',
  2877. '~' => '007E',
  2878. );
  2879. %perl_charset_to_html = (
  2880. 'utf8' => 'utf-8',
  2881. 'utf-8-strict' => 'utf-8',
  2882. 'ascii' => 'us-ascii',
  2883. 'shiftjis' => 'shift_jis',
  2884. );
  2885. # encoding name normalization to html-compatible encoding names
  2886. %t2h_encoding_aliases = (
  2887. 'latin1' => 'iso-8859-1',
  2888. );
  2889. foreach my $perl_charset (keys(%perl_charset_to_html))
  2890. {
  2891. $t2h_encoding_aliases{$perl_charset} = $perl_charset_to_html{$perl_charset};
  2892. $t2h_encoding_aliases{$perl_charset_to_html{$perl_charset}} = $perl_charset_to_html{$perl_charset};
  2893. }
  2894. # These are the encodings from the texinfo manual
  2895. foreach my $canonical_encoding('us-ascii', 'utf-8', 'iso-8859-1',
  2896. 'iso-8859-15','iso-8859-2','koi8-r', 'koi8-u')
  2897. {
  2898. $canonical_texinfo_encodings{$canonical_encoding} = 1;
  2899. }
  2900. # not used currently for html, but used in chm.pm
  2901. %numeric_entity_map = ();
  2902. foreach my $symbol (keys(%unicode_map))
  2903. {
  2904. if ($symbol ne '')
  2905. {
  2906. $numeric_entity_map{$symbol} = '&#' . hex($unicode_map{$symbol}) . ';';
  2907. }
  2908. }
  2909. # When the value begins with & the function with that name is used to do the
  2910. # html. The first argument is the text enclosed within {}, the second is the
  2911. # style name (which is also the key of the hash)
  2912. #
  2913. # Otherwithe the value is the html element used to enclose the text, and if
  2914. # there is a " the resulting text is also enclosed within `'
  2915. my %old_style_map = (
  2916. 'acronym', '',
  2917. 'asis', '',
  2918. 'b', 'b',
  2919. 'cite', 'cite',
  2920. 'clicksequence', '',
  2921. 'code', 'code',
  2922. 'command', 'code',
  2923. 'ctrl', '&default_ctrl',
  2924. 'dfn', 'em',
  2925. 'dmn', '',
  2926. 'email', '&default_email',
  2927. 'emph', 'em',
  2928. 'env', 'code',
  2929. 'file', '"tt',
  2930. 'i', 'i',
  2931. 'kbd', 'kbd',
  2932. 'key', 'kbd',
  2933. 'math', 'em',
  2934. 'option', '"samp',
  2935. 'r', '',
  2936. 'samp', '"samp',
  2937. 'sc', '&default_sc',
  2938. 'strong', 'strong',
  2939. 't', 'tt',
  2940. 'uref', '&default_uref',
  2941. 'url', '&default_url',
  2942. 'var', 'var',
  2943. 'verb', 'tt',
  2944. 'titlefont', '&default_titlefont',
  2945. 'w', '',
  2946. );
  2947. sub t2h_default_copy_style_map ($$;$)
  2948. {
  2949. my $from = shift;
  2950. my $to = shift;
  2951. my $merge = shift;
  2952. foreach my $command (keys(%$from))
  2953. {
  2954. $to->{$command} = {} if (!exists($to->{$command}));
  2955. foreach my $key (keys(%{$from->{$command}}))
  2956. {
  2957. next if (exists($to->{$command}->{$key}) and $merge);
  2958. if ($key eq 'args')
  2959. {
  2960. $to->{$command}->{$key} = [ @{$from->{$command}->{$key}} ];
  2961. }
  2962. else
  2963. {
  2964. $to->{$command}->{$key} = $from->{$command}->{$key};
  2965. }
  2966. }
  2967. }
  2968. }
  2969. # default is {'args' => ['normal'], 'attribute' => ''},
  2970. %style_map = (
  2971. 'asis', {},
  2972. 'b', {},
  2973. 'cite', {},
  2974. 'clicksequence', {},
  2975. 'click', {'function' => \&t2h_default_click_normal, 'type' => 'simple_style'},
  2976. 'code', {'args' => ['code']},
  2977. 'command', {'args' => ['code']},
  2978. 'ctrl', {'function' => \&t2h_default_ctrl,'type' => 'simple_style'},
  2979. 'dfn', {},
  2980. 'dmn', {'type' => 'simple_style'},
  2981. 'email', {'args' => ['code', 'normal'],
  2982. 'function' => \&t2h_default_email,
  2983. 'type' => 'simple_style'},
  2984. #'email', {'args' => ['normal', 'normal'],
  2985. # 'function' => \&t2h_default_email},
  2986. 'emph', {},
  2987. 'env', {'args' => ['code']},
  2988. 'file', {'args' => ['code'], 'quote' => '"'},
  2989. 'headitemfont', {},
  2990. 'i', {},
  2991. 'slanted', {},
  2992. 'sansserif', {},
  2993. 'kbd', {'args' => ['code'], },
  2994. 'key', {'args' => ['code'], 'begin' => '<', 'end' => '>'},
  2995. 'math', {'function' => \&t2h_default_math, 'args' => ['math'] },
  2996. 'option', {'args' => ['code'], 'quote' => '"'},
  2997. 'r', {},
  2998. 'samp', {'args' => ['code'], 'quote' => '"'},
  2999. # 'sc', {'function' => \&t2h_default_sc},
  3000. 'sc', {},
  3001. 'strong', {},
  3002. 't', {},
  3003. 'uref', {'function' => \&t2h_default_uref,
  3004. 'args' => ['code', 'normal', 'normal'],
  3005. 'type' => 'simple_style' },
  3006. #'uref', {'function' => \&t2h_default_uref,
  3007. # 'args' => ['normal', 'normal', 'normal']},
  3008. 'url', {'function' => \&t2h_default_uref,
  3009. 'args' => ['code', 'normal', 'normal'],
  3010. 'type' => 'simple_style'},
  3011. 'indicateurl', {'args' => ['code'], 'begin' => '<', 'end' => '>','type' => 'simple_style'},
  3012. 'var', {},
  3013. 'verb', {'args' => ['code'], },
  3014. 'titlefont', {'function' => \&t2h_default_titlefont,
  3015. 'type' => 'simple_style'},
  3016. 'w', {},
  3017. 'hyphenation', {'function' => \&t2h_default_hyphenation, 'args' => ['keep']},
  3018. );
  3019. %command_type = ();
  3020. foreach my $style (keys(%style_map))
  3021. {
  3022. if (exists($style_map{$style}->{'type'}))
  3023. {
  3024. $command_type{$style} = $style_map{$style}->{'type'};
  3025. }
  3026. else
  3027. {
  3028. $command_type{$style} = 'style';
  3029. }
  3030. }
  3031. sub t2h_default_select_substitution($$$)
  3032. {
  3033. my $in_raw_text = shift;
  3034. my $in_preformatted = shift;
  3035. my $in_simple = shift;
  3036. if ($in_raw_text)
  3037. {
  3038. return \@text_substitutions_texi;
  3039. }
  3040. elsif ($in_simple)
  3041. {
  3042. return \@text_substitutions_simple_format;
  3043. }
  3044. elsif ($in_preformatted)
  3045. {
  3046. return \@text_substitutions_pre;
  3047. }
  3048. else
  3049. {
  3050. return \@text_substitutions_normal;
  3051. }
  3052. }
  3053. sub t2h_text_substitutions($$$$)
  3054. {
  3055. my $text = shift;
  3056. my $in_raw_text = shift;
  3057. my $in_preformatted = shift;
  3058. my $in_simple = shift;
  3059. my $substitutions = t2h_default_select_substitution($in_raw_text, $in_preformatted, $in_simple);
  3060. foreach my $substitution_entry (@$substitutions)
  3061. {
  3062. my $from = quotemeta($substitution_entry->[0]);
  3063. my $to = $substitution_entry->[1];
  3064. $text =~ s/$from/$to/g;
  3065. }
  3066. return $text;
  3067. }
  3068. sub t2h_add_text_substitutions($$$$$)
  3069. {
  3070. my $entry = shift;
  3071. my $in_normal = shift;
  3072. my $in_raw_text = shift;
  3073. my $in_preformatted = shift;
  3074. my $in_simple = shift;
  3075. my @formats_to_be_done = ($in_normal, $in_raw_text, $in_preformatted, $in_simple);
  3076. for (my $index = 0; $index < scalar(@formats_to_be_done); $index++)
  3077. {
  3078. next unless ($formats_to_be_done[$index]);
  3079. my @args = (0, 0, 0);
  3080. my $found = 0;
  3081. $args[$index -1] = 1 if ($index > 0);
  3082. my $substitutions = &t2h_default_select_substitution(@args);
  3083. foreach my $substitution_entry (@$substitutions)
  3084. {
  3085. if ($substitution_entry->[0] eq $entry->[0])
  3086. {
  3087. $found = 1;
  3088. $substitution_entry->[1] = $entry->[1];
  3089. }
  3090. }
  3091. push @$substitutions, $entry unless ($found);
  3092. }
  3093. }
  3094. sub t2h_remove_text_substitutions($$$$$)
  3095. {
  3096. my $entry = shift;
  3097. my $in_normal = shift;
  3098. my $in_raw_text = shift;
  3099. my $in_preformatted = shift;
  3100. my $in_simple = shift;
  3101. my @formats_to_be_done = ($in_normal, $in_raw_text, $in_preformatted, $in_simple);
  3102. for (my $index = 0; $index < scalar(@formats_to_be_done); $index++)
  3103. {
  3104. next unless ($formats_to_be_done[$index]);
  3105. my @args = (0, 0, 0);
  3106. $args[$index -1] = 1 if ($index > 0);
  3107. my $substitutions = &t2h_default_select_substitution(@args);
  3108. @$substitutions = grep {$_->[0] ne $entry} @$substitutions;
  3109. }
  3110. }
  3111. %unicode_diacritical = (
  3112. 'H' => '030B',
  3113. 'ringaccent' => '030A',
  3114. "'" => '0301',
  3115. 'v' => '030C',
  3116. ',' => '0327',
  3117. '^' => '0302',
  3118. 'dotaccent' => '0307',
  3119. '`' => '0300',
  3120. '=' => '0304',
  3121. '~' => '0303',
  3122. '"' => '0308',
  3123. 'udotaccent' => '0323',
  3124. 'ubaraccent' => '0332',
  3125. 'u' => '0306',
  3126. 'tieaccent' => '0361',
  3127. 'ogonek' => '0328'
  3128. );
  3129. %unicode_accents = (
  3130. 'dotaccent' => { # dot above
  3131. 'A' => '0226', #C moz-1.2
  3132. 'a' => '0227', #c moz-1.2
  3133. 'B' => '1E02',
  3134. 'b' => '1E03',
  3135. 'C' => '010A',
  3136. 'c' => '010B',
  3137. 'D' => '1E0A',
  3138. 'd' => '1E0B',
  3139. 'E' => '0116',
  3140. 'e' => '0117',
  3141. 'F' => '1E1E',
  3142. 'f' => '1E1F',
  3143. 'G' => '0120',
  3144. 'g' => '0121',
  3145. 'H' => '1E22',
  3146. 'h' => '1E23',
  3147. 'i' => '0069',
  3148. 'I' => '0130',
  3149. 'N' => '1E44',
  3150. 'n' => '1E45',
  3151. 'O' => '022E', #Y moz-1.2
  3152. 'o' => '022F', #v moz-1.2
  3153. 'P' => '1E56',
  3154. 'p' => '1E57',
  3155. 'R' => '1E58',
  3156. 'r' => '1E59',
  3157. 'S' => '1E60',
  3158. 's' => '1E61',
  3159. 'T' => '1E6A',
  3160. 't' => '1E6B',
  3161. 'W' => '1E86',
  3162. 'w' => '1E87',
  3163. 'X' => '1E8A',
  3164. 'x' => '1E8B',
  3165. 'Y' => '1E8E',
  3166. 'y' => '1E8F',
  3167. 'Z' => '017B',
  3168. 'z' => '017C',
  3169. },
  3170. 'udotaccent' => { # dot below
  3171. 'A' => '1EA0',
  3172. 'a' => '1EA1',
  3173. 'B' => '1E04',
  3174. 'b' => '1E05',
  3175. 'D' => '1E0C',
  3176. 'd' => '1E0D',
  3177. 'E' => '1EB8',
  3178. 'e' => '1EB9',
  3179. 'H' => '1E24',
  3180. 'h' => '1E25',
  3181. 'I' => '1ECA',
  3182. 'i' => '1ECB',
  3183. 'K' => '1E32',
  3184. 'k' => '1E33',
  3185. 'L' => '1E36',
  3186. 'l' => '1E37',
  3187. 'M' => '1E42',
  3188. 'm' => '1E43',
  3189. 'N' => '1E46',
  3190. 'n' => '1E47',
  3191. 'O' => '1ECC',
  3192. 'o' => '1ECD',
  3193. 'R' => '1E5A',
  3194. 'r' => '1E5B',
  3195. 'S' => '1E62',
  3196. 's' => '1E63',
  3197. 'T' => '1E6C',
  3198. 't' => '1E6D',
  3199. 'U' => '1EE4',
  3200. 'u' => '1EE5',
  3201. 'V' => '1E7E',
  3202. 'v' => '1E7F',
  3203. 'W' => '1E88',
  3204. 'w' => '1E89',
  3205. 'Y' => '1EF4',
  3206. 'y' => '1EF5',
  3207. 'Z' => '1E92',
  3208. 'z' => '1E93',
  3209. },
  3210. 'ubaraccent' => { # line below
  3211. 'B' => '1E06',
  3212. 'b' => '1E07',
  3213. 'D' => '1E0E',
  3214. 'd' => '1E0F',
  3215. 'h' => '1E96',
  3216. 'K' => '1E34',
  3217. 'k' => '1E35',
  3218. 'L' => '1E3A',
  3219. 'l' => '1E3B',
  3220. 'N' => '1E48',
  3221. 'n' => '1E49',
  3222. 'R' => '1E5E',
  3223. 'r' => '1E5F',
  3224. 'T' => '1E6E',
  3225. 't' => '1E6F',
  3226. 'Z' => '1E94',
  3227. 'z' => '1E95',
  3228. },
  3229. ',' => { # cedilla
  3230. 'C' => '00C7',
  3231. 'c' => '00E7',
  3232. 'D' => '1E10',
  3233. 'd' => '1E11',
  3234. 'E' => '0228', #C moz-1.2
  3235. 'e' => '0229', #c moz-1.2
  3236. 'G' => '0122',
  3237. 'g' => '0123',
  3238. 'H' => '1E28',
  3239. 'h' => '1E29',
  3240. 'K' => '0136',
  3241. 'k' => '0137',
  3242. 'L' => '013B',
  3243. 'l' => '013C',
  3244. 'N' => '0145',
  3245. 'n' => '0146',
  3246. 'R' => '0156',
  3247. 'r' => '0157',
  3248. 'S' => '015E',
  3249. 's' => '015F',
  3250. 'T' => '0162',
  3251. 't' => '0163',
  3252. },
  3253. '=' => { # macron
  3254. 'A' => '0100',
  3255. 'a' => '0101',
  3256. 'E' => '0112',
  3257. 'e' => '0113',
  3258. 'I' => '012A',
  3259. 'i' => '012B',
  3260. 'G' => '1E20',
  3261. 'g' => '1E21',
  3262. 'O' => '014C',
  3263. 'o' => '014D',
  3264. 'U' => '016A',
  3265. 'u' => '016B',
  3266. 'Y' => '0232', #? moz-1.2
  3267. 'y' => '0233', #? moz-1.2
  3268. },
  3269. '"' => { # diaeresis
  3270. 'A' => '00C4',
  3271. 'a' => '00E4',
  3272. 'E' => '00CB',
  3273. 'e' => '00EB',
  3274. 'H' => '1E26',
  3275. 'h' => '1E27',
  3276. 'I' => '00CF',
  3277. 'i' => '00EF',
  3278. 'O' => '00D6',
  3279. 'o' => '00F6',
  3280. 't' => '1E97',
  3281. 'U' => '00DC',
  3282. 'u' => '00FC',
  3283. 'W' => '1E84',
  3284. 'w' => '1E85',
  3285. 'X' => '1E8C',
  3286. 'x' => '1E8D',
  3287. 'y' => '00FF',
  3288. 'Y' => '0178',
  3289. },
  3290. 'u' => { # breve
  3291. 'A' => '0102',
  3292. 'a' => '0103',
  3293. 'E' => '0114',
  3294. 'e' => '0115',
  3295. 'G' => '011E',
  3296. 'g' => '011F',
  3297. 'I' => '012C',
  3298. 'i' => '012D',
  3299. 'O' => '014E',
  3300. 'o' => '014F',
  3301. 'U' => '016C',
  3302. 'u' => '016D',
  3303. },
  3304. "'" => { # acute
  3305. 'A' => '00C1',
  3306. 'a' => '00E1',
  3307. 'C' => '0106',
  3308. 'c' => '0107',
  3309. 'E' => '00C9',
  3310. 'e' => '00E9',
  3311. 'G' => '01F4',
  3312. 'g' => '01F5',
  3313. 'I' => '00CD',
  3314. 'i' => '00ED',
  3315. 'K' => '1E30',
  3316. 'k' => '1E31',
  3317. 'L' => '0139',
  3318. 'l' => '013A',
  3319. 'M' => '1E3E',
  3320. 'm' => '1E3F',
  3321. 'N' => '0143',
  3322. 'n' => '0144',
  3323. 'O' => '00D3',
  3324. 'o' => '00F3',
  3325. 'P' => '1E54',
  3326. 'p' => '1E55',
  3327. 'R' => '0154',
  3328. 'r' => '0155',
  3329. 'S' => '015A',
  3330. 's' => '015B',
  3331. 'U' => '00DA',
  3332. 'u' => '00FA',
  3333. 'W' => '1E82',
  3334. 'w' => '1E83',
  3335. 'Y' => '00DD',
  3336. 'y' => '00FD',
  3337. 'Z' => '0179',
  3338. 'z' => '018A',
  3339. },
  3340. '~' => { # tilde
  3341. 'A' => '00C3',
  3342. 'a' => '00E3',
  3343. 'E' => '1EBC',
  3344. 'e' => '1EBD',
  3345. 'I' => '0128',
  3346. 'i' => '0129',
  3347. 'N' => '00D1',
  3348. 'n' => '00F1',
  3349. 'O' => '00D5',
  3350. 'o' => '00F5',
  3351. 'U' => '0168',
  3352. 'u' => '0169',
  3353. 'V' => '1E7C',
  3354. 'v' => '1E7D',
  3355. 'Y' => '1EF8',
  3356. 'y' => '1EF9',
  3357. },
  3358. '`' => { # grave
  3359. 'A' => '00C0',
  3360. 'a' => '00E0',
  3361. 'E' => '00C8',
  3362. 'e' => '00E8',
  3363. 'I' => '00CC',
  3364. 'i' => '00EC',
  3365. 'N' => '01F8',
  3366. 'n' => '01F9',
  3367. 'O' => '00D2',
  3368. 'o' => '00F2',
  3369. 'U' => '00D9',
  3370. 'u' => '00F9',
  3371. 'W' => '1E80',
  3372. 'w' => '1E81',
  3373. 'Y' => '1EF2',
  3374. 'y' => '1EF3',
  3375. },
  3376. '^' => { # circumflex
  3377. 'A' => '00C2',
  3378. 'a' => '00E2',
  3379. 'C' => '0108',
  3380. 'c' => '0109',
  3381. 'E' => '00CA',
  3382. 'e' => '00EA',
  3383. 'G' => '011C',
  3384. 'g' => '011D',
  3385. 'H' => '0124',
  3386. 'h' => '0125',
  3387. 'I' => '00CE',
  3388. 'i' => '00EE',
  3389. 'J' => '0134',
  3390. 'j' => '0135',
  3391. 'O' => '00D4',
  3392. 'o' => '00F4',
  3393. 'S' => '015C',
  3394. 's' => '015D',
  3395. 'U' => '00DB',
  3396. 'u' => '00FB',
  3397. 'W' => '0174',
  3398. 'w' => '0175',
  3399. 'Y' => '0176',
  3400. 'y' => '0177',
  3401. 'Z' => '1E90',
  3402. 'z' => '1E91',
  3403. },
  3404. 'ringaccent' => { # ring
  3405. 'A' => '00C5',
  3406. 'a' => '00E5',
  3407. 'U' => '016E',
  3408. 'u' => '016F',
  3409. 'w' => '1E98',
  3410. 'y' => '1E99',
  3411. },
  3412. 'v' => { # caron
  3413. 'A' => '01CD',
  3414. 'a' => '01CE',
  3415. 'C' => '010C',
  3416. 'c' => '010D',
  3417. 'D' => '010E',
  3418. 'd' => '010F',
  3419. 'E' => '011A',
  3420. 'e' => '011B',
  3421. 'G' => '01E6',
  3422. 'g' => '01E7',
  3423. 'H' => '021E', #K with moz-1.2
  3424. 'h' => '021F', #k with moz-1.2
  3425. 'I' => '01CF',
  3426. 'i' => '01D0',
  3427. 'K' => '01E8',
  3428. 'k' => '01E9',
  3429. 'L' => '013D', #L' with moz-1.2
  3430. 'l' => '013E', #l' with moz-1.2
  3431. 'N' => '0147',
  3432. 'n' => '0148',
  3433. 'O' => '01D1',
  3434. 'o' => '01D2',
  3435. 'R' => '0158',
  3436. 'r' => '0159',
  3437. 'S' => '0160',
  3438. 's' => '0161',
  3439. 'T' => '0164',
  3440. 't' => '0165',
  3441. 'U' => '01D3',
  3442. 'u' => '01D4',
  3443. 'Z' => '017D',
  3444. 'z' => '017E',
  3445. },
  3446. 'H' => { # double acute
  3447. 'O' => '0150',
  3448. 'o' => '0151',
  3449. 'U' => '0170',
  3450. 'u' => '0171',
  3451. },
  3452. 'ogonek' => {
  3453. 'A' => '0104',
  3454. 'a' => '0105',
  3455. 'E' => '0118',
  3456. 'e' => '0119',
  3457. 'I' => '012E',
  3458. 'i' => '012F',
  3459. 'U' => '0172',
  3460. 'u' => '0173',
  3461. 'O' => '01EA',
  3462. 'o' => '01EB',
  3463. },
  3464. );
  3465. foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents))
  3466. {
  3467. $style_map{$accent_command} = { 'function' => \&t2h_default_accent };
  3468. $old_style_map{$accent_command} = '&default_accent';
  3469. $style_map_texi{$accent_command} = { 'function' => \&t2h_default_accent };
  3470. }
  3471. %transliterate_accent_map = ();
  3472. foreach my $command (keys(%unicode_accents))
  3473. {
  3474. foreach my $letter(keys (%{$unicode_accents{$command}}))
  3475. {
  3476. $transliterate_accent_map{$unicode_accents{$command}->{$letter}}
  3477. = $letter
  3478. unless (exists($transliterate_map{$unicode_accents{$command}->{$letter}}));
  3479. }
  3480. }
  3481. sub default_accent($$)
  3482. {
  3483. my $text = shift;
  3484. my $accent = shift;
  3485. return "&${text}$accent_map{$accent};" if (defined($accent_map{$accent}) and defined($special_accents{$accent}) and ($text =~ /^[$special_accents{$accent}]$/));
  3486. return '&' . $text . 'ring;' if (($accent eq 'ringaccent') and (defined($special_accents{$accent})) and ($text =~ /^[$special_accents{$accent}]$/));
  3487. return $text . '&lt;' if ($accent eq 'v');
  3488. return ascii_accents($text, $accent);
  3489. }
  3490. sub t2h_default_accent($$)
  3491. {
  3492. my $accent = shift;
  3493. my $args = shift;
  3494. my $text = $args->[0];
  3495. return ascii_accents($text, $accent);
  3496. }
  3497. ####################################################################
  3498. # special accent/encoding commands
  3499. #
  3500. # Some functions used to override normal formatting functions in specific
  3501. # cases. The user shouldn't want to change them, but can use them.
  3502. #
  3503. sub ascii_accents($$)
  3504. {
  3505. my $text = shift;
  3506. my $accent = shift;
  3507. return $text if ($accent eq 'dotless');
  3508. return $text . "''" if ($accent eq 'H');
  3509. return $text . '.' if ($accent eq 'dotaccent');
  3510. return $text . '*' if ($accent eq 'ringaccent');
  3511. return $text . '[' if ($accent eq 'tieaccent');
  3512. return $text . '(' if ($accent eq 'u');
  3513. return $text . '_' if ($accent eq 'ubaraccent');
  3514. return '.' . $text if ($accent eq 'udotaccent');
  3515. return $text . '<' if ($accent eq 'v');
  3516. return $text . ';' if ($accent eq 'ogonek');
  3517. return $text . $accent if (defined($accent_map{$accent}));
  3518. }
  3519. sub xml_default_accent($$)
  3520. {
  3521. my $accent = shift;
  3522. my $args = shift;
  3523. my $text = $args->[0];
  3524. return "&${text}$accent_map{$accent};" if (defined($accent_map{$accent}) and defined($special_accents{$accent}) and ($text =~ /^[$special_accents{$accent}]$/));
  3525. return '&' . $text . 'ring;' if (($accent eq 'ringaccent') and (defined($special_accents{$accent})) and ($text =~ /^[$special_accents{$accent}]$/));
  3526. return $text . '&lt;' if ($accent eq 'v');
  3527. # FIXME here there could be a conversion to the character in the right
  3528. # encoding, like
  3529. # if (get_conf('USE_UNICODE') and defined($OUT_ENCODING) and $OUT_ENCODING ne ''
  3530. # and exists($unicode_accents{$accent}) and exists($unicode_accents{$accent}->{$text}))
  3531. # {
  3532. # my $encoded_char = Encode::encode($OUT_ENCODING, chr(hex($unicode_map{$thing})), Encode::FB_QUIET);
  3533. # return $encoded_char if ($encoded_char ne '');
  3534. # }
  3535. if (get_conf('USE_NUMERIC_ENTITY'))
  3536. {
  3537. if (exists($unicode_accents{$accent}) and exists($unicode_accents{$accent}->{$text}))
  3538. {
  3539. return ('&#' . hex($unicode_accents{$accent}->{$text}) . ';');
  3540. }
  3541. }
  3542. return ascii_accents($text, $accent);
  3543. }
  3544. # used to utf8 encode the result
  3545. sub t2h_utf8_accent($$$)
  3546. {
  3547. my $accent = shift;
  3548. my $args = shift;
  3549. my $style_stack = shift;
  3550. my $text = $args->[0];
  3551. #print STDERR "$accent\[".scalar(@$style_stack) ."\] (@$style_stack)\n";
  3552. # special handling of @dotless{i}
  3553. if ($accent eq 'dotless')
  3554. {
  3555. if (($text eq 'i') and (!defined($style_stack->[-1]) or (!defined($unicode_accents{$style_stack->[-1]})) or ($style_stack->[-1] eq 'tieaccent')))
  3556. {
  3557. return "\x{0131}";
  3558. }
  3559. #return "\x{}" if ($text eq 'j'); # not found !
  3560. return $text;
  3561. }
  3562. # FIXME \x{0131}\x{0308} for @dotless{i} @" doesn't lead to NFC 00ef.
  3563. return Unicode::Normalize::NFC($text . chr(hex($unicode_diacritical{$accent})))
  3564. if (defined($unicode_diacritical{$accent}));
  3565. return ascii_accents($text, $accent);
  3566. }
  3567. sub t2h_utf8_normal_text($$$$$$$;$)
  3568. {
  3569. my $text = shift;
  3570. my $in_raw_text = shift;
  3571. my $in_preformatted = shift;
  3572. my $in_code = shift;
  3573. my $in_math = shift;
  3574. my $in_simple = shift;
  3575. my $style_stack = shift;
  3576. my $state = shift;
  3577. $text = &$protect_text($text) unless($in_raw_text);
  3578. $text = uc($text) if (in_small_caps($style_stack));
  3579. if (!$in_code and !$in_preformatted)
  3580. {
  3581. $text =~ s/---/\x{2014}/g;
  3582. $text =~ s/--/\x{2013}/g;
  3583. $text =~ s/``/\x{201C}/g;
  3584. $text =~ s/''/\x{201D}/g;
  3585. }
  3586. $text = t2h_text_substitutions($text, $in_raw_text, ($in_preformatted or $in_code), $in_simple);
  3587. return Unicode::Normalize::NFC($text);
  3588. }
  3589. sub t2h_enable_encoding_normal_accent($$$)
  3590. {
  3591. return t2h_enable_encoding_accent ('normal', @_);
  3592. }
  3593. sub t2h_enable_encoding_texi_accent($$$)
  3594. {
  3595. return t2h_enable_encoding_accent ('texi', @_);
  3596. }
  3597. sub t2h_enable_encoding_pre_accent($$$)
  3598. {
  3599. return t2h_enable_encoding_accent ('pre', @_);
  3600. }
  3601. sub t2h_enable_encoding_accent($$$$)
  3602. {
  3603. my $context = shift;
  3604. my @other_args = @_;
  3605. my $accent = shift;
  3606. my $args = shift;
  3607. my $style_stack = shift;
  3608. my $text = $args->[0];
  3609. #print STDERR "enable_encoding_accent called($context) $accent (@$style_stack)\n";
  3610. # in case ENCODING_NAME is not known, the accent functions saved previously
  3611. # are used.
  3612. # This should happen rarely, like during @setfilename parsing.
  3613. return &{$t2h_enable_encoding_default_accent{$context}->{$accent}}(@other_args) if (!defined(get_conf('ENCODING_NAME')));
  3614. return t2h_utf8_accent($accent,[$text],$style_stack) if (get_conf('ENCODING_NAME') eq 'utf-8');
  3615. # use the saved default handling if this is not a known 8 bit encoding
  3616. return &{$t2h_enable_encoding_default_accent{$context}->{$accent}}(@other_args) if (!exists($makeinfo_encoding_to_map{get_conf('ENCODING_NAME')}));
  3617. # the following is for the handling of known 8 bit encodings.
  3618. if (scalar(@t2h_enable_encoding_accents_stack))
  3619. {
  3620. # in that case, we already have a result ready that corresponds with the
  3621. # formatting of a part of the stack mapped to
  3622. # t2h_enable_encoding_accents_stack, so it is emptied and the innermost
  3623. # $text is returned as is, such that the unmodified already formatted
  3624. # innermost formatted accented text is returned.
  3625. #print STDERR " doing nothing, still in stack (@t2h_enable_encoding_accents_stack), accent: $accent";
  3626. my $stack_accent = shift @t2h_enable_encoding_accents_stack;
  3627. #print STDERR " stack_accent $stack_accent\n";
  3628. return $text;
  3629. }
  3630. # in that case there is no t2h_enable_encoding_accents_stack, so we are
  3631. # at the closing of the innermost accented command. We will try to format
  3632. # all the stack in reverse(@$style_stack) that coresponds with
  3633. # accent commands
  3634. my @accents_stack = ();
  3635. my @styles = reverse(@$style_stack);
  3636. # accents are formatted and the intermediate results are kept, such
  3637. # that we can return the maximum of multiaccented letters that can be
  3638. # rendered with a given eight bit formatting.
  3639. # first put the letter in the stack
  3640. my @utf8_partial_results = { 'result' => $text,
  3641. 'accents_stack' => [ @accents_stack ]};
  3642. # then the accent that is associated with the function call
  3643. my $current_accent = t2h_utf8_accent($accent,[$text],$style_stack);
  3644. @accents_stack = ($accent);
  3645. push @utf8_partial_results, { 'result' => $current_accent,
  3646. 'accents_stack' => [ @accents_stack ]};
  3647. # and then all the other accents on the stack
  3648. while (scalar(@styles) and (defined($unicode_accents{$styles[0]}) or $styles[0] eq 'dotless'))
  3649. {
  3650. my $next_style = shift @styles;
  3651. my @new_stack = reverse(@styles);
  3652. $current_accent = t2h_utf8_accent($next_style,[$current_accent],\@new_stack);
  3653. push @accents_stack, $next_style;
  3654. push @utf8_partial_results, { 'result' => $current_accent,
  3655. 'accents_stack' => [ @accents_stack ]}
  3656. ;
  3657. }
  3658. my $enc_map = $makeinfo_encoding_to_map{get_conf('ENCODING_NAME')};
  3659. my $eight_bit;
  3660. my $result;
  3661. # At this point we have the utf8 encoded results for the accent
  3662. # commands stack, with all the intermediate results.
  3663. # For each one we'll check if it is possible to encode it in the
  3664. # current eight bit output encoding table
  3665. foreach my $partial_result (@utf8_partial_results)
  3666. {
  3667. my $char = $partial_result->{'result'};
  3668. my $new_eight_bit = '';
  3669. my $new_codepoint;
  3670. if (ord($char) <= 128)
  3671. {
  3672. $new_eight_bit = uc(sprintf("%02x",ord($char)));
  3673. $new_codepoint = uc(sprintf("%04x",ord($char)));
  3674. }
  3675. elsif (ord($char) <= hex(0xFFFF))
  3676. {
  3677. $new_codepoint = uc(sprintf("%04x",ord($char)));
  3678. if (exists($makeinfo_unicode_to_eight_bit{$enc_map}->{$new_codepoint}))
  3679. {
  3680. $new_eight_bit = $makeinfo_unicode_to_eight_bit{$enc_map}->{$new_codepoint};
  3681. }
  3682. }
  3683. #my $eight_bit_txt = 'undef';
  3684. #$eight_bit_txt = $eight_bit if (defined($eight_bit));
  3685. #print STDERR "" . Encode::encode('utf8', "$char") . " (@{$partial_result->{'accents_stack'}}), new_codepoint: $new_codepoint 8bit: $new_eight_bit old:$eight_bit_txt\n";
  3686. # no corresponding eight bit character found
  3687. last if ($new_eight_bit eq '');
  3688. # in that case, the new eight bit character is the same than the one
  3689. # found with one less character (and it isnt a @dotless{i}). It may
  3690. # mean 2 things
  3691. # -> there are 2 characters in accent. This could happen, for example
  3692. # if an accent that cannot be rendered is found and it leads to
  3693. # appending or prepending a character. For example this happens for
  3694. # @={@,{@~{n}}}, where @,{@~{n}} is expanded to a 2 character:
  3695. # n with a tilde, followed by a ,
  3696. # In nthat case, the additional utf8 accent is prepended, which
  3697. # means that it is composed with the , and leaves n with a tilde
  3698. # untouched.
  3699. # -> ord(char) leads to the same for the more inner character.
  3700. # this, for example, happens for @ubaraccent{a}, where ord(a) is
  3701. # the same than ord(a with underbar).
  3702. last if (defined($eight_bit) and (($new_eight_bit eq $eight_bit)
  3703. and !($partial_result->{'accents_stack'}[0] eq 'dotless' and $char eq 'i')));
  3704. $result = $partial_result;
  3705. $eight_bit = $new_eight_bit;
  3706. }
  3707. if (defined($result) and scalar(@{$result->{'accents_stack'}}))
  3708. {
  3709. # we got a result, return it and put in t2h_enable_encoding_accents_stack
  3710. # the stack of accent commands that were processed. They wont be used
  3711. # further, but only unshifted.
  3712. #print STDERR "Result: ".Encode::encode('utf8', $result->{'result'}) ." '$eight_bit' (@{$result->{'accents_stack'}})\n" if defined($result);
  3713. @t2h_enable_encoding_accents_stack = @{$result->{'accents_stack'}};
  3714. # remove the first, it is the accent being processed
  3715. shift @t2h_enable_encoding_accents_stack;
  3716. # it should be noted that we return the 'utf8' accent (which is really
  3717. # a codepoint, and not the eight bit representation, we leave the
  3718. # conversion to perl, which should handle it fine
  3719. return $result->{'result'};
  3720. }
  3721. return &{$t2h_enable_encoding_default_accent{$context}->{$accent}}(@other_args);
  3722. }
  3723. # end special accent/encoding commands
  3724. ####################################################################
  3725. ####################################################################
  3726. # TeX/LaTeX, that can especially be used in @math
  3727. # To load the appropriate hash, use
  3728. # default_load_tex_math
  3729. my %tex_default_simple_map_math = (
  3730. '{' => '\{',
  3731. '}' => '\}',
  3732. '\\' => '\\'
  3733. );
  3734. my %tex_default_math_things_map = %default_things_map;
  3735. $tex_default_math_things_map{'bullet'} = '\bullet';
  3736. $tex_default_math_things_map{'copyright'} = '\copyright';
  3737. $tex_default_math_things_map{'registeredsymbol'} = '\circledR';
  3738. $tex_default_math_things_map{'dots'} = '\dots';
  3739. $tex_default_math_things_map{'endots'} = '\dots';
  3740. $tex_default_math_things_map{'equiv'} = '\equiv';
  3741. $tex_default_math_things_map{'expansion'} = '\mapsto';
  3742. $tex_default_math_things_map{'arrow'} = '\rightarrow';
  3743. $tex_default_math_things_map{'point'} = '\star';
  3744. $tex_default_math_things_map{'print'} = '\dashv';
  3745. $tex_default_math_things_map{'result'} = '\Rightarrow';
  3746. $tex_default_math_things_map{'pounds'} = '\pounds';
  3747. $tex_default_math_things_map{'geq'} = '\geq';
  3748. $tex_default_math_things_map{'leq'} = '\leq';
  3749. $tex_default_math_things_map{'textdegree'} = '^\circ';
  3750. my %latex_default_math_things_map = %tex_default_math_things_map;
  3751. $latex_default_math_things_map{'aa'} = '\mathring{a}';
  3752. $latex_default_math_things_map{'AA'} = '\mathring{A}';
  3753. # FIXME Maybe this should not be there since it is not for math but
  3754. # more for a completly separate format.
  3755. my %latex_default_things_map;
  3756. foreach my $thing (keys(%default_things_map))
  3757. {
  3758. $latex_default_things_map{$thing} = '\\'.$thing;
  3759. }
  3760. $latex_default_things_map{'error'} = '\fbox{error}';
  3761. $latex_default_things_map{'enddots'} = '\dots\@';
  3762. $latex_default_things_map{'exclamdown'} = '\textexclamdown';
  3763. $latex_default_things_map{'questiondown'} = '\textquestiondown';
  3764. $latex_default_things_map{'tie'} = '~';
  3765. $latex_default_things_map{'registeredsymbol'} = '\textregistered';
  3766. $latex_default_things_map{'ordf'} = '\textordfeminine';
  3767. $latex_default_things_map{'ordm'} = '\textordmasculine';
  3768. $latex_default_things_map{'guillemetleft'} = '\guillemotleft';
  3769. $latex_default_things_map{'guillemetright'} = '\guillemotright';
  3770. foreach my $text_prefixed_symbols ('bullet', 'exclamdown', 'questiondown',
  3771. 'quotedblleft', 'quotedblright', 'quoteleft', 'quoteright')
  3772. {
  3773. $latex_default_things_map{$text_prefixed_symbols} = '\text'.$text_prefixed_symbols;
  3774. }
  3775. foreach my $math_only ('equiv', 'expansion', 'arrow', 'minus', 'point',
  3776. 'print', 'result', 'geq', 'leq')
  3777. {
  3778. $latex_default_things_map{$math_only} = '$'.$latex_default_math_things_map{$math_only}.'$';
  3779. }
  3780. # End TeX/LaTeX
  3781. #############################################################
  3782. sub default_sc($$)
  3783. {
  3784. return uc($_[0]);
  3785. }
  3786. sub default_ctrl($$)
  3787. {
  3788. return "^$_[0]";
  3789. }
  3790. # obsolete, no warning, but noop
  3791. sub t2h_default_ctrl($$$)
  3792. {
  3793. shift;
  3794. my $args = shift;
  3795. #return "^$args->[0]";
  3796. return "$args->[0]";
  3797. }
  3798. sub default_sc_pre($$)
  3799. {
  3800. return uc($_[0]);
  3801. }
  3802. sub default_titlefont($$)
  3803. {
  3804. return "<h1 class=\"titlefont\">$_[0]</h1>" if ($_[0] =~ /\S/);
  3805. return '';
  3806. }
  3807. # Return nothing if the text is empty
  3808. sub t2h_default_titlefont($$$)
  3809. {
  3810. shift;
  3811. my $args = shift;
  3812. my $heading = $args->[0];
  3813. return '' unless ($heading =~ /\S/);
  3814. return &$heading_text('@titlefont', $heading, 0);
  3815. }
  3816. # At some point in time (before 4.7?) according to the texinfo
  3817. # manual, url shouldn't lead to a link but rather be formatted
  3818. # like text. It is now what indicateurl do, url is the same that
  3819. # uref with one arg. If we did like makeinfo did it would have been
  3820. #sub url($$)
  3821. #{
  3822. # return '&lt;<code>' . $_[0] . '</code>&gt;';
  3823. #}
  3824. #
  3825. # This is unused, t2h_default_uref is used instead
  3826. sub t2h_default_url ($$)
  3827. {
  3828. shift;
  3829. my $args = shift;
  3830. my $url = shift @$args;
  3831. $url = main::normalise_space($url);
  3832. return '' unless ($url =~ /\S/);
  3833. return t2h_default_url_and_text($url);
  3834. }
  3835. sub default_url ($$)
  3836. {
  3837. my $url = shift;
  3838. my $command = shift;
  3839. $url =~ s/\s*$//;
  3840. $url =~ s/^\s*//;
  3841. return t2h_default_url_and_text($url);
  3842. }
  3843. sub default_uref($$)
  3844. {
  3845. my $arg = shift;
  3846. my $command = shift;
  3847. my ($url, $text, $replacement);
  3848. ($url, $text, $replacement) = split /,\s*/, $arg;
  3849. $url =~ s/\s*$//;
  3850. $url =~ s/^\s*//;
  3851. $text = $replacement if (defined($replacement));
  3852. return t2h_default_url_and_text($url, $text);
  3853. }
  3854. sub t2h_default_uref($$)
  3855. {
  3856. shift;
  3857. my $args = shift;
  3858. my $url = shift @$args;
  3859. my $text = shift @$args;
  3860. my $replacement = shift @$args;
  3861. $url = main::normalise_space($url);
  3862. $replacement = '' if (!defined($replacement));
  3863. $replacement = main::normalise_space($replacement);
  3864. $text = '' if (!defined($text));
  3865. $text = main::normalise_space($text);
  3866. $text = $replacement if ($replacement ne '');
  3867. return t2h_default_url_and_text($url, $text);
  3868. }
  3869. sub t2h_default_math($$)
  3870. {
  3871. shift;
  3872. my $args = shift;
  3873. my $text = shift @$args;
  3874. return "$text";
  3875. }
  3876. sub default_email($$)
  3877. {
  3878. my $arg = shift;
  3879. my $command = shift;
  3880. my ($mail, $text);
  3881. ($mail, $text) = split /,\s*/, $arg;
  3882. $mail =~ s/\s*$//;
  3883. $mail =~ s/^\s*//;
  3884. return t2h_default_url_and_text("mailto:$mail", $text);
  3885. }
  3886. sub t2h_default_email($$)
  3887. {
  3888. my $command = shift;
  3889. my $args = shift;
  3890. my $mail = shift @$args;
  3891. my $text = shift @$args;
  3892. $mail = main::normalise_space($mail);
  3893. if (defined($text))
  3894. {
  3895. $text = main::normalise_space($text);
  3896. }
  3897. my $mailto = '';
  3898. $mailto = "mailto:$mail" if ($mail ne '');
  3899. return t2h_default_url_and_text($mailto, $text);
  3900. }
  3901. sub t2h_default_click_normal($$$)
  3902. {
  3903. return t2h_default_click('normal', @_);
  3904. }
  3905. sub t2h_default_click_pre($$$)
  3906. {
  3907. return t2h_default_click('pre', @_);
  3908. }
  3909. sub t2h_default_click_texi($$$)
  3910. {
  3911. return t2h_default_click('texi', @_);
  3912. }
  3913. sub t2h_default_click($$$$$)
  3914. {
  3915. my $context = shift;
  3916. my $command = shift;
  3917. my $args = shift;
  3918. my $arg = shift @$args;
  3919. my $cmd = get_conf('clickstyle');
  3920. $cmd = 'arrow' if (!defined($cmd) or ($cmd eq ''));
  3921. my $hash = \%things_map;
  3922. if ($context eq 'pre')
  3923. {
  3924. $hash = \%pre_map;
  3925. }
  3926. elsif ($context eq 'texi')
  3927. {
  3928. $hash = \%texi_map;
  3929. }
  3930. return $hash->{$cmd} . $arg if (exists($hash->{$cmd}));
  3931. return $arg;
  3932. }
  3933. sub t2h_default_hyphenation($$)
  3934. {
  3935. my $command = shift;
  3936. my $args = shift;
  3937. my $text = shift @$args;
  3938. $text =~ s/^\s*//;
  3939. $text =~ s/\s*$//;
  3940. my @list = split /\s+/, $text;
  3941. foreach my $entry (@list)
  3942. {
  3943. my $word = $entry;
  3944. $word =~ s/-//g;
  3945. $Texi2HTML::THISDOC{'hyphenation'}->{$word} = $entry;
  3946. }
  3947. }
  3948. sub t2h_default_no_texi_email
  3949. {
  3950. my $command = shift;
  3951. my $args = shift;
  3952. my $mail = shift @$args;
  3953. my $text = shift @$args;
  3954. $mail = main::normalise_space($mail);
  3955. if (defined($text))
  3956. {
  3957. $text = main::normalise_space($text);
  3958. }
  3959. return $text if (defined($text) and ($text ne ''));
  3960. return $mail;
  3961. }
  3962. sub t2h_default_no_texi_image($$$$)
  3963. {
  3964. my $command = shift;
  3965. my $args = shift;
  3966. my $file = $args->[0];
  3967. $file = main::trim_around_spaces($file);
  3968. return main::substitute_line($file, "\@$command", {'remove_texi' => 1, 'code_style' => 1});
  3969. }
  3970. sub t2h_default_no_texi_acronym_like($$)
  3971. {
  3972. my $command = shift;
  3973. my $args = shift;
  3974. my $acronym_texi = $args->[0];
  3975. return (main::remove_texi($acronym_texi));
  3976. }
  3977. sub t2h_remove_command($$$$)
  3978. {
  3979. return '';
  3980. }
  3981. # This is used for style in preformatted sections
  3982. my %old_style_map_pre = %old_style_map;
  3983. $old_style_map_pre{'sc'} = '&default_sc_pre';
  3984. $old_style_map_pre{'titlefont'} = '';
  3985. foreach my $command (keys(%style_map))
  3986. {
  3987. $style_map_texi{$command} = {} if (!exists($style_map_texi{$command}));
  3988. $style_map_texi{$command}->{'args'} = [ @{$style_map{$command}->{'args'}} ]
  3989. if (exists($style_map{$command}->{'args'}));
  3990. #print STDERR "COMMAND $command";
  3991. }
  3992. %style_map_pre = ();
  3993. t2h_default_copy_style_map(\%style_map, \%style_map_pre);
  3994. $style_map_pre{'sc'} = {};
  3995. $style_map_pre{'titlefont'} = {};
  3996. $style_map_pre{'click'}->{'function'} = \&t2h_default_click_pre;
  3997. $style_map_texi{'sc'} = {};
  3998. $style_map_texi{'email'}->{'function'} = \&t2h_default_no_texi_email;
  3999. $style_map_texi{'click'}->{'function'} = \&t2h_default_click_texi;
  4000. ####### special styles. You shouldn't need to change them
  4001. %special_style = (
  4002. #'xref' => ['keep','normal','normal','keep','normal'],
  4003. 'xref' => { 'args' => ['keep','keep','keep','keep','keep'],
  4004. 'function' => \&main::do_xref },
  4005. 'ref' => { 'args' => ['keep','keep','keep','keep','keep'],
  4006. 'function' => \&main::do_xref },
  4007. 'pxref' => { 'args' => ['keep','keep','keep','keep','keep'],
  4008. 'function' => \&main::do_xref },
  4009. 'inforef' => { 'args' => ['keep','keep','keep'],
  4010. 'function' => \&main::do_xref },
  4011. 'image' => { 'args' => ['keep','keep','keep','keep','keep'], 'function' => \&main::do_image },
  4012. 'anchor' => { 'args' => ['keep'], 'function' => \&main::do_anchor_label },
  4013. 'footnote' => { 'args' => ['keep'], 'function' => \&main::do_footnote },
  4014. 'shortcaption' => { 'args' => ['keep'], 'function' => \&main::do_caption_shortcaption },
  4015. 'caption' => { 'args' => ['keep'], 'function' => \&main::do_caption_shortcaption },
  4016. 'acronym', {'args' => ['keep','keep'], 'function' => \&main::do_acronym_like},
  4017. 'abbr', {'args' => ['keep','keep'], 'function' => \&main::do_acronym_like},
  4018. );
  4019. # @image is replaced by the first arg in strings
  4020. $style_map_texi{'image'} = { 'args' => ['keep','keep','keep','keep','keep'],
  4021. 'function' => \&t2h_default_no_texi_image };
  4022. $style_map_texi{'acronym'} = { 'args' => ['keep','keep'],
  4023. 'function' => \&t2h_default_no_texi_acronym_like };
  4024. $style_map_texi{'abbr'} = { 'args' => ['keep','keep'],
  4025. 'function' => \&t2h_default_no_texi_acronym_like };
  4026. foreach my $special (keys(%special_style))
  4027. {
  4028. $style_map{$special} = $special_style{$special}
  4029. unless (defined($style_map{$special}));
  4030. $style_map_pre{$special} = $special_style{$special}
  4031. unless (defined($style_map_pre{$special}));
  4032. $style_map_texi{$special} = { 'args' => ['keep'],
  4033. 'function' => \&t2h_remove_command }
  4034. unless (defined($style_map_texi{$special}));
  4035. }
  4036. ####### end special styles.
  4037. #foreach my $command (keys(%style_map))
  4038. #{
  4039. # print STDERR "STYLE_MAP_TEXI $command($style_map_texi{$command}) ";
  4040. # print STDERR "ARGS $style_map_texi{$command}->{'args'} " if (defined($style_map_texi{$command}->{'args'}));
  4041. # print STDERR "FUN $style_map_texi{$command}->{'function'} " if (defined($style_map_texi{$command}->{'function'}));
  4042. # print STDERR "\n";
  4043. #}
  4044. # uncomment to use the old interface
  4045. #%style_map = %old_style_map;
  4046. #%style_map_pre = %old_style_map_pre;
  4047. %simple_format_simple_map_texi = %simple_map_pre;
  4048. %simple_format_texi_map = %pre_map;
  4049. %simple_format_style_map_texi = ();
  4050. t2h_default_copy_style_map(\%style_map_texi, \%simple_format_style_map_texi);
  4051. foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents))
  4052. {
  4053. # $simple_format_style_map_texi{$accent_command}->{'args'} = ['normal'];
  4054. $simple_format_style_map_texi{$accent_command}->{'function'} = \&t2h_default_accent;
  4055. }
  4056. foreach my $hash (\%style_map, \%style_map_pre, \%style_map_texi, \%simple_format_style_map_texi)
  4057. {
  4058. foreach my $style (keys(%{$hash}))
  4059. {
  4060. $hash->{$style}->{'args'} = ['normal'] if (!exists($hash->{$style}->{'args'}));
  4061. }
  4062. }
  4063. %default_style_map = ();
  4064. %default_style_map_pre = ();
  4065. %default_style_map_texi = ();
  4066. %default_simple_format_style_map_texi = ();
  4067. t2h_default_copy_style_map(\%style_map, \%default_style_map);
  4068. t2h_default_copy_style_map(\%style_map_pre, \%default_style_map_pre);
  4069. t2h_default_copy_style_map(\%style_map_texi, \%default_style_map_texi);
  4070. t2h_default_copy_style_map(\%simple_format_style_map_texi, \%default_simple_format_style_map_texi);
  4071. # called here because %default_style_map_texi is used.
  4072. t2h_default_set_variables_default();
  4073. #################################################################
  4074. # TeX/LaTeX styles, that can be used in math
  4075. my %default_style_tex_map;
  4076. my %default_style_latex_map;
  4077. t2h_default_copy_style_map(\%default_style_map, \%default_style_tex_map);
  4078. t2h_default_copy_style_map(\%default_style_map, \%default_style_latex_map);
  4079. # common in TeX and LaTeX and both for math and normal text
  4080. $default_style_latex_map{'w'}->{'inline_begin'} = '\mbox{';
  4081. $default_style_tex_map{'w'}->{'inline_begin'} = '\mbox{';
  4082. $default_style_latex_map{'dmn'}->{'inline_begin'} = '{\thinspace ';
  4083. $default_style_tex_map{'dmn'}->{'inline_begin'} = '{\thinspace ';
  4084. my %default_style_latex_math_map;
  4085. t2h_default_copy_style_map(\%default_style_latex_map, \%default_style_latex_math_map);
  4086. my %default_tex_latex_map = (
  4087. 'bf' => [ 'b', 'strong' ],
  4088. 'tt' => [ 'code', 'command', 'env', 'file', 'option', 'samp', 't' ],
  4089. 'it' => [ 'i', 'var', 'emph' ],
  4090. 'sf' => [ 'sanserif' ],
  4091. 'rm' => [ 'r' ],
  4092. 'sl' => [ 'dfn', 'slanted' ],
  4093. );
  4094. foreach my $style (keys (%default_tex_latex_map))
  4095. {
  4096. foreach my $command (@{$default_tex_latex_map{$style}})
  4097. {
  4098. $default_style_tex_map{$command}->{'inline_begin'} = '{\\' . $style .' ';
  4099. $default_style_latex_map{$command}->{'inline_begin'} = '\text' . $style .'{';
  4100. $style = 'normal' if ($style eq 'sl');
  4101. $default_style_latex_math_map{$command}->{'inline_begin'} = '\math' . $style .'{';
  4102. }
  4103. }
  4104. # only in text
  4105. $default_style_latex_map{'emph'}->{'inline_begin'} = '\emph{';
  4106. $default_style_latex_map{'var'}->{'inline_begin'} = '\emph{';
  4107. $default_style_latex_map{'sc'}->{'inline_begin'} = '\textsc{';
  4108. foreach my $hash (\%default_style_tex_map, \%default_style_latex_map, \%default_style_latex_math_map)
  4109. {
  4110. foreach my $command (keys(%$hash))
  4111. {
  4112. $hash->{$command}->{'inline_end'} = '}' if ($hash->{$command}->{'inline_begin'});
  4113. }
  4114. }
  4115. # no kbd key sc in math
  4116. # 'kbd' - ?
  4117. # 'key' - ?
  4118. my %default_style_tex_math_map;
  4119. t2h_default_copy_style_map(\%default_style_tex_map, \%default_style_tex_math_map);
  4120. # We don't want to override special commands in math mode for now, as long
  4121. # as they are not handled especially. Also we don't want to modify the math
  4122. # function, it is called to close the @math command and we don't want
  4123. # it to be the turned to the default one when calling
  4124. # FIXME maybe it would be even better not to duplicate default styles in
  4125. # math, like 'email', 'uref'....
  4126. foreach my $command (keys(%special_style), 'math')
  4127. {
  4128. delete $default_style_tex_math_map{$command};
  4129. delete $default_style_latex_math_map{$command};
  4130. }
  4131. foreach my $accent_command ('tieaccent', 'dotless', keys(%unicode_accents))
  4132. {
  4133. $default_style_latex_map{$accent_command} = { 'function' => \&default_tex_accent };
  4134. $default_style_tex_map{$accent_command} = { 'function' => \&default_tex_accent };
  4135. $default_style_tex_math_map{$accent_command} = { 'function' => \&default_tex_math_accent };
  4136. $default_style_latex_math_map{$accent_command} = { 'function' => \&default_latex_math_accent };
  4137. }
  4138. my %tex_text_accent_map = (
  4139. ',' => 'c',
  4140. 'ringaccent' => 'r',
  4141. 'dotaccent' => '.',
  4142. 'ubaraccent' => 'b',
  4143. 'udotaccent' => 'd',
  4144. 'ogonek' => 'k',
  4145. 'tieaccent' => 'tie',
  4146. );
  4147. sub default_tex_accent($$)
  4148. {
  4149. my $text = shift;
  4150. my $accent = shift;
  4151. return "\\$tex_text_accent_map{$accent}\{$text\}" if ($tex_text_accent_map{$accent});
  4152. if ($accent eq 'dotless')
  4153. {
  4154. return "\\$text" if ($text eq 'i' or $text eq 'j');
  4155. return $text;
  4156. }
  4157. return "\\$accent\{$text\}";
  4158. }
  4159. my %tex_math_accent_map = (
  4160. "'" => 'acute',
  4161. '^' => 'hat',
  4162. '`' => 'grave',
  4163. '~' => 'tilde',
  4164. '"' => 'ddot',
  4165. '=' => 'bar',
  4166. 'dotaccent' => 'dot',
  4167. 'u' => 'breve',
  4168. 'ubaraccent' => 'underline',
  4169. );
  4170. sub default_latex_math_accent($$)
  4171. {
  4172. my $text = shift;
  4173. my $accent = shift;
  4174. return '\mathring{'.$text.'}' if ($accent eq 'ringaccent');
  4175. return default_tex_math_accent($text, $accent);
  4176. }
  4177. sub default_tex_math_accent($$)
  4178. {
  4179. my $text = shift;
  4180. my $accent = shift;
  4181. return "\\$tex_text_accent_map{$accent}\{$text\}" if ($tex_text_accent_map{$accent});
  4182. if ($accent eq 'dotless')
  4183. {
  4184. return "\\${text}math" if ($text eq 'i' or $text eq 'j');
  4185. return $text;
  4186. }
  4187. return ascii_accent($text, $accent);
  4188. }
  4189. my $kept_normal_text;
  4190. # We assume that in @math the TeX characters have already been
  4191. # rightly protected and so don't protect once more.
  4192. sub default_tex_normal_math_text($$$$$$$;$)
  4193. {
  4194. my @initial_args = @_;
  4195. my $text = shift;
  4196. my $in_raw_text = shift; # remove_texi
  4197. my $in_preformatted = shift;
  4198. my $in_code = shift;
  4199. my $in_math = shift;
  4200. my $in_simple = shift;
  4201. my $style_stack = shift;
  4202. my $state = shift;
  4203. # Don't protect text in math
  4204. if ($in_math)
  4205. {
  4206. $text = uc($text) if (in_cmd($style_stack, 'sc'));
  4207. return $text;
  4208. }
  4209. return &kept_normal_text(@initial_args);
  4210. }
  4211. # This is the entry point to be used by users.
  4212. sub default_load_tex_math(;$)
  4213. {
  4214. my $style = shift;
  4215. $style = 'latex' if (!defined($style));
  4216. %simple_map_math = %tex_default_simple_map_math;
  4217. if ($style eq 'tex')
  4218. {
  4219. %math_map = %tex_default_math_things_map;
  4220. t2h_default_copy_style_map(\%default_style_tex_math_map, \%style_map_math);
  4221. }
  4222. else
  4223. {
  4224. %math_map = %latex_default_math_things_map;
  4225. t2h_default_copy_style_map(\%default_style_latex_math_map, \%style_map_math);
  4226. }
  4227. $kept_normal_text = $normal_text;
  4228. $normal_text = \&default_tex_normal_math_text;
  4229. }
  4230. # End TeX/LaTeX styles
  4231. #################################################################
  4232. # regions expanded or not depending on the value of this hash.
  4233. # @EXPAND sets entries in this hash, and you should better use
  4234. # @EXPAND unless you know what you are doing.
  4235. %texi_formats_map = (
  4236. 'iftex' => 0,
  4237. 'ignore' => 0,
  4238. 'menu' => 0,
  4239. 'ifplaintext' => 0,
  4240. 'ifinfo' => 0,
  4241. 'ifxml' => 0,
  4242. 'ifhtml' => 0,
  4243. 'ifdocbook' => 0,
  4244. # 'html' => 0,
  4245. # 'tex' => 0,
  4246. # 'xml' => 0,
  4247. # 'docbook' => 0,
  4248. 'titlepage' => 1,
  4249. 'documentdescription' => 1,
  4250. 'copying' => 1,
  4251. 'ifnothtml' => 1,
  4252. 'ifnottex' => 1,
  4253. 'ifnotplaintext' => 1,
  4254. 'ifnotinfo' => 1,
  4255. 'ifnotxml' => 1,
  4256. 'ifnotdocbook' => 1,
  4257. 'direntry' => 'normal',
  4258. 'verbatim' => 'raw',
  4259. 'macro' => 'raw',
  4260. 'ifclear' => 'value',
  4261. 'ifset' => 'value' ,
  4262. );
  4263. %format_map = (
  4264. # 'quotation' => 'blockquote',
  4265. # lists
  4266. # 'itemize' => 'ul',
  4267. 'enumerate' => '',
  4268. # 'multitable' => 'table',
  4269. 'table' => '',
  4270. 'vtable' => '',
  4271. 'ftable' => '',
  4272. 'group' => '',
  4273. 'raggedright' => '',
  4274. # 'detailmenu' => '',
  4275. );
  4276. %special_list_commands = (
  4277. 'table' => {},
  4278. 'vtable' => {},
  4279. 'ftable' => {},
  4280. # 'itemize' => { 'bullet' => '' }
  4281. 'itemize' => {},
  4282. );
  4283. %inter_item_commands = (
  4284. 'c' => 1,
  4285. 'comment' => 1,
  4286. 'cindex' => 1
  4287. );
  4288. #
  4289. # texinfo format to align attribute of paragraphs
  4290. #
  4291. %paragraph_style = (
  4292. 'center' => 'center',
  4293. 'flushleft' => 'left',
  4294. 'flushright' => 'right',
  4295. );
  4296. # complex formats (preformatted)
  4297. %complex_format_map = ();
  4298. foreach my $complex_format ('example', 'smallexample', 'display',
  4299. 'smalldisplay', 'lisp', 'smalllisp', 'format', 'smallformat',
  4300. 'menu', 'detailmenu', 'direntry', 'menu_comment')
  4301. {
  4302. $complex_format_map{$complex_format} = { 'begin' => '', 'end' => '' };
  4303. }
  4304. foreach my $code_complex_format ('example', 'smallexample', 'lisp', 'smalllisp')
  4305. {
  4306. $complex_format_map{$code_complex_format}->{'style'} = 'code';
  4307. }
  4308. # not in code_style, according to post on bug-texinfo
  4309. foreach my $format ('menu', 'detailmenu', 'direntry')
  4310. {
  4311. $complex_format_map{$format}->{'class'} = 'menu-preformatted';
  4312. }
  4313. # not in code_style, according to post on bug-texinfo
  4314. $complex_format_map{'menu_comment'}->{'class'} = 'menu-comment';
  4315. %def_map = (
  4316. # basic commands
  4317. 'deffn', [ 'f', 'category', 'name', 'arg' ],
  4318. 'defvr', [ 'v', 'category', 'name' ],
  4319. 'deftypefn', [ 'f', 'category', 'type', 'name', 'argtype' ],
  4320. 'deftypeop', [ 'f', 'category', 'class' , 'type', 'name', 'argtype' ],
  4321. 'deftypevr', [ 'v', 'category', 'type', 'name' ],
  4322. 'defcv', [ 'v', 'category', 'class' , 'name' ],
  4323. 'deftypecv', [ 'v', 'category', 'class' , 'type', 'name' ],
  4324. 'defop', [ 'f', 'category', 'class' , 'name', 'arg' ],
  4325. 'deftp', [ 't', 'category', 'name', 'argtype' ],
  4326. # shortcuts
  4327. # FIXME i18n
  4328. 'defun', 'deffn Function',
  4329. 'defmac', 'deffn Macro',
  4330. 'defspec', 'deffn {Special Form}',
  4331. 'defvar', 'defvr Variable',
  4332. 'defopt', 'defvr {User Option}',
  4333. 'deftypefun', 'deftypefn {Function}',
  4334. 'deftypevar', 'deftypevr Variable',
  4335. 'defivar', 'defcv {Instance Variable}',
  4336. 'deftypeivar', 'deftypecv {Instance Variable}',
  4337. 'defmethod', 'defop Method',
  4338. 'deftypemethod', 'deftypeop Method',
  4339. );
  4340. $def_always_delimiters = "()[]";
  4341. $def_in_type_delimiters = ",;";
  4342. $def_argument_separator_delimiters = "()[],";
  4343. $warn_var_character_quoted = quotemeta("()[],");
  4344. # basic x commands
  4345. foreach my $key (keys(%def_map))
  4346. {
  4347. $def_map{$key . 'x'} = $def_map{$key};
  4348. }
  4349. #
  4350. # miscalleneous commands
  4351. #
  4352. # Depending on the value, the command arg or spaces following the command
  4353. # are handled differently:
  4354. #
  4355. # the value is a reference on a hash.
  4356. # the hash keys are
  4357. # 'arg' if the value is 'line' then the remaining of the line is the arg
  4358. # if it is a number it is the number of args (separated by spaces)
  4359. # 'skip' if the value is 'line' then the remaining of the line is skipped
  4360. # if the value is 'space' space but no newline is skipped
  4361. # if the value is 'whitespace' space is skipped
  4362. # if the value is 'linewhitespace' space is skipped if there are
  4363. # only spaces remaining on the line
  4364. # if the value is 'linespace' space but no newline is skipped if
  4365. # there are only spaces remaining on the line
  4366. # 'keep' if true the args and the macro are kept, otherwise the macro
  4367. # args and skipped stuffs are removed
  4368. %misc_command = (
  4369. 'bye' => {'skip' => 'line'}, # no arg
  4370. # set, clear
  4371. #'set' => {'skip' => 'line'}, # special arg
  4372. 'set' => {'arg' => 'line'}, # special arg
  4373. #'clear' => {'skip' => 'line'}, # special arg
  4374. 'clear' => {'arg' => 1, 'skip' => 'line'}, # special arg
  4375. 'alias' => {'args' => 3, 'skip' => 'line'}, # special arg
  4376. # comments
  4377. 'comment' => {'arg' => 'line'},
  4378. 'c' => {'arg' => 'line'},
  4379. # not needed for formatting
  4380. 'raisesections' => {'skip' => 'line'}, # no arg
  4381. 'lowersections' => {'skip' => 'line'}, # no arg
  4382. 'contents' => {}, # no arg
  4383. 'shortcontents' => {}, # no arg
  4384. 'summarycontents'=> {}, # no arg
  4385. 'setcontentsaftertitlepage' => {}, # no arg
  4386. 'setshortcontentsaftertitlepage' => {}, # no arg
  4387. #'clickstyle' => {'skip' => 'line'}, # arg should be an @-command
  4388. 'clickstyle' => {'arg' => 'line'}, # arg should be an @-command
  4389. # in preamble
  4390. 'novalidate' => {}, # no arg
  4391. 'dircategory'=> {'arg' => 'line'}, # line. Position with regard
  4392. # with direntry is significant
  4393. 'pagesizes' => {'skip' => 'line', 'arg' => 'line'}, # can have 2 args
  4394. # or one? 200mm,150mm 11.5in
  4395. 'finalout' => {'skip' => 'line'}, # no arg
  4396. 'paragraphindent' => {'skip' => 'line', 'arg' => 1}, # arg none asis
  4397. # or a number and forbids anything else on the line
  4398. 'firstparagraphindent' => {'skip' => 'line', 'arg' => 1}, # none insert
  4399. 'frenchspacing' => {'arg' => 1, 'skip' => 'line'}, # on off
  4400. # not so sure about 'skip' => 'line'
  4401. 'fonttextsize' => {'arg' => 1}, # 10 11
  4402. 'allowcodebreaks' => {'arg' => 1, 'skip' => 'line'}, # false or true
  4403. 'exampleindent' => {'skip' => 'line', 'arg' => 1}, # asis or a number
  4404. 'footnotestyle'=> {'skip' => 'line', 'arg' => 1}, # end and separate
  4405. # and nothing else on the line
  4406. 'afourpaper' => {'skip' => 'line'}, # no arg
  4407. 'afivepaper' => {'skip' => 'line'}, # no arg
  4408. 'afourlatex' => {'skip' => 'line'}, # no arg
  4409. 'afourwide' => {'skip' => 'line'}, # no arg
  4410. 'headings'=> {'skip' => 'line', 'arg' => 1},
  4411. #off on single double singleafter doubleafter
  4412. # interacts with setchapternewpage
  4413. 'setchapternewpage' => {'skip' => 'line', 'arg' => 1}, # off on odd
  4414. 'everyheading' => {'arg' => 'line'},
  4415. 'everyfooting' => {'arg' => 'line'},
  4416. 'evenheading' => {'arg' => 'line'},
  4417. 'evenfooting' => {'arg' => 'line'},
  4418. 'oddheading' => {'arg' => 'line'},
  4419. 'oddfooting' => {'arg' => 'line'},
  4420. 'smallbook' => {'skip' => 'line'}, # no arg
  4421. 'setfilename' => {'arg' => 'line'},
  4422. 'definfoenclose' => {'arg' => 'line'},
  4423. #'shorttitle' => {'arg' => 'line', 'texi' => 1},
  4424. #'shorttitlepage' => {'arg' => 'line', 'texi' => 1},
  4425. #'settitle' => {'arg' => 'line', 'texi' => 1},
  4426. #'author' => {'arg' => 'line', 'texi' => 1},
  4427. #'subtitle' => {'arg' => 'line', 'texi' => 1},
  4428. #'title' => {'arg' => 'line', 'texi' => 1},
  4429. 'shorttitle' => {'arg' => 'line'},
  4430. 'shorttitlepage' => {'arg' => 'line'},
  4431. 'settitle' => {'arg' => 'line'},
  4432. 'author' => {'arg' => 'line'},
  4433. 'subtitle' => {'arg' => 'line'},
  4434. 'title' => {'arg' => 'line'},
  4435. 'syncodeindex' => {'skip' => 'line', 'arg' => 2},
  4436. # args are index identifiers
  4437. 'synindex' => {'skip' => 'line', 'arg' => 2},
  4438. 'defindex' => {'skip' => 'line', 'arg' => 1}, # one identifier arg
  4439. 'defcodeindex' => {'skip' => 'line', 'arg' => 1}, # one identifier arg
  4440. #'documentlanguage' => {'skip' => 'whitespace', 'arg' => 1},
  4441. 'documentlanguage' => {'skip' => 'line', 'arg' => 1},
  4442. # language code arg
  4443. 'kbdinputstyle' => {'skip' => 'whitespace', 'arg' => 1}, # code
  4444. #example distinct
  4445. 'everyheadingmarks' => {'skip' => 'line', 'arg' => 1}, # top bottom
  4446. 'everyfootingmarks' => {'skip' => 'whitespace', 'arg' => 1},
  4447. 'evenheadingmarks' => {'skip' => 'whitespace', 'arg' => 1},
  4448. 'oddheadingmarks' => {'skip' => 'whitespace', 'arg' => 1},
  4449. 'evenfootingmarks' => {'skip' => 'whitespace', 'arg' => 1},
  4450. 'oddfootingmarks' => {'skip' => 'whitespace', 'arg' => 1},
  4451. 'sp' => {'skip' => 'line', 'arg' => 1}, # no arg
  4452. # at the end of line or a numerical arg
  4453. # formatting
  4454. 'page' => {}, # no arg (pagebreak)
  4455. 'refill' => {}, # no arg (obsolete, to be ignored)
  4456. 'noindent' => {'skip' => 'whitespace'}, # no arg
  4457. 'indent' => {'skip' => 'whitespace'},
  4458. 'need' => {'skip' => 'line', 'arg' => 1}, # one numerical/real arg
  4459. 'exdent' => {'skip' => 'space'},
  4460. # not valid for info (should be in @iftex)
  4461. 'vskip' => {'arg' => 'line'}, # arg line in TeX
  4462. 'cropmarks' => {}, # no arg
  4463. # miscalleneous
  4464. 'verbatiminclude'=> {'arg' => 'line'},
  4465. 'documentencoding' => {'arg' => 1, 'skip' => 'line'},
  4466. # obsolete @-commands. Remove spaces and end of lines after the
  4467. # commands? If no, they can lead to empty lines
  4468. 'quote-arg' => {'skip' => 'line'},
  4469. 'allow-recursion' => {'skip' => 'line'},
  4470. );
  4471. my %misc_command_old = (
  4472. # not needed for formatting
  4473. 'raisesections', 'line', # no arg
  4474. 'lowersections', 'line', # no arg
  4475. 'contents', 1, # no arg
  4476. 'shortcontents', 1, # no arg
  4477. 'summarycontents', 1, # no arg
  4478. 'detailmenu', 'whitespace', # no arg
  4479. 'end detailmenu', 'whitespace', # no arg
  4480. #'end detailmenu', 1, # no arg
  4481. 'novalidate', 1, # no arg
  4482. 'bye', 'line', # no arg
  4483. # comments
  4484. 'comment', 'line',
  4485. 'c', 'line',
  4486. # in preamble
  4487. 'dircategory', 'line', # line. Position with regard with direntry is
  4488. # significant
  4489. 'pagesizes', 'line arg2', # can have 2 args
  4490. 'finalout', 1, # no arg
  4491. 'paragraphindent', 'line arg1', # in fact accepts only none asis
  4492. # or a number and forbids anything else on the line
  4493. 'firstparagraphindent', 'line arg1', # in fact accepts only none insert
  4494. 'exampleindent', 'line arg1', # in fact accepts only asis or a number
  4495. 'footnotestyle', 'line arg1', # in fact accepts only end and separate
  4496. # and nothing else on the line
  4497. 'afourpaper', 'line', # no arg
  4498. 'afourlatex', 'line', # no arg
  4499. 'afourwide', 'line', # no arg
  4500. 'headings', 'line', # one arg, possibilities are
  4501. #off on single double singleafter doubleafter
  4502. # interacts with setchapternewpage
  4503. 'setchapternewpage', 'line', # no arg
  4504. 'everyheading', 'line',
  4505. 'everyfooting', 'line',
  4506. 'evenheading', 'line',
  4507. 'evenfooting', 'line',
  4508. 'oddheading', 'line',
  4509. 'oddfooting', 'line',
  4510. 'smallbook', 'line', # no arg
  4511. 'setfilename', 'line',
  4512. 'shorttitle', 'linetexi',
  4513. 'shorttitlepage', 'linetexi',
  4514. 'settitle', 'linetexi',
  4515. 'author', 'linetexi',
  4516. 'subtitle', 'linetexi',
  4517. 'title','linetexi',
  4518. 'syncodeindex','linespace arg2', # args are
  4519. 'synindex','linespace arg2',
  4520. 'defindex', 'line arg1', # one identifier arg
  4521. 'defcodeindex', 'line arg1', # one identifier arg
  4522. 'documentlanguage', 'whitespace arg1', # one language code arg
  4523. 'kbdinputstyle', 'whitespace arg1', # one arg within
  4524. #code example distnct
  4525. 'sp', 'whitespace arg1', # no arg at the en of line or a numerical arg
  4526. # formatting
  4527. 'page', 1, # no arg (pagebreak)
  4528. 'refill', 1, # no arg (obsolete, to be ignored))
  4529. 'noindent', 'space', # no arg
  4530. 'need', 'line arg1', # one numerical/real arg
  4531. 'exdent', 'space',
  4532. # not valid for info (should be in @iftex)
  4533. 'vskip', 'line', # arg line in TeX
  4534. 'cropmarks', 1, # no arg
  4535. # miscalleneous
  4536. 'verbatiminclude', 'line',
  4537. 'documentencoding', 'arg1',
  4538. );
  4539. # The command_handler arrays are for commands formatted externally.
  4540. # The function references in @command_handler_init are called
  4541. # before the second pass, before the @-commands text collection.
  4542. # Those in @command_handler_process are called between the second pass
  4543. # and the third pass, after collection of @-commands text and before their
  4544. # expansion.
  4545. # Those in @command_handler_process are called after the third pass,
  4546. # after the document generation.
  4547. @command_handler_setup = ();
  4548. @command_handler_init = ();
  4549. @command_handler_names = ();
  4550. @command_handler_process = ();
  4551. @command_handler_output = ();
  4552. @command_handler_finish = ();
  4553. sub t2h_default_push_handler($$)
  4554. {
  4555. my $function = shift;
  4556. my $handlers = shift;
  4557. push @$handlers, $function unless (grep {$_ eq $function} @$handlers);
  4558. }
  4559. # the keys of %command_handler are @-command names and the value
  4560. # is a hash reference with the following keys:
  4561. # 'init' function reference used to collect the @-command text
  4562. # 'expand' function reference used when expanding the @-command text
  4563. %command_handler = ();
  4564. # formatting functions
  4565. $anchor = \&t2h_default_anchor;
  4566. $def_item = \&t2h_default_def_item;
  4567. $def = \&t2h_default_def;
  4568. $menu_command = \&t2h_default_menu_command;
  4569. $menu_link = \&t2h_default_menu_link;
  4570. #$menu_comment = \&t2h_default_menu_comment;
  4571. $menu_description = \&t2h_default_menu_description;
  4572. #$simple_menu_link = \&t2h_default_simple_menu_link;
  4573. $table_item = \&t2h_default_table_item;
  4574. $table_line = \&t2h_default_table_line;
  4575. $table_list = \&t2h_default_table_list;
  4576. $row = \&t2h_default_row;
  4577. $cell = \&t2h_default_cell;
  4578. $list_item = \&t2h_default_list_item;
  4579. $comment = \&t2h_default_comment;
  4580. $def_line = \&t2h_default_def_line;
  4581. $def_line_no_texi = \&t2h_default_def_line_no_texi;
  4582. $raw = \&t2h_default_raw;
  4583. $raw_no_texi = \&t2h_default_raw_no_texi;
  4584. $heading = \&t2h_default_heading;
  4585. $heading_text = \&t2h_default_heading_text;
  4586. $heading_text_preformatted = \&t2h_default_heading_text_preformatted;
  4587. $element_heading = \&t2h_default_element_heading;
  4588. $heading_no_texi = \&t2h_default_heading_no_texi;
  4589. $external_href = \&t2h_default_external_href;
  4590. $paragraph = \&t2h_default_paragraph;
  4591. $preformatted = \&t2h_default_preformatted;
  4592. $foot_line_and_ref = \&t2h_default_foot_line_and_ref;
  4593. $foot_section = \&t2h_default_foot_section;
  4594. $image_files = \&t2h_default_image_files;
  4595. $image = \&t2h_default_image;
  4596. $index_entry_label = \&t2h_default_index_entry_label;
  4597. $index_summary = \&t2h_default_index_summary;
  4598. $summary_letter = \&t2h_default_summary_letter;
  4599. $index_entry = \&t2h_default_index_entry;
  4600. $index_entry_command = \&t2h_default_index_entry_command;
  4601. $index_letter = \&t2h_default_index_letter;
  4602. #$printindex = \&t2h_default_printindex;
  4603. $print_index = \&t2h_default_print_index;
  4604. $protect_text = \&t2h_default_protect_text;
  4605. $normal_text = \&t2h_default_normal_text;
  4606. $cartouche = \&t2h_default_cartouche;
  4607. $sp = \&t2h_default_sp;
  4608. $definition_category = \&t2h_default_definition_category;
  4609. $definition_index_entry = \&t2h_default_definition_index_entry;
  4610. $copying_comment = \&t2h_default_copying_comment;
  4611. $documentdescription = \&t2h_default_documentdescription;
  4612. $index_summary_file_entry = \&t2h_default_index_summary_file_entry;
  4613. $index_summary_file_end = \&t2h_default_index_summary_file_end;
  4614. $index_summary_file_begin = \&t2h_default_index_summary_file_begin;
  4615. $empty_line = \&t2h_default_empty_line;
  4616. $float = \&t2h_default_float;
  4617. $listoffloats = \&t2h_default_listoffloats;
  4618. $listoffloats_entry = \&t2h_default_listoffloats_entry;
  4619. $listoffloats_caption = \&t2h_default_listoffloats_caption;
  4620. $listoffloats_float_style = \&t2h_default_listoffloats_float_style;
  4621. $listoffloats_style = \&t2h_default_listoffloats_style;
  4622. $acronym_like = \&t2h_default_acronym_like;
  4623. $quotation = \&t2h_default_quotation;
  4624. $paragraph_style_command = \&t2h_default_paragraph_style_command;
  4625. $heading_texi = \&t2h_default_heading_texi;
  4626. $index_element_heading_texi = \&t2h_default_index_element_heading_texi;
  4627. $element_label = \&t2h_default_element_label;
  4628. $anchor_label = \&t2h_default_anchor_label;
  4629. $preserve_misc_command = \&t2h_default_preserve_misc_command;
  4630. $format_list_item_texi = \&t2h_default_format_list_item_texi;
  4631. $begin_format_texi = \&t2h_default_begin_format_texi;
  4632. $insertcopying = \&t2h_default_insertcopying;
  4633. $simple_command = \&t2h_default_simple_command;
  4634. $thing_command = \&t2h_default_thing_command;
  4635. $line_command = \&t2h_default_line_command;
  4636. $internal_links = \&t2h_default_internal_links;
  4637. # address is not used anymore
  4638. $address = \&t2h_default_address;
  4639. # return the line after preserving things according to misc_command map.
  4640. # You should not change it. It is here, nevertheless, to be used
  4641. # in other function references if needed.
  4642. sub t2h_default_preserve_misc_command($$)
  4643. {
  4644. my $line = shift;
  4645. my $macro = shift;
  4646. my $text = '';
  4647. my $args = [];
  4648. my $skip_spec = '';
  4649. my $arg_spec = '';
  4650. #print STDERR "HHHHHHHHH $line $macro\n";
  4651. $skip_spec = $misc_command{$macro}->{'skip'}
  4652. if (defined($misc_command{$macro}->{'skip'}));
  4653. $arg_spec = $misc_command{$macro}->{'arg'}
  4654. if (defined($misc_command{$macro}->{'arg'}));
  4655. if ($arg_spec eq 'line')
  4656. {
  4657. $text .= $line;
  4658. $args = [ $line ];
  4659. $line = '';
  4660. }
  4661. elsif ($arg_spec)
  4662. {
  4663. my $arg_nr = $misc_command{$macro}->{'arg'};
  4664. while ($arg_nr)
  4665. {
  4666. if ($line =~ s/^(\s+)(\S*)//o)
  4667. {
  4668. $text .= $1.$2;
  4669. my $argument = $2;
  4670. push @$args, $argument if ($argument ne '');
  4671. }
  4672. else
  4673. {
  4674. last;
  4675. }
  4676. $arg_nr--;
  4677. }
  4678. # while ($arg_nr)
  4679. # {
  4680. # $line =~ s/(\s+\S*)//o;
  4681. # my $argument = $1;
  4682. # if (defined($argument))
  4683. # {
  4684. # $text .= $argument;
  4685. # push @$args, $argument;
  4686. # }
  4687. # $arg_nr--;
  4688. # }
  4689. }
  4690. if ($macro eq 'bye')
  4691. {
  4692. $line = '';
  4693. $text = "\n";
  4694. }
  4695. elsif ($skip_spec eq 'linespace')
  4696. {
  4697. if ($line =~ /^\s*$/o)
  4698. {
  4699. $line =~ s/^([ \t]*)//o;
  4700. $text .= $1;
  4701. }
  4702. }
  4703. elsif ($skip_spec eq 'linewhitespace')
  4704. {
  4705. if ($line =~ /^\s*$/o)
  4706. {
  4707. $text .= $line;
  4708. $line = '';
  4709. }
  4710. }
  4711. elsif ($skip_spec eq 'line')
  4712. {
  4713. $text .= $line;
  4714. $line = '';
  4715. }
  4716. elsif ($skip_spec eq 'whitespace')
  4717. {
  4718. $line =~ s/^(\s*)//o;
  4719. $text .= $1;
  4720. }
  4721. elsif ($skip_spec eq 'space')
  4722. {
  4723. $line =~ s/^([ \t]*)//o;
  4724. $text .= $1;
  4725. }
  4726. $line = '' if (!defined($line));
  4727. return ($line, $text, $args);
  4728. }
  4729. sub t2h_default_simple_command($$$$$)
  4730. {
  4731. my $command = shift;
  4732. my $in_preformatted = shift;
  4733. my $in_math = shift;
  4734. my $line_nr = shift;
  4735. my $state = shift;
  4736. if ($in_math)
  4737. {
  4738. my $result = $simple_map_pre{$command};
  4739. $result = $simple_map_math{$command} if (defined($simple_map_math{$command}));
  4740. return $result;
  4741. }
  4742. elsif ($in_preformatted)
  4743. {
  4744. return $simple_map_pre{$command};
  4745. }
  4746. else
  4747. {
  4748. return $simple_map{$command};
  4749. }
  4750. }
  4751. sub t2h_default_thing_command($$$$$$)
  4752. {
  4753. my $command = shift;
  4754. my $text = shift;
  4755. my $in_preformatted = shift;
  4756. my $in_math = shift;
  4757. my $line_nr = shift;
  4758. my $state = shift;
  4759. my $result;
  4760. if ($in_math)
  4761. {
  4762. $result = $pre_map{$command};
  4763. $result = $math_map{$command} if (defined($math_map{$command}));
  4764. }
  4765. elsif ($in_preformatted)
  4766. {
  4767. $result = $pre_map{$command};
  4768. }
  4769. else
  4770. {
  4771. $result = $things_map{$command};
  4772. }
  4773. return $result . $text;
  4774. }
  4775. # this is called each time a format begins. Here it is used to keep a
  4776. # record of the multitables to have a faithful count of the cell nr.
  4777. sub t2h_default_begin_format_texi($$$)
  4778. {
  4779. my $command = shift;
  4780. my $line = shift;
  4781. my $state = shift;
  4782. # remove space in front of center, unless it removes the end of line!
  4783. $line =~ s/^\s*// if ($command eq 'center' and $line =~ /\S/);
  4784. return $line;
  4785. }
  4786. # This function is called whenever a complex format is processed
  4787. #
  4788. # arguments:
  4789. # name of the format
  4790. # text appearing inside the format
  4791. #
  4792. # an eval of $complex_format->{format name}->{'begin'} should lead to the
  4793. # beginning of the complex format, an eval of
  4794. # $complex_format->{format name}->{'end'} should lead to the end of the
  4795. # complex format.
  4796. sub t2h_default_complex_format($$)
  4797. {
  4798. my $name = shift;
  4799. my $text = shift;
  4800. return '' if ($text eq '');
  4801. return '' if ($name eq 'direntry');
  4802. my $beginning;
  4803. my $end;
  4804. # FIXME obsoleted in nov 2009
  4805. if (exists($complex_format_map->{$name}))
  4806. {
  4807. $beginning = eval "$complex_format_map->{$name}->{'begin'}";
  4808. if ($@ ne '')
  4809. {
  4810. main::msg_debug("Evaluation of $complex_format_map->{$name}->{'begin'}: $@");
  4811. $beginning = '';
  4812. }
  4813. $end = eval "$complex_format_map->{$name}->{'end'}";
  4814. if ($@ ne '')
  4815. {
  4816. main::msg_debug("Evaluation of $complex_format_map->{$name}->{'end'}: $@");
  4817. $end = '';
  4818. }
  4819. }
  4820. else
  4821. {
  4822. $beginning = $complex_format_map{$name}->{'begin'};
  4823. $beginning = '' if (!defined($beginning));
  4824. $end = $complex_format_map{$name}->{'end'};
  4825. $end = '' if (!defined($end));
  4826. }
  4827. return $beginning . $text . $end;
  4828. }
  4829. sub t2h_default_empty_line($$)
  4830. {
  4831. my $text = shift;
  4832. my $state = shift;
  4833. #ignore the line if it just follows a deff
  4834. return '' if ($state->{'deff_line'});
  4835. return $text;
  4836. }
  4837. sub t2h_default_unknown($$$$$)
  4838. {
  4839. my $macro = shift;
  4840. my $line = shift;
  4841. my $pass = shift;
  4842. my $stack = shift;
  4843. my $state = shift;
  4844. my ($result_line, $result, $result_text, $message);
  4845. return ($line, 0, undef, undef);
  4846. }
  4847. sub t2h_default_unknown_style($$$$$)
  4848. {
  4849. my $command = shift;
  4850. my $text = shift;
  4851. my $state = shift;
  4852. my $no_close = shift;
  4853. my $no_open = shift;
  4854. my ($result, $result_text, $message);
  4855. return (0, undef, undef);
  4856. }
  4857. sub t2h_default_caption_shortcaption($)
  4858. {
  4859. my $float = shift;
  4860. my $caption_lines;
  4861. my $shortcaption_lines;
  4862. my $style = $float->{'style_texi'};
  4863. if (defined($float->{'nr'}))
  4864. {
  4865. my $nr = $float->{'nr'};
  4866. if ($style ne '')
  4867. {
  4868. $style = gdt('{style} {number}', { 'style' => $style, 'number' => $nr});
  4869. }
  4870. else
  4871. {
  4872. $style = $nr;
  4873. }
  4874. }
  4875. my $empty_caption = 1;
  4876. if (defined($float->{'caption_texi'}) and @{$float->{'caption_texi'}})
  4877. {
  4878. @$caption_lines = @{$float->{'caption_texi'}};
  4879. $caption_lines->[0] =~ s/^\s*//;
  4880. if ($caption_lines->[0] =~ /\S/ or @$caption_lines > 2)
  4881. {
  4882. $empty_caption = 0;
  4883. }
  4884. }
  4885. if (!$empty_caption)
  4886. {
  4887. if (defined($style))
  4888. {
  4889. $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . gdt('{style}: {caption_first_line}', { 'style' => $style, 'caption_first_line' => $caption_lines->[0] });
  4890. }
  4891. else
  4892. {
  4893. $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $caption_lines->[0];
  4894. }
  4895. push @$caption_lines, "}\n";
  4896. }
  4897. elsif (defined($style))
  4898. {
  4899. $caption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $style . '}' . "\n";
  4900. }
  4901. my $empty_shortcaption = 1;
  4902. if (defined($float->{'shortcaption_texi'}) and @{$float->{'shortcaption_texi'}})
  4903. {
  4904. @$shortcaption_lines = @{$float->{'shortcaption_texi'}};
  4905. $shortcaption_lines->[0] =~ s/^\s*//;
  4906. if ($shortcaption_lines->[0] =~ /\S/ or @$shortcaption_lines > 1)
  4907. {
  4908. $empty_shortcaption = 0;
  4909. }
  4910. }
  4911. if (!$empty_shortcaption)
  4912. {
  4913. if (defined($style))
  4914. {
  4915. $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' . gdt('{style}: {shortcaption_first_line}', { 'style' => $style, 'shortcaption_first_line' => $shortcaption_lines->[0] });
  4916. }
  4917. else
  4918. {
  4919. $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $shortcaption_lines->[0];
  4920. }
  4921. push @$shortcaption_lines, "}\n";
  4922. }
  4923. elsif (defined($style))
  4924. {
  4925. $shortcaption_lines->[0] = '@'.$CAPTION_STYLE.'{' . $style . '}' . "\n";
  4926. }
  4927. return ($caption_lines, $shortcaption_lines);
  4928. }
  4929. # everything is done in &$float
  4930. sub t2h_default_caption_shortcaption_command($$$$)
  4931. {
  4932. my $command = shift;
  4933. my $text = shift;
  4934. my $texi_lines = shift;
  4935. my $float_element = shift;
  4936. return '';
  4937. }
  4938. sub t2h_default_float($$$$$)
  4939. {
  4940. my $text = shift;
  4941. my $float = shift;
  4942. my $caption = shift;
  4943. my $shortcaption = shift;
  4944. my $label = '';
  4945. if (exists($float->{'id'}))
  4946. {
  4947. $label = &$anchor($float->{'id'});
  4948. }
  4949. my $caption_text = '';
  4950. if (defined($float->{'caption_texi'}))
  4951. {
  4952. $caption_text = $caption;
  4953. }
  4954. elsif (defined($float->{'shortcaption_texi'}))
  4955. {
  4956. $caption_text = $shortcaption;
  4957. }
  4958. elsif (defined($caption))
  4959. {
  4960. $caption_text = $caption;
  4961. }
  4962. return $text . "\n" . $caption_text;
  4963. }
  4964. sub t2h_default_listoffloats_style($)
  4965. {
  4966. my $style_texi = shift;
  4967. return ($style_texi);
  4968. }
  4969. sub t2h_default_listoffloats_float_style($$)
  4970. {
  4971. my $style_texi = shift;
  4972. my $float = shift;
  4973. my $style = $float->{'style_texi'};
  4974. #print STDERR "listoffloat/float style mismatch $style_texi $style\n" if ($style_texi ne $style);
  4975. if (defined($float->{'nr'}))
  4976. {
  4977. my $nr = $float->{'nr'};
  4978. if ($style ne '')
  4979. {
  4980. $style = gdt('{style} {number}', { 'style' => $style, 'number' => $nr});
  4981. }
  4982. else
  4983. {
  4984. $style = $nr;
  4985. }
  4986. }
  4987. return $style;
  4988. }
  4989. sub t2h_default_listoffloats_caption($)
  4990. {
  4991. my $float = shift;
  4992. if (defined($float->{'shortcaption_texi'}))
  4993. {
  4994. return ([ @{$float->{'shortcaption_texi'}} ], 'shortcaption');
  4995. }
  4996. elsif (defined($float->{'caption_texi'}))
  4997. {
  4998. return ([ @{$float->{'caption_texi'}} ], 'caption');
  4999. }
  5000. return ([ ], undef);
  5001. }
  5002. sub t2h_default_listoffloats_entry($$$$)
  5003. {
  5004. my $style_texi = shift;
  5005. my $float = shift;
  5006. my $float_style = shift;
  5007. my $caption = shift;
  5008. my $href = shift;
  5009. my @lines = split /^/, $caption;
  5010. $caption = $lines[0];
  5011. $caption = '' if (!defined($caption));
  5012. chomp ($caption);
  5013. $caption = $float->{'text'} if ($caption eq '' and defined($float->{'text'}) and $float->{'text'} =~ /\S/);
  5014. return "* $float_style: ${caption}\n";
  5015. }
  5016. sub t2h_default_listoffloats($$$)
  5017. {
  5018. my $style_texi = shift;
  5019. my $style = shift;
  5020. my $float_entries = shift;
  5021. my $result = "* List of $style:\n";
  5022. foreach my $float_entry (@$float_entries)
  5023. {
  5024. $result .= $float_entry;
  5025. }
  5026. return $result . "\n";
  5027. }
  5028. sub t2h_default_insertcopying($$$)
  5029. {
  5030. my $text = shift;
  5031. my $comment = shift;
  5032. my $simple_text = shift;
  5033. return $text;
  5034. }
  5035. sub t2h_default_protect_text($)
  5036. {
  5037. my $text = shift;
  5038. return $text;
  5039. }
  5040. # This function is used to protect characters which are special in xml
  5041. # in inline text: &, ", <, and >.
  5042. #
  5043. # argument:
  5044. # text to be protected
  5045. sub xml_default_protect_text($)
  5046. {
  5047. my $text = shift;
  5048. $text =~ s/&/&amp;/g;
  5049. $text =~ s/</&lt;/g;
  5050. $text =~ s/>/&gt;/g;
  5051. $text =~ s/\"/&quot;/g;
  5052. return $text;
  5053. }
  5054. sub in_cmd($$)
  5055. {
  5056. my $style_stack = shift;
  5057. my $command = shift;
  5058. my $result = 0;
  5059. if ($style_stack and scalar(@{$style_stack}))
  5060. {
  5061. my $level = $#$style_stack;
  5062. #print STDERR ":::$level ::@{$style_stack}\n";
  5063. while ($level >= 0)
  5064. {
  5065. if ($style_stack->[$level] eq $command)
  5066. {
  5067. $result = 1;
  5068. last;
  5069. }
  5070. $level--;
  5071. }
  5072. }
  5073. return $result;
  5074. }
  5075. #
  5076. #
  5077. sub in_small_caps($)
  5078. {
  5079. my $style_stack = shift;
  5080. my $in_sc = 0;
  5081. if ($style_stack and scalar(@{$style_stack}))
  5082. {
  5083. my $level = $#$style_stack;
  5084. #print STDERR ":::$level ::@{$style_stack}\n";
  5085. while ($level >= 0)
  5086. {
  5087. if ($style_stack->[$level] eq 'sc')
  5088. {
  5089. $in_sc = 1;
  5090. last;
  5091. }
  5092. $level--;
  5093. }
  5094. }
  5095. return $in_sc;
  5096. }
  5097. #
  5098. #
  5099. sub t2h_default_normal_text($$$$$$$;$)
  5100. {
  5101. my @initial_args = @_;
  5102. my $text = shift;
  5103. my $in_raw_text = shift; # remove_texi
  5104. my $in_preformatted = shift;
  5105. my $in_code = shift;
  5106. my $in_math = shift;
  5107. my $in_simple = shift;
  5108. my $style_stack = shift;
  5109. my $state = shift;
  5110. # like utf8.pm
  5111. 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' and get_conf('USE_UNICODE'))
  5112. {
  5113. return &t2h_utf8_normal_text(@initial_args);
  5114. }
  5115. $text = uc($text) if (in_cmd($style_stack, 'sc'));
  5116. if (! $in_code and !$in_preformatted)
  5117. {
  5118. $text =~ s/---/\x{1F}/g;
  5119. $text =~ s/--/-/g;
  5120. $text =~ s/\x{1F}/--/g;
  5121. $text =~ s/``/"/g;
  5122. $text =~ s/\'\'/"/g;
  5123. }
  5124. else
  5125. {
  5126. # to be like tex. This would be wrong, however.
  5127. # my $special_code = 0;
  5128. # $special_code = 1 if (in_cmd($style_stack, 'code') or
  5129. # in_cmd($style_stack, 'example') or in_cmd($style_stack, 'verbatim'));
  5130. # $text =~ s/'/\&rsquo\;/g unless ($special_code and exists($main::value{'txicodequoteundirected'}));
  5131. # $text =~ s/`/\&lsquo\;/g unless ($special_code and exists($main::value{'txicodequotebacktick'}));
  5132. }
  5133. $text = t2h_text_substitutions($text, $in_raw_text, ($in_preformatted or $in_code), $in_simple);
  5134. return $text;
  5135. }
  5136. sub t2h_default_url_and_text($;$)
  5137. {
  5138. my $url = shift;
  5139. my $text = shift;
  5140. if (!defined($text) or $text eq '')
  5141. {
  5142. return "<$url>" if (defined($url) and $url ne '');
  5143. return '';
  5144. }
  5145. else
  5146. {
  5147. return $text if (!defined($url) or $url eq '');
  5148. return "$text <$url>";
  5149. }
  5150. }
  5151. # This function produces an anchor. This need is quite html specific.
  5152. #
  5153. # arguments:
  5154. # $name : anchor name
  5155. # $href : anchor href
  5156. # text : text displayed
  5157. # extra_attribs : added to anchor attributes list
  5158. sub t2h_default_anchor($;$$$)
  5159. {
  5160. my $name = shift;
  5161. my $href = shift;
  5162. my $text = shift;
  5163. my $attributes = shift;
  5164. return $text if (defined($text));
  5165. return '';
  5166. }
  5167. # This function is used to format the text associated with a @deff/@end deff
  5168. #
  5169. # argument:
  5170. # text
  5171. #
  5172. # DEF_TABLE should be used to distinguish between @def formatted as table
  5173. # and as definition lists.
  5174. sub t2h_default_def_item($$$)
  5175. {
  5176. my $text = shift;
  5177. my $only_inter_item_commands = shift;
  5178. my $command = shift;
  5179. if ($text =~ /\S/)
  5180. {
  5181. return $text;
  5182. }
  5183. return '';
  5184. }
  5185. sub t2h_default_definition_category($$$$)
  5186. {
  5187. my $name = shift;
  5188. my $class = shift;
  5189. my $style = shift;
  5190. my $command = shift;
  5191. return ($name) if (!defined($class) or $class =~ /^\s*$/);
  5192. if ($style eq 'f')
  5193. {
  5194. return gdt('{name} on {class}', { 'name' => $name, 'class' => $class });
  5195. }
  5196. elsif ($style eq 'v')
  5197. {
  5198. return gdt('{name} of {class}', { 'name' => $name, 'class' => $class });
  5199. }
  5200. else
  5201. {
  5202. return $name;
  5203. }
  5204. }
  5205. sub t2h_default_definition_index_entry($$$$)
  5206. {
  5207. my $name = shift;
  5208. my $class = shift;
  5209. my $style = shift;
  5210. my $command = shift;
  5211. return ($name) if (!defined($class) or $class =~ /^\s*$/);
  5212. if ($style eq 'f')
  5213. {
  5214. return gdt('{name} on {class}', { 'name' => $name, 'class' => $class });
  5215. }
  5216. elsif ($style eq 'v' and $command ne 'defcv')
  5217. {
  5218. return gdt('{name} of {class}', { 'name' => $name, 'class' => $class });
  5219. }
  5220. else
  5221. {
  5222. return $name;
  5223. }
  5224. }
  5225. sub t2h_default_summary_letter($$$$$$$)
  5226. {
  5227. my $letter = shift;
  5228. my $file = shift;
  5229. my $default_identifier = shift;
  5230. my $index_element_id = shift;
  5231. my $number = shift;
  5232. my $index_element = shift;
  5233. my $index_name = shift;
  5234. return '';
  5235. }
  5236. # format the container for the @deffn line and text
  5237. #
  5238. # argument
  5239. # text of the whole @def, line and associated text.
  5240. #
  5241. # DEF_TABLE should be used.
  5242. sub t2h_default_def($$)
  5243. {
  5244. my $text = shift;
  5245. my $command = shift;
  5246. if ($text =~ /\S/)
  5247. {
  5248. return $text;
  5249. }
  5250. return '';
  5251. }
  5252. # a whole menu
  5253. #
  5254. # argument:
  5255. # the whole menu text (entries and menu comments)
  5256. #
  5257. # argument:
  5258. # whole menu text.
  5259. # not used since menu is a normal preformatted command with SIMPLE_MENU
  5260. sub t2h_default_menu_command($$$)
  5261. {
  5262. my $format = shift;
  5263. my $text = shift;
  5264. my $in_preformatted = shift;
  5265. return "* Menu:\n".$text."\n";
  5266. }
  5267. # formats a menu entry link pointing to a node or section
  5268. #
  5269. # arguments:
  5270. # the entry text
  5271. # the state, a hash reference holding informations about the context, with a
  5272. # usefull entry, 'preformatted', true if we are in a preformatted format
  5273. # (a format keeping space between words). In that case a function
  5274. # of the main program, main::do_preformatted($text, $state) might
  5275. # be used to format the text with the current format style.
  5276. # href is optionnal. It is the reference to the section or the node anchor
  5277. # which should be used to make the link (typically it is the argument
  5278. # of a href= attribute in a <a> element).
  5279. sub t2h_default_menu_link($$$$$$$$)
  5280. {
  5281. my $entry = shift;
  5282. my $state = shift;
  5283. my $href = shift;
  5284. my $node = shift;
  5285. my $title = shift;
  5286. my $ending = shift;
  5287. my $has_title = shift;
  5288. my $command_stack = shift;
  5289. my $preformatted = shift;
  5290. $title = '' unless ($has_title);
  5291. $title .= ':' if ($title ne '');
  5292. return "$MENU_SYMBOL$title$node$ending" if (get_conf('NODE_NAME_IN_MENU'));
  5293. return "$MENU_SYMBOL$title$entry$ending";
  5294. }
  5295. # formats a menu entry description, ie the text appearing after the node
  5296. # specification in a menu entry an spanning until there is another
  5297. # menu entry, an empty line or some text at the very beginning of the line
  5298. # (we consider that text at the beginning of the line begins a menu comment)
  5299. #
  5300. # arguments:
  5301. # the description text
  5302. # the state. See menu_entry.
  5303. # the heading of the element associated with the node.
  5304. # not usd since in SIMPLE_MENU
  5305. sub t2h_default_menu_description($$$$)
  5306. {
  5307. my $text = shift;
  5308. my $state = shift;
  5309. my $element_text = shift;
  5310. my $command_stack = shift;
  5311. my $preformatted = shift;
  5312. return $text;
  5313. }
  5314. %htmlxref_entries = (
  5315. 'node' => [ 'node', 'section', 'chapter', 'mono' ],
  5316. 'section' => [ 'section', 'chapter','node', 'mono' ],
  5317. 'chapter' => [ 'chapter', 'section', 'node', 'mono' ],
  5318. 'mono' => [ 'mono', 'chapter', 'section', 'node' ],
  5319. );
  5320. # Construct a href to an external source of information.
  5321. # node is the node with texinfo @-commands
  5322. # node_id is the node transliterated and transformed as explained in the
  5323. # texinfo manual
  5324. # node_xhtml_id is the node transformed such that it is unique and can
  5325. # be used to make an html cross ref as explained in the texinfo manual
  5326. # file is the file in '(file)node'
  5327. # This is used to construct href, so is likely to be ignored oustside of
  5328. # html.
  5329. sub t2h_default_external_href($$$)
  5330. {
  5331. my $node = shift;
  5332. my $node_id = shift;
  5333. my $node_xhtml_id = shift;
  5334. my $file = shift;
  5335. $file = '' if (!defined($file));
  5336. my $default_target_split = get_conf('EXTERNAL_CROSSREF_SPLIT');
  5337. my $target_split;
  5338. #my $target_mono;
  5339. #my $href_split;
  5340. #my $href_mono;
  5341. if ($file ne '')
  5342. {
  5343. if (get_conf('NEW_CROSSREF_STYLE'))
  5344. {
  5345. $file =~ s/\.[^\.]*$//;
  5346. $file =~ s/^.*\///;
  5347. my $href;
  5348. my $document_split = get_conf('SPLIT');
  5349. $document_split = 'mono' if (!$document_split);
  5350. my $split_found;
  5351. if (exists($Texi2HTML::THISDOC{'htmlxref'}->{$file}))
  5352. {
  5353. foreach my $split_ordered (@{$htmlxref_entries{$document_split}})
  5354. {
  5355. if (defined($Texi2HTML::THISDOC{'htmlxref'}->{$file}->{$split_ordered}))
  5356. {
  5357. $split_found = $split_ordered;
  5358. $href = $Texi2HTML::THISDOC{'htmlxref'}->{$file}->{$split_ordered};
  5359. last;
  5360. }
  5361. }
  5362. }
  5363. if (defined($split_found))
  5364. {
  5365. $target_split = 1 unless ($split_found eq 'mono');
  5366. }
  5367. else
  5368. { # nothing specified for that manual, use default
  5369. $target_split = $default_target_split;
  5370. }
  5371. if ($target_split)
  5372. {
  5373. if (defined($href))
  5374. {
  5375. $file = $href;
  5376. }
  5377. elsif (defined(get_conf('EXTERNAL_DIR')))
  5378. {
  5379. $file = get_conf('EXTERNAL_DIR')."/$file";
  5380. }
  5381. elsif (get_conf('SPLIT'))
  5382. {
  5383. $file = "../$file";
  5384. }
  5385. $file .= "/";
  5386. }
  5387. else
  5388. {# target not split
  5389. if (defined($href))
  5390. {
  5391. $file = $href;
  5392. }
  5393. else
  5394. {
  5395. if (defined(get_conf('EXTERNAL_DIR')))
  5396. {
  5397. $file = get_conf('EXTERNAL_DIR')."/$file";
  5398. }
  5399. elsif (get_conf('SPLIT'))
  5400. {
  5401. $file = "../$file";
  5402. }
  5403. $file .= "." . get_conf('NODE_FILE_EXTENSION');
  5404. }
  5405. }
  5406. }
  5407. else
  5408. {
  5409. $file .= "/";
  5410. if (defined(get_conf('EXTERNAL_DIR')))
  5411. {
  5412. $file = get_conf('EXTERNAL_DIR') . $file;
  5413. }
  5414. else
  5415. {
  5416. $file = '../' . $file;
  5417. }
  5418. }
  5419. }
  5420. else
  5421. {
  5422. $target_split = $default_target_split;
  5423. }
  5424. if ($node eq '')
  5425. {
  5426. if (get_conf('NEW_CROSSREF_STYLE'))
  5427. {
  5428. if ($target_split)
  5429. {
  5430. if (defined(get_conf('TOP_NODE_FILE_TARGET')))
  5431. {
  5432. return $file . get_conf('TOP_NODE_FILE_TARGET') . '.' . get_conf('NODE_FILE_EXTENSION') . '#Top';
  5433. }
  5434. else
  5435. {
  5436. return $file . '#Top';
  5437. }
  5438. }
  5439. else
  5440. {
  5441. return $file . '#Top';
  5442. }
  5443. }
  5444. else
  5445. {
  5446. return $file;
  5447. }
  5448. }
  5449. my $target;
  5450. if (get_conf('NEW_CROSSREF_STYLE'))
  5451. {
  5452. $node = $node_id;
  5453. $target = $node_xhtml_id;
  5454. }
  5455. else
  5456. {
  5457. $node = main::remove_texi($node);
  5458. $node =~ s/[^\w\.\-]/-/g;
  5459. }
  5460. my $file_basename = $node;
  5461. $file_basename = get_conf('TOP_NODE_FILE_TARGET') if ($node =~ /^top$/i and defined(get_conf('TOP_NODE_FILE_TARGET')));
  5462. if (get_conf('NEW_CROSSREF_STYLE'))
  5463. {
  5464. if ($target_split)
  5465. {
  5466. return $file . $file_basename . '.'.get_conf('NODE_FILE_EXTENSION') . '#' . $target;
  5467. }
  5468. else
  5469. {
  5470. return $file . '#' . $target;
  5471. }
  5472. }
  5473. else
  5474. {
  5475. return $file . $file_basename . '.'.get_conf('NODE_FILE_EXTENSION');
  5476. }
  5477. }
  5478. # format a reference external to the generated manual. This produces a full
  5479. # reference with introductive words and the reference itself.
  5480. #
  5481. # arguments:
  5482. # type of the reference: xref (reference at the beginning of a sentence),
  5483. # pxref (reference in a parenthesis),
  5484. # section in the book. This might be undef.
  5485. # book name.
  5486. # manual file name
  5487. # href linking to the html page containing the referenced node. A typical
  5488. # use for this href is a href attribute in an <a> element
  5489. # cross reference name
  5490. # array of texi arguments of the reference
  5491. # array of the formatted arguments of the reference
  5492. # node name
  5493. sub t2h_default_external_ref($$$$$$$$$)
  5494. {
  5495. my $type = shift;
  5496. my $section = shift;
  5497. my $book = shift;
  5498. my $file = shift;
  5499. #my $file_node = shift;
  5500. my $href = shift;
  5501. my $cross_ref = shift;
  5502. my $args_texi = shift;
  5503. my $formatted_args = shift;
  5504. my $node = shift;
  5505. my $name = $section;
  5506. $name = $cross_ref if ($name eq '');
  5507. $name = $node if ($name eq '');
  5508. my $reference = $name;
  5509. if ($book eq '' and $file ne '')
  5510. {
  5511. $name = "($file)$name";
  5512. }
  5513. $reference = &$anchor('', $href, $name) if ($href ne '');
  5514. # Yes, this is ugly, yet this helps internationalization
  5515. if ($type eq 'pxref')
  5516. {
  5517. if (($book ne '') and ($href ne ''))
  5518. {
  5519. return gdt('see {reference} in @cite{{book}}', { 'reference' => $reference, 'book' => $book },{'duplicate'=>1});
  5520. }
  5521. elsif (($book ne '') and ($reference ne ''))
  5522. {
  5523. return gdt('see `{section}\' in @cite{{book}}', { 'section' => $reference, 'book' => $book },{'duplicate'=>1});
  5524. }
  5525. elsif ($book ne '')
  5526. { # should seldom or even never happen
  5527. return gdt('see @cite{{book}}', { 'book' => $book },{'duplicate'=>1});
  5528. }
  5529. elsif ($href ne '')
  5530. {
  5531. return gdt('see {reference}', { 'reference' => $reference },{'duplicate'=>1});
  5532. }
  5533. elsif ($reference ne '')
  5534. {
  5535. return gdt('see `{section}\'', { 'section' => $reference },{'duplicate'=>1});
  5536. }
  5537. }
  5538. if ($type eq 'xref' or $type eq 'inforef')
  5539. {
  5540. if (($book ne '') and ($href ne ''))
  5541. {
  5542. return gdt('See {reference} in @cite{{book}}', { 'reference' => $reference, 'book' => $book },{'duplicate'=>1});
  5543. }
  5544. elsif (($book ne '') and ($reference ne ''))
  5545. {
  5546. return gdt('See `{section}\' in @cite{{book}}', { 'section' => $reference, 'book' => $book },{'duplicate'=>1});
  5547. }
  5548. elsif ($book ne '')
  5549. { # should seldom or even never happen
  5550. return gdt('See @cite{{book}}', { 'book' => $book },{'duplicate'=>1});
  5551. }
  5552. elsif ($href ne '')
  5553. {
  5554. return gdt('See {reference}', { 'reference' => $reference },{'duplicate'=>1});
  5555. }
  5556. elsif ($reference ne '')
  5557. {
  5558. return gdt('See `{section}\'', { 'section' => $reference },{'duplicate'=>1});
  5559. }
  5560. }
  5561. if ($type eq 'ref')
  5562. {
  5563. if (($book ne '') and ($href ne ''))
  5564. {
  5565. return gdt('{reference} in @cite{{book}}', { 'reference' => $reference, 'book' => $book },{'duplicate'=>1});
  5566. }
  5567. elsif (($book ne '') and ($reference ne ''))
  5568. {
  5569. return gdt('`{section}\' in @cite{{book}}', { 'section' => $reference, 'book' => $book },{'duplicate'=>1});
  5570. }
  5571. elsif ($book ne '')
  5572. { # should seldom or even never happen
  5573. return gdt('@cite{{book}}', { 'book' => $book },{'duplicate'=>1});
  5574. }
  5575. elsif ($href ne '')
  5576. {
  5577. return gdt('{reference}', { 'reference' => $reference },{'duplicate'=>1});
  5578. }
  5579. elsif ($reference ne '')
  5580. {
  5581. return gdt('`{section}\'', { 'section' => $reference },{'duplicate'=>1});
  5582. }
  5583. }
  5584. return '';
  5585. }
  5586. # format a reference to a node or a section in the generated manual. This
  5587. # produces a full reference with introductive words and the reference itself.
  5588. #
  5589. # arguments:
  5590. # type of the reference: xref (reference at the beginning of a sentence),
  5591. # pxref (reference in a parenthesis),
  5592. # href linking to the html page containing the node or the section. A typical
  5593. # use for this href is a href attribute in an <a> element
  5594. # short name for this reference
  5595. # name for this reference
  5596. # boolean true if the reference is a reference to a section
  5597. #
  5598. # SHORT_REF should be used.
  5599. sub t2h_default_internal_ref($$$$$$$$)
  5600. {
  5601. my $type = shift;
  5602. my $href = shift;
  5603. my $short_name = shift;
  5604. my $name = shift;
  5605. my $is_section = shift;
  5606. my $args_texi = shift;
  5607. my $formatted_args = shift;
  5608. my $element = shift;
  5609. if (! get_conf('SHORT_REF'))
  5610. {
  5611. $name = &$anchor('', $href, $name);
  5612. if ($type eq 'pxref')
  5613. {
  5614. return gdt('see section {reference_name}', { 'reference_name' => $name },{'duplicate'=>1}) if ($is_section);
  5615. return gdt('see {reference_name}', { 'reference_name' => $name },{'duplicate'=>1});
  5616. }
  5617. elsif ($type eq 'xref' or $type eq 'inforef')
  5618. {
  5619. return gdt('See section {reference_name}', { 'reference_name' => $name },{'duplicate'=>1}) if ($is_section);
  5620. return gdt('See {reference_name}', { 'reference_name' => $name },{'duplicate'=>1});
  5621. }
  5622. elsif ($type eq 'ref')
  5623. {
  5624. return gdt('{reference_name}', { 'reference_name' => $name },{'duplicate'=>1});
  5625. }
  5626. }
  5627. else
  5628. {
  5629. $name = &$anchor('', $href, $short_name);
  5630. if ($type eq 'pxref')
  5631. {
  5632. return gdt('see {reference_name}', { 'reference_name' => $name },{'duplicate'=>1});
  5633. }
  5634. elsif ($type eq 'xref' or $type eq 'inforef')
  5635. {
  5636. return gdt('See {reference_name}', { 'reference_name' => $name },{'duplicate'=>1});
  5637. }
  5638. elsif ($type eq 'ref')
  5639. {
  5640. return gdt('{reference_name}', { 'reference_name' => $name },{'duplicate'=>1});
  5641. }
  5642. }
  5643. return '';
  5644. }
  5645. # text after @item in table, vtable and ftable
  5646. sub t2h_default_table_item($$$$$$$)
  5647. {
  5648. my $text = shift;
  5649. my $index_label = shift;
  5650. my $format = shift;
  5651. my $command = shift;
  5652. my $style_stack = shift;
  5653. my $item_cmd = shift;
  5654. my $formatted_index_entry = shift;
  5655. return $text . "\n";
  5656. }
  5657. # format text on the line following the @item line (in table, vtable and ftable)
  5658. sub t2h_default_table_line($$$)
  5659. {
  5660. my $text = shift;
  5661. my $only_inter_item_commands = shift;
  5662. my $before_items = shift;
  5663. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  5664. if ($text =~ /\S/)
  5665. {
  5666. return $text;
  5667. }
  5668. return '';
  5669. }
  5670. #my $cell_nr = -1;
  5671. # row in multitable
  5672. sub t2h_default_row($$$$$$$$)
  5673. {
  5674. my $text = shift;
  5675. my $macro = shift;
  5676. my $columnfractions = shift;
  5677. my $prototype_row = shift;
  5678. my $prototype_lengths = shift;
  5679. my $column_number = shift;
  5680. my $only_inter_item_commands = shift;
  5681. my $before_items = shift;
  5682. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  5683. if ($text =~ /\S/)
  5684. {
  5685. return $text ."\n";
  5686. }
  5687. return '';
  5688. }
  5689. # cell in multitable
  5690. sub t2h_default_cell($$$$$$$$)
  5691. {
  5692. my $text = shift;
  5693. my $row_macro = shift;
  5694. my $columnfractions = shift;
  5695. my $prototype_row = shift;
  5696. my $prototype_lengths = shift;
  5697. my $column_number = shift;
  5698. my $only_inter_item_commands = shift;
  5699. my $before_items = shift;
  5700. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  5701. $text =~ s/^\s*//;
  5702. $text =~ s/\s*$//;
  5703. return " $text";
  5704. }
  5705. # format an itemize, enumerate or @*table @item line, returning
  5706. # a texinfo line.
  5707. sub t2h_default_format_list_item_texi($$$$$)
  5708. {
  5709. my $format = shift;
  5710. my $line = shift;
  5711. my $prepended = shift;
  5712. my $command = shift;
  5713. my $number = shift;
  5714. my $result_line;
  5715. my $open_command = 0;
  5716. $command = 'bullet' if ((!defined($command) or $command eq '') and (!defined($prepended) or $prepended eq '') and $format eq 'itemize');
  5717. $prepended = "\@$command\{\}" if (defined($command) and $command ne '');
  5718. $prepended = "$number." if (defined($number) and $number ne '');
  5719. if (defined($command) and $command ne '' and $format ne 'itemize')
  5720. {
  5721. #@*table
  5722. $open_command = 1;
  5723. $line =~ s/^\s*//;
  5724. $line =~ s/\s*$//;
  5725. if (exists ($style_map{$command}))
  5726. {
  5727. $result_line = "\@$command\{$line\}\n";
  5728. }
  5729. elsif (exists ($things_map{$command}))
  5730. {
  5731. $result_line = "\@$command\{\} $line\n";
  5732. }
  5733. else
  5734. {
  5735. $result_line = "\@$command $line\n";
  5736. }
  5737. }
  5738. elsif (defined($prepended) and $prepended ne '')
  5739. {
  5740. $prepended =~ s/^\s*//;
  5741. $prepended =~ s/\s*$//;
  5742. $line =~ s/^\s*//;
  5743. $result_line = $prepended . ' ' . $line;
  5744. }
  5745. return ($result_line, $open_command);
  5746. }
  5747. # format an item in a list
  5748. #
  5749. # argument:
  5750. # text of the item
  5751. # format of the list (itemize or enumerate)
  5752. # command passed as argument to the format
  5753. # formatted_command leading command formatted, if it is a thing command
  5754. sub t2h_default_list_item($$$$$$$$$$$$)
  5755. {
  5756. my $text = shift;
  5757. my $format = shift;
  5758. my $command = shift;
  5759. my $formatted_command = shift;
  5760. my $item_nr = shift;
  5761. my $enumerate_style = shift;
  5762. my $number = shift;
  5763. my $prepended = shift;
  5764. my $prepended_formatted = shift;
  5765. my $only_inter_item_commands = shift;
  5766. my $before_items = shift;
  5767. my $item_command = shift;
  5768. $only_inter_item_commands = '' if (!defined($only_inter_item_commands));
  5769. if ($text =~ /\S/)
  5770. {
  5771. return $text;
  5772. }
  5773. return '';
  5774. }
  5775. sub t2h_default_table_list($$$$$$$$$)
  5776. {
  5777. my $format_command = shift;
  5778. my $text = shift;
  5779. my $command = shift;
  5780. my $formatted_command = shift;
  5781. # enumerate
  5782. my $item_nr = shift;
  5783. my $enumerate_style = shift;
  5784. # itemize
  5785. my $prepended = shift;
  5786. my $prepended_formatted = shift;
  5787. # multitable
  5788. my $columnfractions = shift;
  5789. my $prototype_row = shift;
  5790. my $prototype_lengths = shift;
  5791. my $column_number = shift;
  5792. # my $number = shift;
  5793. return $text;
  5794. }
  5795. # an comment
  5796. sub t2h_default_comment($)
  5797. {
  5798. my $text = shift;
  5799. return '';
  5800. }
  5801. # an xml comment
  5802. sub xml_default_comment($)
  5803. {
  5804. my $text = shift;
  5805. $text =~ s/--+/-/go;
  5806. return '<!-- ' . $text . ' -->' . "\n";
  5807. }
  5808. sub t2h_collect_styles($)
  5809. {
  5810. my $cmd_stack = shift;
  5811. my @result = ();
  5812. foreach my $style (reverse(@$cmd_stack))
  5813. {
  5814. # last unless (defined($command_type{$style}) and $command_type{$style} eq 'style');
  5815. push @result, $style if (defined($command_type{$style}) and $command_type{$style} eq 'style');
  5816. }
  5817. return @result;
  5818. }
  5819. sub html_default_parse_attribute($)
  5820. {
  5821. my $element = shift;
  5822. return ('', '', '') if (!defined($element));
  5823. my ($class, $attributes) = ('', '');
  5824. if ($element =~ /^(\w+)(\s+.*)/)
  5825. {
  5826. $element = $1;
  5827. $attributes = $2;
  5828. if ($attributes =~ s/^\s+class=\"([^\"]+)\"//)
  5829. {
  5830. $class = $1;
  5831. }
  5832. }
  5833. return ($element, $class, $attributes);
  5834. }
  5835. sub t2h_get_attribute($;$)
  5836. {
  5837. my $command = shift;
  5838. my $map_ref = shift;
  5839. $map_ref = \%style_map if (!defined($map_ref));
  5840. return unless (defined($map_ref->{$command}));
  5841. my ($element, $class, $attributes) = ('', '', '');
  5842. if (defined($map_ref->{$command}))
  5843. {
  5844. if (ref($map_ref->{$command}) eq 'HASH')
  5845. {
  5846. ($element, $class, $attributes) = t2h_html_parse_attribute ($map_ref->{$command}->{'attribute'});
  5847. }
  5848. elsif ($map_ref->{$command} !~ /^&/)
  5849. {
  5850. $element = $map_ref->{$command};
  5851. $element =~ s/^\"//;
  5852. }
  5853. }
  5854. return ($element, $class, $attributes);
  5855. }
  5856. # a paragraph
  5857. # arguments:
  5858. # $text of the paragraph
  5859. # $align for the alignement
  5860. # $indent for the indent style (indent or noindent)
  5861. # The following is usefull if the paragraph is in an itemize.
  5862. # $paragraph_command is the leading formatting command (like @minus)
  5863. # $paragraph_command_formatted is the leading formatting command formatted
  5864. # $paragraph_number is a reference on the number of paragraphs appearing
  5865. # in the format. The value should be increased if a paragraph is done
  5866. # $format is the format name (@itemize)
  5867. sub t2h_default_paragraph($$$$$$$$$$$$)
  5868. {
  5869. my $text = shift;
  5870. my $align = shift;
  5871. my $indent = shift;
  5872. my $paragraph_command = shift;
  5873. my $paragraph_command_formatted = shift;
  5874. my $paragraph_number = shift;
  5875. my $format = shift;
  5876. my $item_nr = shift;
  5877. my $enumerate_style = shift;
  5878. my $number = shift;
  5879. my $command_stack_at_end = shift;
  5880. my $command_stack_at_begin = shift;
  5881. #print STDERR "format: $format\n" if (defined($format));
  5882. #print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
  5883. # $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
  5884. # exists($special_list_commands{$format}->{$paragraph_command}));
  5885. return '' if ($text =~ /^\s*$/);
  5886. return $text;
  5887. }
  5888. # a preformatted region
  5889. # arguments:
  5890. # $text of the preformatted region
  5891. # $pre_style css style
  5892. # $class identifier for the preformatted region (example, menu-comment)
  5893. # The following is usefull if the preformatted is in an itemize.
  5894. # $leading_command is the leading formatting command (like @minus)
  5895. # $leading_command_formatted is the leading formatting command formatted
  5896. # $preformatted_number is a reference on the number of preformatteds appearing
  5897. # in the format. The value should be increased if a preformatted is done
  5898. sub t2h_default_preformatted($$$$$$$$$$$$)
  5899. {
  5900. my $text = shift;
  5901. my $pre_style = shift;
  5902. my $class = shift;
  5903. my $leading_command = shift;
  5904. my $leading_command_formatted = shift;
  5905. my $preformatted_number = shift;
  5906. my $format = shift;
  5907. my $item_nr = shift;
  5908. my $enumerate_style = shift;
  5909. my $number = shift;
  5910. my $command_stack_at_end = shift;
  5911. my $command_stack_at_begin = shift;
  5912. #print STDERR "preformatted @$command_stack_at_end; @$command_stack_at_begin\n";
  5913. return '' if ($text eq '');
  5914. my $top_stack = '';
  5915. $top_stack = $command_stack_at_begin->[-1] if (scalar (@$command_stack_at_begin));
  5916. if ($top_stack eq 'multitable')
  5917. {
  5918. $text =~ s/^\s*//;
  5919. $text =~ s/\s*$//;
  5920. }
  5921. # add a new line at the end in case there is none
  5922. chomp($text);
  5923. return $text . "\n";
  5924. }
  5925. # $new_element is set if the element is associated with a different
  5926. # reference element than the preceding element. This is where we
  5927. # do the navigation. For example it could be a @node before a @section.
  5928. #
  5929. # The heading function is always called, though -- in the default case
  5930. # nodes don't lead to an outputted title.
  5931. sub t2h_default_element_heading($$$$$$$$$$$$)
  5932. {
  5933. my $element = shift;
  5934. my $command = shift;
  5935. my $texi_line = shift;
  5936. my $line = shift;
  5937. my $in_preformatted = shift;
  5938. my $one_section = shift;
  5939. my $element_heading = shift;
  5940. my $first_in_page = shift;
  5941. my $is_top = shift;
  5942. my $previous_is_top = shift;
  5943. my $command_line = shift;
  5944. my $element_id = shift;
  5945. my $new_element = shift;
  5946. #print STDERR ":::::::: $element $command i_p $in_preformatted o_s $one_section e_h $element_heading f_p $first_in_page i_t $is_top p_i_t $previous_is_top id $element_id new $new_element\n";
  5947. # my $result = '';
  5948. my $result = &$element_label($element_id, $element, $command, $command_line);
  5949. # in default case, print_head_navigation and print_navigation are no-ops.
  5950. # and $print_element_header is undef, so the following nothing.
  5951. if ($new_element and !$one_section)
  5952. {
  5953. main::msg_debug ("For $element->{'texi'}, element_ref not defined", $element->{'line_nr'}) if (!defined($element->{'element_ref'}));
  5954. if (!defined($element->{'element_ref'}->{'top'}))
  5955. {
  5956. if (defined($print_element_header))
  5957. { # FIXME backward compatibility, print_element_header is obsoleted in nov 2009
  5958. $result .= &$print_element_header($first_in_page, $previous_is_top);
  5959. }
  5960. else
  5961. {
  5962. if (($first_in_page or $previous_is_top) and get_conf('HEADERS'))
  5963. {
  5964. $result .= &$print_head_navigation(undef, \@SECTION_BUTTONS, $first_in_page, $previous_is_top, $element);
  5965. }
  5966. else
  5967. { # got to do this here, as it isn't done otherwise sinc
  5968. # print_head_navigation is not called
  5969. $result .= &$print_navigation(\@SECTION_BUTTONS) if (get_conf('HEADERS') or get_conf('SPLIT') eq 'node');
  5970. }
  5971. }
  5972. }
  5973. else
  5974. { # this is here because we want to always print the head navigation for top
  5975. # and use TOP_BUTTONS
  5976. $result .= &$print_head_navigation(undef, \@TOP_BUTTONS, $first_in_page, $previous_is_top, $element)
  5977. if (get_conf('SPLIT') or get_conf('HEADERS'));
  5978. }
  5979. }
  5980. return $result. &$heading($element, $command, $texi_line, $line, $in_preformatted, $one_section, $element_heading);
  5981. }
  5982. # This function formats a heading for an element
  5983. #
  5984. # argument:
  5985. # an element. It is a hash reference for a node or a sectioning command.
  5986. # it may be the wrong one in case of headings.
  5987. # The interesting keys are:
  5988. # 'text': the heading text
  5989. # 'text_nonumber': the heading text without section number
  5990. # 'node': true if it is a node
  5991. # 'level': level of the element. 0 for @top, 1 for chapter, heading,
  5992. # appendix..., 2 for section and so on...
  5993. # 'tag_level': the sectioning element name, raisesections and lowersections
  5994. # taken into account
  5995. sub t2h_default_heading($$$$$;$$)
  5996. {
  5997. my $element = shift;
  5998. my $command = shift;
  5999. my $texi_line = shift;
  6000. my $line = shift;
  6001. my $in_preformatted = shift;
  6002. my $one_section = shift;
  6003. my $element_heading = shift;
  6004. my $level = $element->{'level'};
  6005. if ($element->{'node'})
  6006. {
  6007. if ($element->{'text'} =~ /^top$/i)
  6008. {
  6009. $level = 0;
  6010. }
  6011. else
  6012. {
  6013. $level = 3;
  6014. }
  6015. return '' if (!$element->{'this'} or $element->{'with_section'})
  6016. }
  6017. else
  6018. {
  6019. $command = $element->{'tag_level'};
  6020. }
  6021. my $text = $element->{'text'};
  6022. if (get_conf('TOC_LINKS') and $command !~ /heading/ and defined($element->{'tocid'}))
  6023. {
  6024. $text = &$anchor ('', "$Texi2HTML::THISDOC{'toc_file'}#$element->{'tocid'}", $text);
  6025. }
  6026. my $result;
  6027. if ($in_preformatted)
  6028. {
  6029. $result = &$heading_text_preformatted("\@$command", $text, $level);
  6030. }
  6031. else
  6032. {
  6033. $result = &$heading_text("\@$command", $text, $level);
  6034. }
  6035. #$result .= "\n";
  6036. return $result;
  6037. }
  6038. sub t2h_default_heading_no_texi($$$)
  6039. {
  6040. my $element = shift;
  6041. my $command = shift;
  6042. my $line = shift;
  6043. return main::remove_texi($line) . "\n";
  6044. }
  6045. # formatting of raw regions
  6046. # if L2H is true another mechanism is used for tex
  6047. sub t2h_default_raw($$;$)
  6048. {
  6049. my $style = shift;
  6050. my $text = shift;
  6051. my $line_nr = shift;
  6052. my $expanded = 1 if (grep {$style eq $_} @EXPAND);
  6053. if ($style eq 'verbatim' or $style eq 'verbatiminclude' or ($style eq 'tex' and $expanded))
  6054. {
  6055. return $text;
  6056. }
  6057. elsif ($expanded)
  6058. {
  6059. main::line_warn (sprintf(__("Raw format %s is not converted"), $style), $line_nr);
  6060. return $text;
  6061. }
  6062. else
  6063. {
  6064. return '';
  6065. }
  6066. }
  6067. # raw environment when removing texi (in comments)
  6068. sub t2h_default_raw_no_texi($$)
  6069. {
  6070. my $style = shift;
  6071. my $text = shift;
  6072. if ($style eq 'verbatim' or $style eq 'verbatiminclude' or grep {$style eq $_} @EXPAND)
  6073. {
  6074. return $text;
  6075. }
  6076. return '';
  6077. }
  6078. # This function formats a footnote reference and the footnote text associated
  6079. # with a given footnote.
  6080. # The footnote reference is the text appearing in the main document pointing
  6081. # to the footnote text.
  6082. #
  6083. # arguments:
  6084. # absolute number of the footnote (in the document)
  6085. # relative number of the footnote (in the page)
  6086. # identifier for the footnote
  6087. # identifier for the footnote reference in the main document
  6088. # main document file
  6089. # footnote text file
  6090. # array with the footnote text lines
  6091. # the state. See menu entry.
  6092. #
  6093. # returns:
  6094. # reference on an array containing the footnote text lines which should
  6095. # have been updated
  6096. # the text for the reference pointing on the footnote text
  6097. sub t2h_default_foot_line_and_ref($$$$$$$$$)
  6098. {
  6099. my $number_in_doc = shift;
  6100. my $number_in_page = shift;
  6101. my $footnote_id = shift;
  6102. my $place_id = shift;
  6103. my $document_file = shift;
  6104. my $footnote_file = shift;
  6105. my $lines = shift;
  6106. my $document_state = shift;
  6107. $number_in_doc = $NO_NUMBER_FOOTNOTE_SYMBOL if (!get_conf('NUMBER_FOOTNOTES'));
  6108. if ($document_file eq $footnote_file)
  6109. {
  6110. $document_file = $footnote_file = '';
  6111. }
  6112. unshift (@$lines, "($number_in_doc)\n");
  6113. push @$lines, "\n";
  6114. return ($lines, "($number_in_doc)");
  6115. }
  6116. # formats a group of footnotes.
  6117. #
  6118. # argument:
  6119. # array reference on the footnotes texts lines
  6120. #
  6121. # returns an array reference on the group of footnotes lines
  6122. sub t2h_default_foot_section($)
  6123. {
  6124. my $lines = shift;
  6125. my $header = &$heading_text('footnotes', gdt('Footnotes'), 3);
  6126. unshift (@$lines, "$header\n");
  6127. return $lines;
  6128. }
  6129. sub t2h_default_image_files($$$$)
  6130. {
  6131. my $base = shift;
  6132. my $extension = shift;
  6133. my $texi_base = shift;
  6134. my $texi_extension = shift;
  6135. my @files = ();
  6136. return @files if (!defined($base) or ($base eq ''));
  6137. if (defined($extension) and ($extension ne ''))
  6138. {
  6139. push @files,["$base.$extension", "$texi_base.$texi_extension"];
  6140. }
  6141. foreach my $ext (@IMAGE_EXTENSIONS)
  6142. {
  6143. push @files,["$base.$ext", "$texi_base.$ext"];
  6144. }
  6145. return @files;
  6146. }
  6147. # format an image
  6148. #
  6149. # arguments:
  6150. # image file name with path
  6151. # image basename
  6152. # a boolean true if we are in a preformatted format
  6153. # image file name without path
  6154. # alt text
  6155. # width
  6156. # height
  6157. # raw alt
  6158. # extension
  6159. # path to working dir
  6160. # path to file relative from working dir
  6161. sub t2h_default_image($$$$$$$$$$$$$$$$$)
  6162. {
  6163. my $file = shift;
  6164. my $base = shift;
  6165. my $preformatted = shift;
  6166. my $file_name = shift;
  6167. my $alt = shift;
  6168. my $width = shift;
  6169. my $height = shift;
  6170. my $raw_alt = shift;
  6171. my $extension = shift;
  6172. my $working_dir = shift;
  6173. my $file_path = shift;
  6174. my $in_paragraph = shift;
  6175. my $file_locations = shift;
  6176. my $base_simple_format = shift;
  6177. my $extension_simple_format = shift;
  6178. my $file_name_simple_format = shift;
  6179. my $line_nr = shift;
  6180. if (!defined($file_path) or $file_path eq '')
  6181. {
  6182. if (defined($extension) and $extension ne '')
  6183. {
  6184. $file = "$base.$extension";
  6185. }
  6186. else
  6187. {
  6188. $file = "$base.txt";
  6189. }
  6190. }
  6191. elsif (! get_conf('COMPLETE_IMAGE_PATHS'))
  6192. {
  6193. $file = $file_name;
  6194. }
  6195. my $alt_txt = '';
  6196. $alt_txt = ": $alt" if (defined($alt) and $alt =~ /\S/);
  6197. return "[ $file$alt_txt ]";
  6198. # it is possible that $file_name is more correct as it allows the user
  6199. # to chose the relative path.
  6200. }
  6201. # address put in footer describing when was generated and who did the manual
  6202. # not used anymore
  6203. sub t2h_default_address($)
  6204. {
  6205. my $date = shift;
  6206. $date = '' if (!defined($date));
  6207. if ($date ne '')
  6208. {
  6209. return gdt('on @emph{{date}}', { 'date' => $date });
  6210. }
  6211. return '';
  6212. }
  6213. # format a target in the main document for an index entry.
  6214. #
  6215. # arguments:
  6216. # target identifier
  6217. # boolean true if in preformatted format
  6218. sub t2h_default_index_entry_label($$$$$$$$$)
  6219. {
  6220. my $identifier = shift;
  6221. my $preformatted = shift;
  6222. my $entry = shift;
  6223. my $index_name = shift;
  6224. my $index_command = shift;
  6225. my $texi_entry = shift;
  6226. my $formatted_entry = shift;
  6227. my $in_region_not_in_output = shift;
  6228. my $index_entry_ref = shift;
  6229. return '' if (!defined($identifier) or ($identifier !~ /\S/));
  6230. my $label = &$anchor($identifier);
  6231. return $label;
  6232. }
  6233. sub t2h_default_index_entry_command($$$$$$)
  6234. {
  6235. my $command = shift;
  6236. my $index_name = shift;
  6237. my $label = shift;
  6238. my $entry_texi = shift;
  6239. my $entry_formatted = shift;
  6240. my $index_entry_ref = shift;
  6241. return $label;
  6242. }
  6243. # process definition commands line @deffn for example
  6244. sub t2h_default_def_line($$$$$$$$$$$$$$$$)
  6245. {
  6246. my $category_prepared = shift;
  6247. my $name = shift;
  6248. my $type = shift;
  6249. my $arguments = shift;
  6250. my $index_label = shift;
  6251. my $arguments_array = shift;
  6252. my $arguments_type_array = shift;
  6253. my $unformatted_arguments_array = shift;
  6254. my $command = shift;
  6255. my $class_name = shift;
  6256. my $category = shift;
  6257. my $class = shift;
  6258. my $style = shift;
  6259. my $original_command = shift;
  6260. $name = '' if (!defined($name) or ($name =~ /^\s*$/));
  6261. $type = '' if (!defined($type) or $type =~ /^\s*$/);
  6262. $arguments = '' if (!defined($arguments) or $arguments =~ /^\s*$/);
  6263. my $type_name = '';
  6264. $type_name .= "$type " if ($type ne '');
  6265. $type_name .= $name if ($name ne '');
  6266. my $result = " -- $category_prepared: ${type_name}$arguments";
  6267. $result =~ s/\s*$//;
  6268. $result .= "\n";
  6269. }
  6270. # process definition commands line @deffn for example while removing texi
  6271. # commands
  6272. sub t2h_default_def_line_no_texi($$$$$)
  6273. {
  6274. my $category = shift;
  6275. my $name = shift;
  6276. my $type = shift;
  6277. my $arguments = shift;
  6278. $name = '' if (!defined($name) or ($name =~ /^\s*$/));
  6279. $type = '' if (!defined($type) or $type =~ /^\s*$/);
  6280. if (!defined($arguments) or $arguments =~ /^\s*$/)
  6281. {
  6282. $arguments = '';
  6283. }
  6284. my $type_name = '';
  6285. $type_name = " $type" if ($type ne '');
  6286. $type_name .= ' ' . $name if ($name ne '');
  6287. $type_name .= $arguments;
  6288. if (! get_conf('DEF_TABLE'))
  6289. {
  6290. return $category . ':' . $type_name . "\n";
  6291. }
  6292. else
  6293. {
  6294. return $type_name . " " . $category . "\n";
  6295. }
  6296. }
  6297. # a cartouche
  6298. sub t2h_default_cartouche($$)
  6299. {
  6300. my $text = shift;
  6301. if ($text =~ /\S/)
  6302. {
  6303. return $text;
  6304. }
  6305. return '';
  6306. }
  6307. my $IDXFILE;
  6308. # key:
  6309. # origin_href:
  6310. # entry:
  6311. # texi entry:
  6312. # element_href:
  6313. # element_text:
  6314. sub t2h_default_index_summary_file_entry ($$$$$$$$$)
  6315. {
  6316. my $index_name = shift;
  6317. my $key = shift;
  6318. my $origin_href = shift;
  6319. my $entry = shift;
  6320. my $texi_entry = shift;
  6321. my $element_href = shift;
  6322. my $element_text = shift;
  6323. my $is_printed = shift;
  6324. my $manual_name = shift;
  6325. $element_text = 'UNDEF' if (!defined($element_text));
  6326. print $IDXFILE "key: $key\n origin_href: $origin_href\n entry: $entry\n"
  6327. . " texi_entry: $texi_entry\n"
  6328. . " element_href: $element_href\n element_text: $element_text\n";
  6329. }
  6330. sub t2h_default_index_summary_file_begin($$$)
  6331. {
  6332. my $name = shift;
  6333. my $is_printed = shift;
  6334. my $manual_name = shift;
  6335. $IDXFILE = main::open_out("$Texi2HTML::THISDOC{'destination_directory'}$Texi2HTML::THISDOC{'file_base_name'}" . "_$name.idx");
  6336. }
  6337. sub t2h_default_index_summary_file_end($$$)
  6338. {
  6339. my $name = shift;
  6340. my $is_printed = shift;
  6341. my $manual_name = shift;
  6342. close ($IDXFILE);
  6343. }
  6344. sub t2h_default_sp($$)
  6345. {
  6346. my $number = shift;
  6347. my $preformatted = shift;
  6348. return "\n" x $number;
  6349. }
  6350. sub t2h_default_acronym_like($$$$$$)
  6351. {
  6352. my $command = shift;
  6353. my $acronym_texi = shift;
  6354. my $acronym_text = shift;
  6355. my $with_explanation = shift;
  6356. my $explanation_lines = shift;
  6357. my $explanation_text = shift;
  6358. my $explanation_simply_formatted = shift;
  6359. if ($with_explanation)
  6360. {
  6361. #return "$acronym_text ($explanation_text)";
  6362. return gdt('{acronym_like} ({explanation})', {'acronym_like' => $acronym_text, 'explanation' => $explanation_text},{'duplicate'=>1});
  6363. }
  6364. else
  6365. {
  6366. return "$acronym_text";
  6367. }
  6368. }
  6369. sub t2h_default_quotation_prepend_text($$)
  6370. {
  6371. my $command = shift;
  6372. my $text = shift;
  6373. return undef if (!defined($text) or $text =~ /^$/);
  6374. # If there is a @ protecting the end of line the result is,
  6375. # after the chomp:
  6376. # @b{some text @:}
  6377. # It is likely not to be what was intended, but it is certainly right.
  6378. # this is tested in formatting/quotation.texi
  6379. chomp($text);
  6380. return gdt('@b{{quotation_arg}:} ', {'quotation_arg' => $text}, {'keep_texi' => 1});
  6381. }
  6382. sub t2h_default_quotation($$$$$)
  6383. {
  6384. my $command = shift;
  6385. my $text = shift;
  6386. my $argument_text = shift;
  6387. my $argument_text_texi = shift;
  6388. my $authors = shift;
  6389. my $class_text = '';
  6390. # this allows to add an end of line if there was none, which can happen
  6391. # if there is an argument to @quotation, but an empty quotation, like
  6392. # @quotation something
  6393. # @end quotation
  6394. chomp($text);
  6395. $text .= "\n";
  6396. return $text;
  6397. }
  6398. # format the text within a paragraph style format,
  6399. #
  6400. # argument:
  6401. # format name
  6402. # text within the format
  6403. sub t2h_default_paragraph_style_command($$)
  6404. {
  6405. my $format = shift;
  6406. my $text = shift;
  6407. return $text;
  6408. }
  6409. # format a whole index
  6410. #
  6411. # argument:
  6412. # index text
  6413. # index name
  6414. sub t2h_default_print_index($$)
  6415. {
  6416. my $text = shift;
  6417. my $name = shift;
  6418. return '' if (!defined($text));
  6419. return "* Index:\n" . $text;
  6420. }
  6421. # format a letter entry in an index page. The letter entry contains
  6422. # the index entries for the words beginning with that letter. It is
  6423. # a target for links pointing from the summary of the index.
  6424. #
  6425. # arguments:
  6426. # the letter
  6427. # identifier for the letter entry. This should be used to make the target
  6428. # identifier
  6429. # text of the index entries
  6430. sub t2h_default_index_letter($$$)
  6431. {
  6432. my $letter = shift;
  6433. my $id = shift;
  6434. my $text = shift;
  6435. return $text;
  6436. }
  6437. # format an index entry (in a letter entry).
  6438. #
  6439. # arguments:
  6440. # href to the main text, linking to the place where the index entry appears
  6441. # entry text
  6442. # href to the main text, linking to the section or node where the index
  6443. # entry appears
  6444. # section or node heading
  6445. sub t2h_default_index_entry($$$$$$$$$$)
  6446. {
  6447. my $text_href = shift;
  6448. my $entry = shift;
  6449. my $element_href = shift;
  6450. my $element_text = shift;
  6451. my $entry_file = shift;
  6452. my $current_element_file = shift;
  6453. my $entry_target = shift;
  6454. my $entry_element_target = shift;
  6455. my $in_region_not_in_output = shift;
  6456. my $index_entry_ref = shift;
  6457. return '' if ($in_region_not_in_output);
  6458. #!$index_entry_ref->{'seen_in_output'} and defined($index_entry_ref->{'region'}));
  6459. my $state = {};
  6460. $state = { 'code_style' => 1 } if ($index_entry_ref->{'in_code'});
  6461. $entry = main::substitute_line($index_entry_ref->{'texi'}, "index entry in \@printindex", $state);
  6462. return '' if ($entry =~ /^\s*$/);
  6463. my $real_element_text;
  6464. my $element = $index_entry_ref->{'real_element'};
  6465. # in case $element->{'text'} is not defined, it certainly means that we
  6466. # are n a special elemet, most likely the virtual element appearing
  6467. # before anything else
  6468. if (defined($element->{'text'}))
  6469. {
  6470. my $element_set = 0;
  6471. if (get_conf('NODE_NAME_IN_INDEX'))
  6472. {
  6473. if ($element->{'node'})
  6474. {
  6475. $element_set = 1;
  6476. }
  6477. elsif ($element->{'with_node'})
  6478. {
  6479. $element = $element->{'with_node'};
  6480. $element_set = 1;
  6481. }
  6482. }
  6483. elsif (defined(get_conf('NODE_NAME_IN_INDEX')))
  6484. {
  6485. if (!$element->{'node'})
  6486. {
  6487. $element_set = 1;
  6488. }
  6489. elsif ($element->{'with_section'})
  6490. {
  6491. $element = $element->{'with_section'};
  6492. $element_set = 1;
  6493. }
  6494. }
  6495. $element = $element->{'element_ref'} if ($element->{'element_ref'} and !$element_set);
  6496. $real_element_text = $element->{'text'};
  6497. }
  6498. else
  6499. {
  6500. $real_element_text = gdt('(outside of any element)');
  6501. }
  6502. return "* $entry: ".$real_element_text . '.'."\n";
  6503. }
  6504. sub t2h_default_copying_comment($$$$)
  6505. {
  6506. my $copying_lines = shift;
  6507. my $copying_text = shift;
  6508. my $copying_no_texi = shift;
  6509. my $copying_simple_text = shift;
  6510. return '' if ($copying_no_texi eq '');
  6511. my $text = &$comment($copying_no_texi);
  6512. return $text;
  6513. }
  6514. # return value is currently ignored
  6515. sub t2h_default_documentdescription($$$$)
  6516. {
  6517. my $decription_lines = shift;
  6518. my $description_text = shift;
  6519. my $description_no_texi = shift;
  6520. my $description_simple_text = shift;
  6521. #return '' if ($description_no_texi eq '');
  6522. #my @documentdescription = split (/\n/, $description_no_texi);
  6523. if ($description_simple_text eq '')
  6524. {
  6525. set_from_document('documentdescription', undef);
  6526. return;
  6527. }
  6528. my @documentdescription = split (/\n/, $description_simple_text);
  6529. my $document_description = shift @documentdescription;
  6530. chomp $document_description;
  6531. foreach my $line (@documentdescription)
  6532. {
  6533. chomp $line;
  6534. $document_description .= ' ' . $line;
  6535. }
  6536. set_from_document('documentdescription', $document_description);
  6537. }
  6538. # format an index summary. This is a list of letters linking to the letter
  6539. # entries.
  6540. #
  6541. # arguments:
  6542. # array reference containing the formatted alphabetical letters
  6543. # array reference containing the formatted non lphabetical letters
  6544. sub t2h_default_index_summary($$)
  6545. {
  6546. my $alpha = shift;
  6547. my $nonalpha = shift;
  6548. my $join = '';
  6549. my $nonalpha_text = '';
  6550. my $alpha_text = '';
  6551. return '';
  6552. }
  6553. # return the heading with number texinfo text
  6554. # also called for nodes.
  6555. sub t2h_default_heading_texi($$$)
  6556. {
  6557. my $tag = shift;
  6558. my $texi = shift;
  6559. my $number = shift;
  6560. #$texi = main::trim_around_spaces($texi);
  6561. return "$number $texi" if (get_conf('NUMBER_SECTIONS') and defined($number) and ($number !~ /^\s*$/)) ;
  6562. return $texi;
  6563. }
  6564. # return the heading texinfo text for split index sections
  6565. sub t2h_default_index_element_heading_texi($$$)
  6566. { # FIXME i18n
  6567. my $heading_texi = shift;
  6568. my $tag = shift;
  6569. my $texi = shift;
  6570. my $number = shift;
  6571. my $first_letter = shift;
  6572. my $last_letter = shift;
  6573. return "$heading_texi: $first_letter -- $last_letter" if ($last_letter ne $first_letter);
  6574. return "$heading_texi: $first_letter";
  6575. }
  6576. sub t2h_default_element_label($$$$)
  6577. {
  6578. my $id = shift;
  6579. my $element = shift;
  6580. my $command = shift;
  6581. my $line = shift;
  6582. return &$anchor($id);
  6583. }
  6584. sub t2h_default_misc_element_label($$)
  6585. {
  6586. my $id = shift;
  6587. my $misc_page_name = shift;
  6588. return &$anchor($id);
  6589. }
  6590. sub t2h_default_anchor_label($$$$)
  6591. {
  6592. my $id = shift;
  6593. my $anchor_text = shift;
  6594. my $anchor_reference = shift;
  6595. my $in_special_region = shift;
  6596. return &$anchor($id);
  6597. }
  6598. sub t2h_default_colon_command($)
  6599. {
  6600. my $punctuation_character = shift;
  6601. return $colon_command_punctuation_characters{$punctuation_character} if defined($colon_command_punctuation_characters{$punctuation_character});
  6602. return $punctuation_character;
  6603. }
  6604. # called each time a @tab or an @itemx is encountered.
  6605. # To be noticed that there is another function better suited for
  6606. # formatting of an @item line: $format_list_item_texi
  6607. sub t2h_default_tab_item_texi($$$$$$)
  6608. {
  6609. my $command = shift;
  6610. my $commands_stack = shift;
  6611. my $stack = shift;
  6612. my $state = shift;
  6613. my $line = shift;
  6614. my $line_nr = shift;
  6615. return undef;
  6616. }
  6617. sub xml_default_line_command($$$$)
  6618. {
  6619. my $command = shift;
  6620. my $arg_text = shift;
  6621. my $arg_texi = shift;
  6622. my $state = shift;
  6623. my $style = $line_command_map{$command};
  6624. return '' if ($arg_text eq '' and !defined($style) or $style eq '');
  6625. if ($style)
  6626. {
  6627. my $attribute_text = '';
  6628. if ($style =~ /^(\w+)(\s+.*)/)
  6629. {
  6630. $style = $1;
  6631. $attribute_text = $2;
  6632. }
  6633. $arg_text = "<${style}$attribute_text>$arg_text</$style>";
  6634. }
  6635. $arg_text .= "\n";
  6636. return $arg_text;
  6637. }
  6638. sub t2h_default_line_command($$$$)
  6639. {
  6640. my $command = shift;
  6641. my $arg_text = shift;
  6642. my $arg_texi = shift;
  6643. my $state = shift;
  6644. return $arg_text;
  6645. }
  6646. # info is special, since it doesn't use the basename but directly the
  6647. # setfilename output, contrary to all the other formats
  6648. sub t2h_default_element_file_name($$$)
  6649. {
  6650. my $element = shift;
  6651. my $type = shift;
  6652. my $prefix = shift;
  6653. my $outname;
  6654. return unless (get_conf('USE_SETFILENAME_EXTENSION') and get_conf('PREFIX') eq '');
  6655. my $outfile = get_conf('OUTFILE');
  6656. $outname = $outfile if (defined($outfile) and $outfile ne '' and $Texi2HTML::THISDOC{'input_file_number'} == 0);
  6657. if ($type eq 'doc' or !get_conf('SPLIT'))
  6658. {
  6659. if (defined(get_conf('setfilename')) and !defined($outname))
  6660. {
  6661. main::document_override('EXTENSION', '');
  6662. return get_conf('setfilename');
  6663. }
  6664. }
  6665. return undef;
  6666. }
  6667. sub t2h_default_misc_command_line($$$$$)
  6668. {
  6669. my $macro = shift;
  6670. my $line = shift;
  6671. my $args = shift;
  6672. my $stack = shift;
  6673. my $state = shift;
  6674. my $result;
  6675. return ($macro, $line, $result);
  6676. }
  6677. sub t2h_default_internal_links($$$)
  6678. {
  6679. my $fh = shift;
  6680. my $elements_list = shift;
  6681. my $indices = shift;
  6682. foreach my $element (@$elements_list)
  6683. {
  6684. my $text = $element->{'no_texi'};
  6685. #$text =~ s/^([\w.]+)\. /$1 /;
  6686. #$text = "Annexe ".$text if ($element->{'tag'} =~ /appendix/);
  6687. print $fh "$element->{'file'}#$element->{'id'}\ttoc\t$text\n";
  6688. }
  6689. foreach my $index_name (sort(keys(%$indices)))
  6690. {
  6691. my $entries = $indices->{$index_name};
  6692. foreach my $letter_entries (@$entries)
  6693. {
  6694. foreach my $entry (@{$letter_entries->{'entries'}})
  6695. {
  6696. #print STDERR "($index_name) key $key, t $entry->{'texi'}: $entry->{'file'}#$entry->{'target'}\n";
  6697. print $fh "$entry->{'file'}#$entry->{'target'}\t$index_name\t$entry->{'key'}\n" if ($entry->{'key'} =~ /\S/);
  6698. }
  6699. }
  6700. }
  6701. }
  6702. 1;