1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648 |
- (eval-when-compile (require 'cl))
- (require 'org-element)
- (declare-function org-e-ascii-export-as-ascii "org-e-ascii"
- (&optional subtreep visible-only body-only ext-plist))
- (declare-function org-e-ascii-export-to-ascii "org-e-ascii"
- (&optional subtreep visible-only body-only ext-plist pub-dir))
- (declare-function org-e-html-export-as-html "org-e-html"
- (&optional subtreep visible-only body-only ext-plist))
- (declare-function org-e-html-export-to-html "org-e-html"
- (&optional subtreep visible-only body-only ext-plist pub-dir))
- (declare-function org-e-latex-export-as-latex "org-e-latex"
- (&optional subtreep visible-only body-only ext-plist))
- (declare-function org-e-latex-export-to-latex "org-e-latex"
- (&optional subtreep visible-only body-only ext-plist pub-dir))
- (declare-function org-e-latex-export-to-pdf "org-e-latex"
- (&optional subtreep visible-only body-only ext-plist pub-dir))
- (declare-function org-e-odt-export-to-odt "org-e-odt"
- (&optional subtreep visible-only body-only ext-plist pub-dir))
- (declare-function org-e-publish "org-e-publish" (project &optional force))
- (declare-function org-e-publish-all "org-e-publish" (&optional force))
- (declare-function org-e-publish-current-file "org-e-publish" (&optional force))
- (declare-function org-e-publish-current-project "org-e-publish"
- (&optional force))
- (declare-function org-export-blocks-preprocess "org-exp-blocks")
- (defvar org-e-publish-project-alist)
- (defvar org-table-number-fraction)
- (defvar org-table-number-regexp)
- (defconst org-export-max-depth 19
- "Maximum nesting depth for headlines, counting from 0.")
- (defconst org-export-options-alist
- '((:author "AUTHOR" nil user-full-name t)
- (:creator "CREATOR" nil org-export-creator-string)
- (:date "DATE" nil nil t)
- (:description "DESCRIPTION" nil nil newline)
- (:email "EMAIL" nil user-mail-address t)
- (:exclude-tags "EXCLUDE_TAGS" nil org-export-exclude-tags split)
- (:headline-levels nil "H" org-export-headline-levels)
- (:keywords "KEYWORDS" nil nil space)
- (:language "LANGUAGE" nil org-export-default-language t)
- (:preserve-breaks nil "\\n" org-export-preserve-breaks)
- (:section-numbers nil "num" org-export-with-section-numbers)
- (:select-tags "SELECT_TAGS" nil org-export-select-tags split)
- (:time-stamp-file nil "timestamp" org-export-time-stamp-file)
- (:title "TITLE" nil nil space)
- (:with-archived-trees nil "arch" org-export-with-archived-trees)
- (:with-author nil "author" org-export-with-author)
- (:with-clocks nil "c" org-export-with-clocks)
- (:with-creator nil "creator" org-export-with-creator)
- (:with-drawers nil "d" org-export-with-drawers)
- (:with-email nil "email" org-export-with-email)
- (:with-emphasize nil "*" org-export-with-emphasize)
- (:with-entities nil "e" org-export-with-entities)
- (:with-fixed-width nil ":" org-export-with-fixed-width)
- (:with-footnotes nil "f" org-export-with-footnotes)
- (:with-inlinetasks nil "inline" org-export-with-inlinetasks)
- (:with-plannings nil "p" org-export-with-planning)
- (:with-priority nil "pri" org-export-with-priority)
- (:with-special-strings nil "-" org-export-with-special-strings)
- (:with-statistics-cookies nil "stat" org-export-with-statistics-cookies)
- (:with-sub-superscript nil "^" org-export-with-sub-superscripts)
- (:with-toc nil "toc" org-export-with-toc)
- (:with-tables nil "|" org-export-with-tables)
- (:with-tags nil "tags" org-export-with-tags)
- (:with-tasks nil "tasks" org-export-with-tasks)
- (:with-timestamps nil "<" org-export-with-timestamps)
- (:with-todo-keywords nil "todo" org-export-with-todo-keywords))
- "Alist between export properties and ways to set them.
- The CAR of the alist is the property name, and the CDR is a list
- like (KEYWORD OPTION DEFAULT BEHAVIOUR) where:
- KEYWORD is a string representing a buffer keyword, or nil. Each
- property defined this way can also be set, during subtree
- export, through an headline property named after the keyword
- with the \"EXPORT_\" prefix (i.e. DATE keyword and EXPORT_DATE
- property).
- OPTION is a string that could be found in an #+OPTIONS: line.
- DEFAULT is the default value for the property.
- BEHAVIOUR determine how Org should handle multiple keywords for
- the same property. It is a symbol among:
- nil Keep old value and discard the new one.
- t Replace old value with the new one.
- `space' Concatenate the values, separating them with a space.
- `newline' Concatenate the values, separating them with
- a newline.
- `split' Split values at white spaces, and cons them to the
- previous list.
- KEYWORD and OPTION have precedence over DEFAULT.
- All these properties should be back-end agnostic. Back-end
- specific properties are set through `org-export-define-backend'.
- Properties redefined there have precedence over these.")
- (defconst org-export-special-keywords '("SETUP_FILE" "OPTIONS")
- "List of in-buffer keywords that require special treatment.
- These keywords are not directly associated to a property. The
- way they are handled must be hard-coded into
- `org-export--get-inbuffer-options' function.")
- (defconst org-export-filters-alist
- '((:filter-bold . org-export-filter-bold-functions)
- (:filter-babel-call . org-export-filter-babel-call-functions)
- (:filter-center-block . org-export-filter-center-block-functions)
- (:filter-clock . org-export-filter-clock-functions)
- (:filter-code . org-export-filter-code-functions)
- (:filter-comment . org-export-filter-comment-functions)
- (:filter-comment-block . org-export-filter-comment-block-functions)
- (:filter-drawer . org-export-filter-drawer-functions)
- (:filter-dynamic-block . org-export-filter-dynamic-block-functions)
- (:filter-entity . org-export-filter-entity-functions)
- (:filter-example-block . org-export-filter-example-block-functions)
- (:filter-export-block . org-export-filter-export-block-functions)
- (:filter-export-snippet . org-export-filter-export-snippet-functions)
- (:filter-final-output . org-export-filter-final-output-functions)
- (:filter-fixed-width . org-export-filter-fixed-width-functions)
- (:filter-footnote-definition . org-export-filter-footnote-definition-functions)
- (:filter-footnote-reference . org-export-filter-footnote-reference-functions)
- (:filter-headline . org-export-filter-headline-functions)
- (:filter-horizontal-rule . org-export-filter-horizontal-rule-functions)
- (:filter-inline-babel-call . org-export-filter-inline-babel-call-functions)
- (:filter-inline-src-block . org-export-filter-inline-src-block-functions)
- (:filter-inlinetask . org-export-filter-inlinetask-functions)
- (:filter-italic . org-export-filter-italic-functions)
- (:filter-item . org-export-filter-item-functions)
- (:filter-keyword . org-export-filter-keyword-functions)
- (:filter-latex-environment . org-export-filter-latex-environment-functions)
- (:filter-latex-fragment . org-export-filter-latex-fragment-functions)
- (:filter-line-break . org-export-filter-line-break-functions)
- (:filter-link . org-export-filter-link-functions)
- (:filter-macro . org-export-filter-macro-functions)
- (:filter-node-property . org-export-filter-node-property-functions)
- (:filter-paragraph . org-export-filter-paragraph-functions)
- (:filter-parse-tree . org-export-filter-parse-tree-functions)
- (:filter-plain-list . org-export-filter-plain-list-functions)
- (:filter-plain-text . org-export-filter-plain-text-functions)
- (:filter-planning . org-export-filter-planning-functions)
- (:filter-property-drawer . org-export-filter-property-drawer-functions)
- (:filter-quote-block . org-export-filter-quote-block-functions)
- (:filter-quote-section . org-export-filter-quote-section-functions)
- (:filter-radio-target . org-export-filter-radio-target-functions)
- (:filter-section . org-export-filter-section-functions)
- (:filter-special-block . org-export-filter-special-block-functions)
- (:filter-src-block . org-export-filter-src-block-functions)
- (:filter-statistics-cookie . org-export-filter-statistics-cookie-functions)
- (:filter-strike-through . org-export-filter-strike-through-functions)
- (:filter-subscript . org-export-filter-subscript-functions)
- (:filter-superscript . org-export-filter-superscript-functions)
- (:filter-table . org-export-filter-table-functions)
- (:filter-table-cell . org-export-filter-table-cell-functions)
- (:filter-table-row . org-export-filter-table-row-functions)
- (:filter-target . org-export-filter-target-functions)
- (:filter-timestamp . org-export-filter-timestamp-functions)
- (:filter-underline . org-export-filter-underline-functions)
- (:filter-verbatim . org-export-filter-verbatim-functions)
- (:filter-verse-block . org-export-filter-verse-block-functions))
- "Alist between filters properties and initial values.
- The key of each association is a property name accessible through
- the communication channel. Its value is a configurable global
- variable defining initial filters.
- This list is meant to install user specified filters. Back-end
- developers may install their own filters using
- `org-export-define-backend'. Filters defined there will always
- be prepended to the current list, so they always get applied
- first.")
- (defconst org-export-default-inline-image-rule
- `(("file" .
- ,(format "\\.%s\\'"
- (regexp-opt
- '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
- "xpm" "pbm" "pgm" "ppm") t))))
- "Default rule for link matching an inline image.
- This rule applies to links with no description. By default, it
- will be considered as an inline image if it targets a local file
- whose extension is either \"png\", \"jpeg\", \"jpg\", \"gif\",
- \"tiff\", \"tif\", \"xbm\", \"xpm\", \"pbm\", \"pgm\" or \"ppm\".
- See `org-export-inline-image-p' for more information about
- rules.")
- (defgroup org-export nil
- "Options for exporting Org mode files."
- :tag "Org Export"
- :group 'org)
- (defgroup org-export-general nil
- "General options for export engine."
- :tag "Org Export General"
- :group 'org-export)
- (defcustom org-export-with-archived-trees 'headline
- "Whether sub-trees with the ARCHIVE tag should be exported.
- This can have three different values:
- nil Do not export, pretend this tree is not present.
- t Do export the entire tree.
- `headline' Only export the headline, but skip the tree below it.
- This option can also be set with the #+OPTIONS line,
- e.g. \"arch:nil\"."
- :group 'org-export-general
- :type '(choice
- (const :tag "Not at all" nil)
- (const :tag "Headline only" 'headline)
- (const :tag "Entirely" t)))
- (defcustom org-export-with-author t
- "Non-nil means insert author name into the exported file.
- This option can also be set with the #+OPTIONS line,
- e.g. \"author:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-clocks nil
- "Non-nil means export CLOCK keywords.
- This option can also be set with the #+OPTIONS line,
- e.g. \"c:t\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-creator 'comment
- "Non-nil means the postamble should contain a creator sentence.
- The sentence can be set in `org-export-creator-string' and
- defaults to \"Generated by Org mode XX in Emacs XXX.\".
- If the value is `comment' insert it as a comment."
- :group 'org-export-general
- :type '(choice
- (const :tag "No creator sentence" nil)
- (const :tag "Sentence as a comment" 'comment)
- (const :tag "Insert the sentence" t)))
- (defcustom org-export-creator-string
- (format "Generated by Org mode %s in Emacs %s."
- (if (fboundp 'org-version) (org-version) "(Unknown)")
- emacs-version)
- "String to insert at the end of the generated document."
- :group 'org-export-general
- :type '(string :tag "Creator string"))
- (defcustom org-export-with-drawers t
- "Non-nil means export contents of standard drawers.
- When t, all drawers are exported. This may also be a list of
- drawer names to export. This variable doesn't apply to
- properties drawers.
- This option can also be set with the #+OPTIONS line,
- e.g. \"d:nil\"."
- :group 'org-export-general
- :type '(choice
- (const :tag "All drawers" t)
- (const :tag "None" nil)
- (repeat :tag "Selected drawers"
- (string :tag "Drawer name"))))
- (defcustom org-export-with-email nil
- "Non-nil means insert author email into the exported file.
- This option can also be set with the #+OPTIONS line,
- e.g. \"email:t\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-emphasize t
- "Non-nil means interpret *word*, /word/, and _word_ as emphasized text.
- If the export target supports emphasizing text, the word will be
- typeset in bold, italic, or underlined, respectively. Not all
- export backends support this.
- This option can also be set with the #+OPTIONS line, e.g. \"*:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-exclude-tags '("noexport")
- "Tags that exclude a tree from export.
- All trees carrying any of these tags will be excluded from
- export. This is without condition, so even subtrees inside that
- carry one of the `org-export-select-tags' will be removed.
- This option can also be set with the #+EXCLUDE_TAGS: keyword."
- :group 'org-export-general
- :type '(repeat (string :tag "Tag")))
- (defcustom org-export-with-fixed-width t
- "Non-nil means lines starting with \":\" will be in fixed width font.
- This can be used to have pre-formatted text, fragments of code
- etc. For example:
- : ;; Some Lisp examples
- : (while (defc cnt)
- : (ding))
- will be looking just like this in also HTML. See also the QUOTE
- keyword. Not all export backends support this.
- This option can also be set with the #+OPTIONS line, e.g. \"::nil\"."
- :group 'org-export-translation
- :type 'boolean)
- (defcustom org-export-with-footnotes t
- "Non-nil means Org footnotes should be exported.
- This option can also be set with the #+OPTIONS line,
- e.g. \"f:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-headline-levels 3
- "The last level which is still exported as a headline.
- Inferior levels will produce itemize lists when exported.
- This option can also be set with the #+OPTIONS line, e.g. \"H:2\"."
- :group 'org-export-general
- :type 'integer)
- (defcustom org-export-default-language "en"
- "The default language for export and clocktable translations, as a string.
- This may have an association in
- `org-clock-clocktable-language-setup'."
- :group 'org-export-general
- :type '(string :tag "Language"))
- (defcustom org-export-preserve-breaks nil
- "Non-nil means preserve all line breaks when exporting.
- Normally, in HTML output paragraphs will be reformatted.
- This option can also be set with the #+OPTIONS line,
- e.g. \"\\n:t\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-entities t
- "Non-nil means interpret entities when exporting.
- For example, HTML export converts \\alpha to α and \\AA to
- Å.
- For a list of supported names, see the constant `org-entities'
- and the user option `org-entities-user'.
- This option can also be set with the #+OPTIONS line,
- e.g. \"e:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-inlinetasks t
- "Non-nil means inlinetasks should be exported.
- This option can also be set with the #+OPTIONS line,
- e.g. \"inline:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-planning nil
- "Non-nil means include planning info in export.
- This option can also be set with the #+OPTIONS: line,
- e.g. \"p:t\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-priority nil
- "Non-nil means include priority cookies in export.
- This option can also be set with the #+OPTIONS line,
- e.g. \"pri:t\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-section-numbers t
- "Non-nil means add section numbers to headlines when exporting.
- When set to an integer n, numbering will only happen for
- headlines whose relative level is higher or equal to n.
- This option can also be set with the #+OPTIONS line,
- e.g. \"num:t\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-select-tags '("export")
- "Tags that select a tree for export.
- If any such tag is found in a buffer, all trees that do not carry
- one of these tags will be ignored during export. Inside trees
- that are selected like this, you can still deselect a subtree by
- tagging it with one of the `org-export-exclude-tags'.
- This option can also be set with the #+SELECT_TAGS: keyword."
- :group 'org-export-general
- :type '(repeat (string :tag "Tag")))
- (defcustom org-export-with-special-strings t
- "Non-nil means interpret \"\\-\", \"--\" and \"---\" for export.
- When this option is turned on, these strings will be exported as:
- Org HTML LaTeX UTF-8
- -----+----------+--------+-------
- \\- ­ \\-
- -- – -- –
- --- — --- —
- ... … \\ldots …
- This option can also be set with the #+OPTIONS line,
- e.g. \"-:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-statistics-cookies t
- "Non-nil means include statistics cookies in export.
- This option can also be set with the #+OPTIONS: line,
- e.g. \"stat:nil\""
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-sub-superscripts t
- "Non-nil means interpret \"_\" and \"^\" for export.
- When this option is turned on, you can use TeX-like syntax for
- sub- and superscripts. Several characters after \"_\" or \"^\"
- will be considered as a single item - so grouping with {} is
- normally not needed. For example, the following things will be
- parsed as single sub- or superscripts.
- 10^24 or 10^tau several digits will be considered 1 item.
- 10^-12 or 10^-tau a leading sign with digits or a word
- x^2-y^3 will be read as x^2 - y^3, because items are
- terminated by almost any nonword/nondigit char.
- x_{i^2} or x^(2-i) braces or parenthesis do grouping.
- Still, ambiguity is possible - so when in doubt use {} to enclose
- the sub/superscript. If you set this variable to the symbol
- `{}', the braces are *required* in order to trigger
- interpretations as sub/superscript. This can be helpful in
- documents that need \"_\" frequently in plain text.
- This option can also be set with the #+OPTIONS line,
- e.g. \"^:nil\"."
- :group 'org-export-general
- :type '(choice
- (const :tag "Interpret them" t)
- (const :tag "Curly brackets only" {})
- (const :tag "Do not interpret them" nil)))
- (defcustom org-export-with-toc t
- "Non-nil means create a table of contents in exported files.
- The TOC contains headlines with levels up
- to`org-export-headline-levels'. When an integer, include levels
- up to N in the toc, this may then be different from
- `org-export-headline-levels', but it will not be allowed to be
- larger than the number of headline levels. When nil, no table of
- contents is made.
- This option can also be set with the #+OPTIONS line,
- e.g. \"toc:nil\" or \"toc:3\"."
- :group 'org-export-general
- :type '(choice
- (const :tag "No Table of Contents" nil)
- (const :tag "Full Table of Contents" t)
- (integer :tag "TOC to level")))
- (defcustom org-export-with-tables t
- "If non-nil, lines starting with \"|\" define a table.
- For example:
- | Name | Address | Birthday |
- |-------------+----------+-----------|
- | Arthur Dent | England | 29.2.2100 |
- This option can also be set with the #+OPTIONS line, e.g. \"|:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-tags t
- "If nil, do not export tags, just remove them from headlines.
- If this is the symbol `not-in-toc', tags will be removed from
- table of contents entries, but still be shown in the headlines of
- the document.
- This option can also be set with the #+OPTIONS line,
- e.g. \"tags:nil\"."
- :group 'org-export-general
- :type '(choice
- (const :tag "Off" nil)
- (const :tag "Not in TOC" not-in-toc)
- (const :tag "On" t)))
- (defcustom org-export-with-tasks t
- "Non-nil means include TODO items for export.
- This may have the following values:
- t include tasks independent of state.
- todo include only tasks that are not yet done.
- done include only tasks that are already done.
- nil remove all tasks before export
- list of keywords keep only tasks with these keywords"
- :group 'org-export-general
- :type '(choice
- (const :tag "All tasks" t)
- (const :tag "No tasks" nil)
- (const :tag "Not-done tasks" todo)
- (const :tag "Only done tasks" done)
- (repeat :tag "Specific TODO keywords"
- (string :tag "Keyword"))))
- (defcustom org-export-time-stamp-file t
- "Non-nil means insert a time stamp into the exported file.
- The time stamp shows when the file was created.
- This option can also be set with the #+OPTIONS line,
- e.g. \"timestamp:nil\"."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-with-timestamps t
- "Non nil means allow timestamps in export.
- It can be set to `active', `inactive', t or nil, in order to
- export, respectively, only active timestamps, only inactive ones,
- all of them or none.
- This option can also be set with the #+OPTIONS line, e.g.
- \"<:nil\"."
- :group 'org-export-general
- :type '(choice
- (const :tag "All timestamps" t)
- (const :tag "Only active timestamps" active)
- (const :tag "Only inactive timestamps" inactive)
- (const :tag "No timestamp" nil)))
- (defcustom org-export-with-todo-keywords t
- "Non-nil means include TODO keywords in export.
- When nil, remove all these keywords from the export."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-allow-BIND 'confirm
- "Non-nil means allow #+BIND to define local variable values for export.
- This is a potential security risk, which is why the user must
- confirm the use of these lines."
- :group 'org-export-general
- :type '(choice
- (const :tag "Never" nil)
- (const :tag "Always" t)
- (const :tag "Ask a confirmation for each file" confirm)))
- (defcustom org-export-snippet-translation-alist nil
- "Alist between export snippets back-ends and exporter back-ends.
- This variable allows to provide shortcuts for export snippets.
- For example, with a value of '\(\(\"h\" . \"e-html\"\)\), the
- HTML back-end will recognize the contents of \"@@h:<b>@@\" as
- HTML code while every other back-end will ignore it."
- :group 'org-export-general
- :type '(repeat
- (cons
- (string :tag "Shortcut")
- (string :tag "Back-end"))))
- (defcustom org-export-coding-system nil
- "Coding system for the exported file."
- :group 'org-export-general
- :type 'coding-system)
- (defcustom org-export-copy-to-kill-ring t
- "Non-nil means exported stuff will also be pushed onto the kill ring."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-initial-scope 'buffer
- "The initial scope when exporting with `org-export-dispatch'.
- This variable can be either set to `buffer' or `subtree'."
- :group 'org-export-general
- :type '(choice
- (const :tag "Export current buffer" 'buffer)
- (const :tag "Export current subtree" 'subtree)))
- (defcustom org-export-show-temporary-export-buffer t
- "Non-nil means show buffer after exporting to temp buffer.
- When Org exports to a file, the buffer visiting that file is ever
- shown, but remains buried. However, when exporting to
- a temporary buffer, that buffer is popped up in a second window.
- When this variable is nil, the buffer remains buried also in
- these cases."
- :group 'org-export-general
- :type 'boolean)
- (defcustom org-export-dispatch-use-expert-ui nil
- "Non-nil means using a non-intrusive `org-export-dispatch'.
- In that case, no help buffer is displayed. Though, an indicator
- for current export scope is added to the prompt \(i.e. \"b\" when
- output is restricted to body only, \"s\" when it is restricted to
- the current subtree and \"v\" when only visible elements are
- considered for export\). Also, \[?] allows to switch back to
- standard mode."
- :group 'org-export-general
- :type 'boolean)
- (defmacro org-export-define-backend (backend translators &rest body)
- "Define a new back-end BACKEND.
- TRANSLATORS is an alist between object or element types and
- functions handling them.
- These functions should return a string without any trailing
- space, or nil. They must accept three arguments: the object or
- element itself, its contents or nil when it isn't recursive and
- the property list used as a communication channel.
- Contents, when not nil, are stripped from any global indentation
- \(although the relative one is preserved). They also always end
- with a single newline character.
- If, for a given type, no function is found, that element or
- object type will simply be ignored, along with any blank line or
- white space at its end. The same will happen if the function
- returns the nil value. If that function returns the empty
- string, the type will be ignored, but the blank lines or white
- spaces will be kept.
- In addition to element and object types, one function can be
- associated to the `template' symbol and another one to the
- `plain-text' symbol.
- The former returns the final transcoded string, and can be used
- to add a preamble and a postamble to document's body. It must
- accept two arguments: the transcoded string and the property list
- containing export options.
- The latter, when defined, is to be called on every text not
- recognized as an element or an object. It must accept two
- arguments: the text string and the information channel. It is an
- appropriate place to protect special chars relative to the
- back-end.
- BODY can start with pre-defined keyword arguments. The following
- keywords are understood:
- :export-block
- String, or list of strings, representing block names that
- will not be parsed. This is used to specify blocks that will
- contain raw code specific to the back-end. These blocks
- still have to be handled by the relative `export-block' type
- translator.
- :filters-alist
- Alist between filters and function, or list of functions,
- specific to the back-end. See `org-export-filters-alist' for
- a list of all allowed filters. Filters defined here
- shouldn't make a back-end test, as it may prevent back-ends
- derived from this one to behave properly.
- :menu-entry
- Menu entry for the export dispatcher. It should be a list
- like:
- \(KEY DESCRIPTION ACTION-OR-MENU)
- where :
- KEY is a free character selecting the back-end.
- DESCRIPTION is a string naming the back-end.
- ACTION-OR-MENU is either a function or an alist.
- If it is an action, it will be called with three arguments:
- SUBTREEP, VISIBLE-ONLY and BODY-ONLY. See `org-export-as'
- for further explanations.
- If it is an alist, associations should follow the
- pattern:
- \(KEY DESCRIPTION ACTION)
- where KEY, DESCRIPTION and ACTION are described above.
- Valid values include:
- \(?m \"My Special Back-end\" my-special-export-function)
- or
- \(?l \"Export to LaTeX\"
- \((?b \"TEX (buffer)\" org-e-latex-export-as-latex)
- \(?l \"TEX (file)\" org-e-latex-export-to-latex)
- \(?p \"PDF file\" org-e-latex-export-to-pdf)
- \(?o \"PDF file and open\"
- \(lambda (subtree visible body-only)
- \(org-open-file
- \(org-e-latex-export-to-pdf subtree visible body-only))))))
- :options-alist
- Alist between back-end specific properties introduced in
- communication channel and how their value are acquired. See
- `org-export-options-alist' for more information about
- structure of the values."
- (declare (debug (&define name sexp [&rest [keywordp sexp]] defbody))
- (indent 1))
- (let (export-block filters menu-entry options)
- (while (keywordp (car body))
- (case (pop body)
- (:export-block (let ((names (pop body)))
- (setq export-block
- (if (consp names) (mapcar 'upcase names)
- (list (upcase names))))))
- (:filters-alist (setq filters (pop body)))
- (:menu-entry (setq menu-entry (pop body)))
- (:options-alist (setq options (pop body)))
- (t (pop body))))
- `(progn
-
- (defvar ,(intern (format "org-%s-translate-alist" backend)) ',translators
- "Alist between element or object types and translators.")
-
- ,(when options
- `(defconst ,(intern (format "org-%s-options-alist" backend)) ',options
- ,(format "Alist between %s export properties and ways to set them.
- See `org-export-options-alist' for more information on the
- structure of the values."
- backend)))
-
- ,(when filters
- `(defconst ,(intern (format "org-%s-filters-alist" backend)) ',filters
- "Alist between filters keywords and back-end specific filters.
- See `org-export-filters-alist' for more information."))
-
- ,(when export-block
- `(mapc
- (lambda (name)
- (add-to-list 'org-element-block-name-alist
- `(,name . org-element-export-block-parser)))
- ',export-block))
-
- ,(when menu-entry
- (let ((menu (assq (car menu-entry) org-export-dispatch-menu-entries)))
- (unless menu
- `(push ',menu-entry org-export-dispatch-menu-entries))))
-
- ,@body)))
- (defmacro org-export-define-derived-backend (child parent &rest body)
- "Create a new back-end as a variant of an existing one.
- CHILD is the name of the derived back-end. PARENT is the name of
- the parent back-end.
- BODY can start with pre-defined keyword arguments. The following
- keywords are understood:
- :export-block
- String, or list of strings, representing block names that
- will not be parsed. This is used to specify blocks that will
- contain raw code specific to the back-end. These blocks
- still have to be handled by the relative `export-block' type
- translator.
- :filters-alist
- Alist of filters that will overwrite or complete filters
- defined in PARENT back-end. See `org-export-filters-alist'
- for a list of allowed filters.
- :menu-entry
- Menu entry for the export dispatcher. See
- `org-export-define-backend' for more information about the
- expected value.
- :options-alist
- Alist of back-end specific properties that will overwrite or
- complete those defined in PARENT back-end. Refer to
- `org-export-options-alist' for more information about
- structure of the values.
- :sub-menu-entry
- Append entries to an existing menu in the export dispatcher.
- The associated value should be a list whose CAR is the
- character selecting the menu to expand and CDR a list of
- entries following the pattern:
- \(KEY DESCRIPTION ACTION)
- where KEY is a free character triggering the action,
- DESCRIPTION is a string defining the action, and ACTION is
- a function that will be called with three arguments:
- SUBTREEP, VISIBLE-ONLY and BODY-ONLY. See `org-export-as'
- for further explanations.
- Valid values include:
- \(?l (?P \"As PDF file (Beamer)\" org-e-beamer-export-to-pdf)
- \(?O \"As PDF file and open (Beamer)\"
- \(lambda (s v b)
- \(org-open-file (org-e-beamer-export-to-pdf s v b)))))
- :translate-alist
- Alist of element and object types and transcoders that will
- overwrite or complete transcode table from PARENT back-end.
- Refer to `org-export-define-backend' for detailed information
- about transcoders.
- As an example, here is how one could define \"my-latex\" back-end
- as a variant of `e-latex' back-end with a custom template
- function:
- \(org-export-define-derived-backend my-latex e-latex
- :translate-alist ((template . my-latex-template-fun)))
- The back-end could then be called with, for example:
- \(org-export-to-buffer 'my-latex \"*Test my-latex*\")"
- (declare (debug (&define name sexp [&rest [keywordp sexp]] def-body))
- (indent 2))
- (let (export-block filters menu-entry options sub-menu-entry translate)
- (while (keywordp (car body))
- (case (pop body)
- (:export-block (let ((names (pop body)))
- (setq export-block
- (if (consp names) (mapcar 'upcase names)
- (list (upcase names))))))
- (:filters-alist (setq filters (pop body)))
- (:menu-entry (setq menu-entry (pop body)))
- (:options-alist (setq options (pop body)))
- (:sub-menu-entry (setq sub-menu-entry (pop body)))
- (:translate-alist (setq translate (pop body)))
- (t (pop body))))
- `(progn
-
- ,(when export-block
- `(mapc
- (lambda (name)
- (add-to-list 'org-element-block-name-alist
- `(,name . org-element-export-block-parser)))
- ',export-block))
-
- ,(let ((parent-filters (intern (format "org-%s-filters-alist" parent))))
- (when (or (boundp parent-filters) filters)
- `(defconst ,(intern (format "org-%s-filters-alist" child))
- ',(append filters
- (and (boundp parent-filters)
- (copy-sequence (symbol-value parent-filters))))
- "Alist between filters keywords and back-end specific filters.
- See `org-export-filters-alist' for more information.")))
-
- ,(let ((parent-options (intern (format "org-%s-options-alist" parent))))
- (when (or (boundp parent-options) options)
- `(defconst ,(intern (format "org-%s-options-alist" child))
- ',(append options
- (and (boundp parent-options)
- (copy-sequence (symbol-value parent-options))))
- ,(format "Alist between %s export properties and ways to set them.
- See `org-export-options-alist' for more information on the
- structure of the values."
- child))))
-
- (defvar ,(intern (format "org-%s-translate-alist" child))
- ',(append translate
- (copy-sequence
- (symbol-value
- (intern (format "org-%s-translate-alist" parent)))))
- "Alist between element or object types and translators.")
-
- ,(when menu-entry
- (let ((menu (assq (car menu-entry) org-export-dispatch-menu-entries)))
- (unless menu
- `(push ',menu-entry org-export-dispatch-menu-entries))))
- ,(when sub-menu-entry
- (let ((menu (nth 2 (assq (car sub-menu-entry)
- org-export-dispatch-menu-entries))))
- (when menu `(nconc ',menu
- ',(org-remove-if (lambda (e) (member e menu))
- (cdr sub-menu-entry))))))
-
- ,@body)))
- (defun org-export-barf-if-invalid-backend (backend)
- "Signal an error if BACKEND isn't defined."
- (unless (boundp (intern (format "org-%s-translate-alist" backend)))
- (error "Unknown \"%s\" back-end: Aborting export" backend)))
- (defun org-export-get-environment (&optional backend subtreep ext-plist)
- "Collect export options from the current buffer.
- Optional argument BACKEND is a symbol specifying which back-end
- specific options to read, if any.
- When optional argument SUBTREEP is non-nil, assume the export is
- done against the current sub-tree.
- Third optional argument EXT-PLIST is a property list with
- external parameters overriding Org default settings, but still
- inferior to file-local settings."
-
- (org-export--install-letbind-maybe)
-
- (org-combine-plists
-
- (org-export--get-global-options backend)
-
- (org-export--get-buffer-attributes)
-
- ext-plist
-
- (org-export--get-inbuffer-options
- backend
- (and buffer-file-name (org-remove-double-quotes buffer-file-name)))
-
- (and subtreep (org-export--get-subtree-options backend))
-
- `(:back-end
- ,backend
- :translate-alist
- ,(let ((trans-alist (intern (format "org-%s-translate-alist" backend))))
- (when (boundp trans-alist) (symbol-value trans-alist))))))
- (defun org-export--parse-option-keyword (options &optional backend)
- "Parse an OPTIONS line and return values as a plist.
- Optional argument BACKEND is a symbol specifying which back-end
- specific items to read, if any."
- (let* ((all
- (append org-export-options-alist
- (and backend
- (let ((var (intern
- (format "org-%s-options-alist" backend))))
- (and (boundp var) (eval var))))))
-
- (alist (delq nil
- (mapcar (lambda (e)
- (when (nth 2 e) (cons (regexp-quote (nth 2 e))
- (car e))))
- all)))
- plist)
- (mapc (lambda (e)
- (when (string-match (concat "\\(\\`\\|[ \t]\\)"
- (car e)
- ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)")
- options)
- (setq plist (plist-put plist
- (cdr e)
- (car (read-from-string
- (match-string 2 options)))))))
- alist)
- plist))
- (defun org-export--get-subtree-options (&optional backend)
- "Get export options in subtree at point.
- Optional argument BACKEND is a symbol specifying back-end used
- for export. Return options as a plist."
-
-
-
- (org-with-wide-buffer
- (let (prop plist)
-
- (unless (org-at-heading-p) (org-back-to-heading t))
-
-
- (when (setq prop (progn (looking-at org-todo-line-regexp)
- (or (save-match-data
- (org-entry-get (point) "EXPORT_TITLE"))
- (org-match-string-no-properties 3))))
- (setq plist
- (plist-put
- plist :title
- (org-element-parse-secondary-string
- prop (org-element-restriction 'keyword)))))
-
- (when (setq prop (org-entry-get (point) "EXPORT_OPTIONS"))
- (setq plist
- (nconc plist (org-export--parse-option-keyword prop backend))))
-
- (let ((seen '("TITLE")))
- (mapc
- (lambda (option)
- (let ((property (nth 1 option)))
- (when (and property (not (member property seen)))
- (let* ((subtree-prop (concat "EXPORT_" property))
-
- (value (let ((case-fold-search t))
- (org-entry-get (point) subtree-prop))))
- (push property seen)
- (when value
- (setq plist
- (plist-put
- plist
- (car option)
-
- (if (member property org-element-parsed-keywords)
- (org-element-parse-secondary-string
- value (org-element-restriction 'keyword))
- value))))))))
-
-
- (append (and backend
- (let ((var (intern
- (format "org-%s-options-alist" backend))))
- (and (boundp var) (symbol-value var))))
- org-export-options-alist)))
-
- plist)))
- (defun org-export--get-inbuffer-options (&optional backend files)
- "Return current buffer export options, as a plist.
- Optional argument BACKEND, when non-nil, is a symbol specifying
- which back-end specific options should also be read in the
- process.
- Optional argument FILES is a list of setup files names read so
- far, used to avoid circular dependencies.
- Assume buffer is in Org mode. Narrowing, if any, is ignored."
- (org-with-wide-buffer
- (goto-char (point-min))
- (let ((case-fold-search t) plist)
-
- (let ((special-re
- (format "^[ \t]*#\\+%s:" (regexp-opt org-export-special-keywords))))
- (while (re-search-forward special-re nil t)
- (let ((element (org-element-at-point)))
- (when (eq (org-element-type element) 'keyword)
- (let* ((key (org-element-property :key element))
- (val (org-element-property :value element))
- (prop
- (cond
- ((string= key "SETUP_FILE")
- (let ((file
- (expand-file-name
- (org-remove-double-quotes (org-trim val)))))
-
- (unless (member file files)
- (with-temp-buffer
- (insert (org-file-contents file 'noerror))
- (org-mode)
- (org-export--get-inbuffer-options
- backend (cons file files))))))
- ((string= key "OPTIONS")
- (org-export--parse-option-keyword val backend)))))
- (setq plist (org-combine-plists plist prop)))))))
-
- (let* ((all (append org-export-options-alist
-
-
- (and backend
- (let ((var
- (intern
- (format "org-%s-options-alist" backend))))
- (and (boundp var) (eval var))))))
-
- (alist
- (delq nil (mapcar
- (lambda (e) (when (nth 1 e) (cons (nth 1 e) (car e))))
- all)))
-
-
- (opt-re (format "^[ \t]*#\\+%s:"
- (regexp-opt
- (delq nil (mapcar (lambda (e) (nth 1 e)) all))))))
- (goto-char (point-min))
- (while (re-search-forward opt-re nil t)
- (let ((element (org-element-at-point)))
- (when (eq (org-element-type element) 'keyword)
- (let* ((key (org-element-property :key element))
- (val (org-element-property :value element))
- (prop (cdr (assoc key alist)))
- (behaviour (nth 4 (assq prop all))))
- (setq plist
- (plist-put
- plist prop
-
- (case behaviour
- (space
- (if (not (plist-get plist prop)) (org-trim val)
- (concat (plist-get plist prop) " " (org-trim val))))
- (newline
- (org-trim
- (concat (plist-get plist prop) "\n" (org-trim val))))
- (split
- `(,@(plist-get plist prop) ,@(org-split-string val)))
- ('t val)
- (otherwise (if (not (plist-member plist prop)) val
- (plist-get plist prop))))))))))
-
- (mapc
- (lambda (key)
- (let* ((prop (cdr (assoc key alist)))
- (value (and prop (plist-get plist prop))))
- (when (stringp value)
- (setq plist
- (plist-put
- plist prop
- (org-element-parse-secondary-string
- value (org-element-restriction 'keyword)))))))
- org-element-parsed-keywords))
-
- plist)))
- (defun org-export--get-buffer-attributes ()
- "Return properties related to buffer attributes, as a plist."
- (let ((visited-file (buffer-file-name (buffer-base-buffer))))
- (list
-
- :input-file visited-file
- :title (or (and visited-file
- (file-name-sans-extension
- (file-name-nondirectory visited-file)))
- (buffer-name (buffer-base-buffer)))
- :footnote-definition-alist
-
-
-
- (let (alist)
- (org-with-wide-buffer
- (goto-char (point-min))
- (while (re-search-forward org-footnote-definition-re nil t)
- (let ((def (org-footnote-at-definition-p)))
- (when def
- (org-skip-whitespace)
- (push (cons (car def)
- (save-restriction
- (narrow-to-region (point) (nth 2 def))
-
-
-
- (org-element--parse-elements
- (point-min) (point-max) nil nil nil nil
- (list 'org-data nil))))
- alist))))
- alist))
- :id-alist
-
- (let (alist)
- (org-with-wide-buffer
- (goto-char (point-min))
- (while (re-search-forward
- "\\[\\[id:\\(\\S-+?\\)\\]\\(?:\\[.*?\\]\\)?\\]" nil t)
- (let* ((id (org-match-string-no-properties 1))
- (file (org-id-find-id-file id)))
- (when file (push (cons id (file-relative-name file)) alist)))))
- alist))))
- (defun org-export--get-global-options (&optional backend)
- "Return global export options as a plist.
- Optional argument BACKEND, if non-nil, is a symbol specifying
- which back-end specific export options should also be read in the
- process."
- (let ((all (append org-export-options-alist
- (and backend
- (let ((var (intern
- (format "org-%s-options-alist" backend))))
- (and (boundp var) (symbol-value var))))))
-
- plist)
- (mapc
- (lambda (cell)
- (setq plist
- (plist-put
- plist
- (car cell)
-
-
-
- (let ((value (eval (nth 3 cell))))
- (if (not (stringp value)) value
- (let ((keyword (nth 1 cell)))
- (if (not (member keyword org-element-parsed-keywords)) value
- (org-element-parse-secondary-string
- value (org-element-restriction 'keyword)))))))))
- all)
-
- plist))
- (defvar org-export--allow-BIND-local nil)
- (defun org-export--confirm-letbind ()
- "Can we use #+BIND values during export?
- By default this will ask for confirmation by the user, to divert
- possible security risks."
- (cond
- ((not org-export-allow-BIND) nil)
- ((eq org-export-allow-BIND t) t)
- ((local-variable-p 'org-export--allow-BIND-local)
- org-export--allow-BIND-local)
- (t (org-set-local 'org-export--allow-BIND-local
- (yes-or-no-p "Allow BIND values in this buffer? ")))))
- (defun org-export--install-letbind-maybe ()
- "Install the values from #+BIND lines as local variables.
- Variables must be installed before in-buffer options are
- retrieved."
- (let ((case-fold-search t) letbind pair)
- (org-with-wide-buffer
- (goto-char (point-min))
- (while (re-search-forward "^[ \t]*#\\+BIND:" nil t)
- (let* ((element (org-element-at-point))
- (value (org-element-property :value element)))
- (when (and (eq (org-element-type element) 'keyword)
- (not (equal value ""))
- (org-export--confirm-letbind))
- (push (read (format "(%s)" value)) letbind)))))
- (dolist (pair (nreverse letbind))
- (org-set-local (car pair) (nth 1 pair)))))
- (defun org-export-collect-tree-properties (data info)
- "Extract tree properties from parse tree.
- DATA is the parse tree from which information is retrieved. INFO
- is a list holding export options.
- Following tree properties are set or updated:
- `:exported-data' Hash table used to memoize results from
- `org-export-data'.
- `:footnote-definition-alist' List of footnotes definitions in
- original buffer and current parse tree.
- `:headline-offset' Offset between true level of headlines and
- local level. An offset of -1 means an headline
- of level 2 should be considered as a level
- 1 headline in the context.
- `:headline-numbering' Alist of all headlines as key an the
- associated numbering as value.
- `:ignore-list' List of elements that should be ignored during
- export.
- `:target-list' List of all targets in the parse tree.
- Return updated plist."
-
-
- (setq info (plist-put info :parse-tree data))
-
-
-
- (setq info
- (plist-put info
- :ignore-list
- (append (org-export--populate-ignore-list data info)
- (plist-get info :ignore-list))))
-
-
- (setq info
- (plist-put info
- :headline-offset
- (- 1 (org-export--get-min-level data info))))
-
-
-
-
-
- (let ((defs (plist-get info :footnote-definition-alist)))
- (org-element-map
- data 'footnote-definition
- (lambda (fn)
- (push (cons (org-element-property :label fn)
- `(org-data nil ,@(org-element-contents fn)))
- defs)))
- (setq info (plist-put info :footnote-definition-alist defs)))
-
-
- (nconc
- `(:target-list
- ,(org-element-map
- data '(keyword target)
- (lambda (blob)
- (when (or (eq (org-element-type blob) 'target)
- (string= (org-element-property :key blob) "TARGET"))
- blob)) info)
- :headline-numbering ,(org-export--collect-headline-numbering data info)
- :exported-data ,(make-hash-table :test 'eq :size 4001))
- info))
- (defun org-export--get-min-level (data options)
- "Return minimum exportable headline's level in DATA.
- DATA is parsed tree as returned by `org-element-parse-buffer'.
- OPTIONS is a plist holding export options."
- (catch 'exit
- (let ((min-level 10000))
- (mapc
- (lambda (blob)
- (when (and (eq (org-element-type blob) 'headline)
- (not (memq blob (plist-get options :ignore-list))))
- (setq min-level
- (min (org-element-property :level blob) min-level)))
- (when (= min-level 1) (throw 'exit 1)))
- (org-element-contents data))
-
-
- (if (= min-level 10000) 1 min-level))))
- (defun org-export--collect-headline-numbering (data options)
- "Return numbering of all exportable headlines in a parse tree.
- DATA is the parse tree. OPTIONS is the plist holding export
- options.
- Return an alist whose key is an headline and value is its
- associated numbering \(in the shape of a list of numbers\)."
- (let ((numbering (make-vector org-export-max-depth 0)))
- (org-element-map
- data
- 'headline
- (lambda (headline)
- (let ((relative-level
- (1- (org-export-get-relative-level headline options))))
- (cons
- headline
- (loop for n across numbering
- for idx from 0 to org-export-max-depth
- when (< idx relative-level) collect n
- when (= idx relative-level) collect (aset numbering idx (1+ n))
- when (> idx relative-level) do (aset numbering idx 0)))))
- options)))
- (defun org-export--populate-ignore-list (data options)
- "Return list of elements and objects to ignore during export.
- DATA is the parse tree to traverse. OPTIONS is the plist holding
- export options."
- (let* (ignore
- walk-data
-
- (selected (org-export--selected-trees data options))
- (walk-data
- (lambda (data)
-
- (let ((type (org-element-type data)))
- (if (org-export--skip-p data options selected) (push data ignore)
- (if (and (eq type 'headline)
- (eq (plist-get options :with-archived-trees) 'headline)
- (org-element-property :archivedp data))
-
-
- (mapc (lambda (e) (push e ignore))
- (org-element-contents data))
-
- (let ((sec-prop
- (cdr (assq type org-element-secondary-value-alist))))
- (when sec-prop
- (mapc walk-data (org-element-property sec-prop data))))
-
- (mapc walk-data (org-element-contents data))))))))
-
- (funcall walk-data data)
-
- ignore))
- (defun org-export--selected-trees (data info)
- "Return list of headlines containing a select tag in their tree.
- DATA is parsed data as returned by `org-element-parse-buffer'.
- INFO is a plist holding export options."
- (let* (selected-trees
- walk-data
- (walk-data
- (function
- (lambda (data genealogy)
- (case (org-element-type data)
- (org-data (mapc (lambda (el) (funcall walk-data el genealogy))
- (org-element-contents data)))
- (headline
- (let ((tags (org-element-property :tags data)))
- (if (loop for tag in (plist-get info :select-tags)
- thereis (member tag tags))
-
-
-
- (setq selected-trees
- (append
- genealogy
- (org-element-map data 'headline 'identity)
- selected-trees))
-
- (mapc
- (lambda (el) (funcall walk-data el (cons data genealogy)))
- (org-element-contents data))))))))))
- (funcall walk-data data nil) selected-trees))
- (defun org-export--skip-p (blob options selected)
- "Non-nil when element or object BLOB should be skipped during export.
- OPTIONS is the plist holding export options. SELECTED, when
- non-nil, is a list of headlines belonging to a tree with a select
- tag."
- (case (org-element-type blob)
- (clock (not (plist-get options :with-clocks)))
- (drawer
- (or (not (plist-get options :with-drawers))
- (and (consp (plist-get options :with-drawers))
- (not (member (org-element-property :drawer-name blob)
- (plist-get options :with-drawers))))))
- (headline
- (let ((with-tasks (plist-get options :with-tasks))
- (todo (org-element-property :todo-keyword blob))
- (todo-type (org-element-property :todo-type blob))
- (archived (plist-get options :with-archived-trees))
- (tags (org-element-property :tags blob)))
- (or
-
- (loop for k in (plist-get options :exclude-tags)
- thereis (member k tags))
-
-
- (and selected (not (memq blob selected)))
-
- (org-element-property :commentedp blob)
-
- (and (not archived) (org-element-property :archivedp blob))
-
- (and todo
- (or (not with-tasks)
- (and (memq with-tasks '(todo done))
- (not (eq todo-type with-tasks)))
- (and (consp with-tasks) (not (member todo with-tasks))))))))
- (inlinetask (not (plist-get options :with-inlinetasks)))
- (planning (not (plist-get options :with-plannings)))
- (statistics-cookie (not (plist-get options :with-statistics-cookies)))
- (table-cell
- (and (org-export-table-has-special-column-p
- (org-export-get-parent-table blob))
- (not (org-export-get-previous-element blob options))))
- (table-row (org-export-table-row-is-special-p blob options))
- (timestamp
- (case (plist-get options :with-timestamps)
-
- ('nil t)
-
-
- (active
- (not (memq (org-element-property :type blob)
- '(active active-range))))
-
-
- (inactive
- (not (memq (org-element-property :type blob)
- '(inactive inactive-range))))))))
- (defun org-export-transcoder (blob info)
- "Return appropriate transcoder for BLOB.
- INFO is a plist containing export directives."
- (let ((type (org-element-type blob)))
-
- (if (eq type 'org-data) (lambda (blob contents info) contents)
- (let ((transcoder (cdr (assq type (plist-get info :translate-alist)))))
- (and (functionp transcoder) transcoder)))))
- (defun org-export-data (data info)
- "Convert DATA into current back-end format.
- DATA is a parse tree, an element or an object or a secondary
- string. INFO is a plist holding export options.
- Return transcoded string."
- (let ((memo (gethash data (plist-get info :exported-data) 'no-memo)))
- (if (not (eq memo 'no-memo)) memo
- (let* ((type (org-element-type data))
- (results
- (cond
-
- ((memq data (plist-get info :ignore-list)) nil)
-
- ((eq type 'plain-text)
- (org-export-filter-apply-functions
- (plist-get info :filter-plain-text)
- (let ((transcoder (org-export-transcoder data info)))
- (if transcoder (funcall transcoder data info) data))
- info))
-
-
- ((not (org-export--interpret-p data info))
- (org-export-data
- (org-export-expand
- data
- (mapconcat (lambda (blob) (org-export-data blob info))
- (org-element-contents data)
- ""))
- info))
-
- ((not type)
- (mapconcat (lambda (obj) (org-export-data obj info)) data ""))
-
-
-
- ((or (not (org-element-contents data))
- (and (eq type 'headline)
- (eq (plist-get info :with-archived-trees) 'headline)
- (org-element-property :archivedp data)))
- (let ((transcoder (org-export-transcoder data info)))
- (and (functionp transcoder)
- (funcall transcoder data nil info))))
-
- (t
- (let ((transcoder (org-export-transcoder data info)))
- (when transcoder
- (let* ((greaterp (memq type org-element-greater-elements))
- (objectp
- (and (not greaterp)
- (memq type org-element-recursive-objects)))
- (contents
- (mapconcat
- (lambda (element) (org-export-data element info))
- (org-element-contents
- (if (or greaterp objectp) data
-
-
-
- (org-element-normalize-contents
- data
-
-
-
-
-
- (when (eq type 'paragraph)
- (let ((parent (org-export-get-parent data)))
- (and
- (eq (car (org-element-contents parent))
- data)
- (memq (org-element-type parent)
- '(footnote-definition item))))))))
- "")))
- (funcall transcoder data
- (if (not greaterp) contents
- (org-element-normalize-string contents))
- info))))))))
-
- (puthash
- data
- (cond
- ((not results) nil)
- ((memq type '(org-data plain-text nil)) results)
-
-
- (t
- (let ((results
- (org-export-filter-apply-functions
- (plist-get info (intern (format ":filter-%s" type)))
- (let ((post-blank (or (org-element-property :post-blank data)
- 0)))
- (if (memq type org-element-all-elements)
- (concat (org-element-normalize-string results)
- (make-string post-blank ?\n))
- (concat results (make-string post-blank ? ))))
- info)))
- results)))
- (plist-get info :exported-data))))))
- (defun org-export--interpret-p (blob info)
- "Non-nil if element or object BLOB should be interpreted as Org syntax.
- Check is done according to export options INFO, stored as
- a plist."
- (case (org-element-type blob)
-
- (entity (plist-get info :with-entities))
-
- (emphasis (plist-get info :with-emphasize))
-
- (fixed-width (plist-get info :with-fixed-width))
-
- ((footnote-definition footnote-reference)
- (plist-get info :with-footnotes))
-
- ((subscript superscript)
- (let ((sub/super-p (plist-get info :with-sub-superscript)))
- (if (eq sub/super-p '{})
- (org-element-property :use-brackets-p blob)
- sub/super-p)))
-
- (table (plist-get info :with-tables))
- (otherwise t)))
- (defun org-export-expand (blob contents)
- "Expand a parsed element or object to its original state.
- BLOB is either an element or an object. CONTENTS is its
- contents, as a string or nil."
- (funcall
- (intern (format "org-element-%s-interpreter" (org-element-type blob)))
- blob contents))
- (defun org-export-ignore-element (element info)
- "Add ELEMENT to `:ignore-list' in INFO.
- Any element in `:ignore-list' will be skipped when using
- `org-element-map'. INFO is modified by side effects."
- (plist-put info :ignore-list (cons element (plist-get info :ignore-list))))
- (defvar org-export-before-parsing-hook nil
- "Hook run before parsing an export buffer.
- This is run after include keywords have been expanded and Babel
- code executed, on a copy of original buffer's area being
- exported. Visibility is the same as in the original one. Point
- is left at the beginning of the new one.
- Every function in this hook will be called with one argument: the
- back-end currently used, as a symbol.")
- (defvar org-export-filter-parse-tree-functions nil
- "List of functions applied to the parsed tree.
- Each filter is called with three arguments: the parse tree, as
- returned by `org-element-parse-buffer', the back-end, as
- a symbol, and the communication channel, as a plist. It must
- return the modified parse tree to transcode.")
- (defvar org-export-filter-final-output-functions nil
- "List of functions applied to the transcoded string.
- Each filter is called with three arguments: the full transcoded
- string, the back-end, as a symbol, and the communication channel,
- as a plist. It must return a string that will be used as the
- final export output.")
- (defvar org-export-filter-plain-text-functions nil
- "List of functions applied to plain text.
- Each filter is called with three arguments: a string which
- contains no Org syntax, the back-end, as a symbol, and the
- communication channel, as a plist. It must return a string or
- nil.")
- (defvar org-export-filter-babel-call-functions nil
- "List of functions applied to a transcoded babel-call.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-center-block-functions nil
- "List of functions applied to a transcoded center block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-clock-functions nil
- "List of functions applied to a transcoded clock.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-comment-functions nil
- "List of functions applied to a transcoded comment.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-comment-block-functions nil
- "List of functions applied to a transcoded comment-comment.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-drawer-functions nil
- "List of functions applied to a transcoded drawer.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-dynamic-block-functions nil
- "List of functions applied to a transcoded dynamic-block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-example-block-functions nil
- "List of functions applied to a transcoded example-block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-export-block-functions nil
- "List of functions applied to a transcoded export-block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-fixed-width-functions nil
- "List of functions applied to a transcoded fixed-width.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-footnote-definition-functions nil
- "List of functions applied to a transcoded footnote-definition.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-headline-functions nil
- "List of functions applied to a transcoded headline.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-horizontal-rule-functions nil
- "List of functions applied to a transcoded horizontal-rule.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-inlinetask-functions nil
- "List of functions applied to a transcoded inlinetask.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-item-functions nil
- "List of functions applied to a transcoded item.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-keyword-functions nil
- "List of functions applied to a transcoded keyword.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-latex-environment-functions nil
- "List of functions applied to a transcoded latex-environment.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-node-property-functions nil
- "List of functions applied to a transcoded node-property.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-paragraph-functions nil
- "List of functions applied to a transcoded paragraph.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-plain-list-functions nil
- "List of functions applied to a transcoded plain-list.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-planning-functions nil
- "List of functions applied to a transcoded planning.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-property-drawer-functions nil
- "List of functions applied to a transcoded property-drawer.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-quote-block-functions nil
- "List of functions applied to a transcoded quote block.
- Each filter is called with three arguments: the transcoded quote
- data, as a string, the back-end, as a symbol, and the
- communication channel, as a plist. It must return a string or
- nil.")
- (defvar org-export-filter-quote-section-functions nil
- "List of functions applied to a transcoded quote-section.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-section-functions nil
- "List of functions applied to a transcoded section.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-special-block-functions nil
- "List of functions applied to a transcoded special block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-src-block-functions nil
- "List of functions applied to a transcoded src-block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-table-functions nil
- "List of functions applied to a transcoded table.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-table-cell-functions nil
- "List of functions applied to a transcoded table-cell.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-table-row-functions nil
- "List of functions applied to a transcoded table-row.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-verse-block-functions nil
- "List of functions applied to a transcoded verse block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-bold-functions nil
- "List of functions applied to transcoded bold text.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-code-functions nil
- "List of functions applied to transcoded code text.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-entity-functions nil
- "List of functions applied to a transcoded entity.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-export-snippet-functions nil
- "List of functions applied to a transcoded export-snippet.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-footnote-reference-functions nil
- "List of functions applied to a transcoded footnote-reference.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-inline-babel-call-functions nil
- "List of functions applied to a transcoded inline-babel-call.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-inline-src-block-functions nil
- "List of functions applied to a transcoded inline-src-block.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-italic-functions nil
- "List of functions applied to transcoded italic text.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-latex-fragment-functions nil
- "List of functions applied to a transcoded latex-fragment.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-line-break-functions nil
- "List of functions applied to a transcoded line-break.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-link-functions nil
- "List of functions applied to a transcoded link.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-macro-functions nil
- "List of functions applied to a transcoded macro.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-radio-target-functions nil
- "List of functions applied to a transcoded radio-target.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-statistics-cookie-functions nil
- "List of functions applied to a transcoded statistics-cookie.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-strike-through-functions nil
- "List of functions applied to transcoded strike-through text.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-subscript-functions nil
- "List of functions applied to a transcoded subscript.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-superscript-functions nil
- "List of functions applied to a transcoded superscript.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-target-functions nil
- "List of functions applied to a transcoded target.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-timestamp-functions nil
- "List of functions applied to a transcoded timestamp.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-underline-functions nil
- "List of functions applied to transcoded underline text.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defvar org-export-filter-verbatim-functions nil
- "List of functions applied to transcoded verbatim text.
- Each filter is called with three arguments: the transcoded data,
- as a string, the back-end, as a symbol, and the communication
- channel, as a plist. It must return a string or nil.")
- (defun org-export-filter-apply-functions (filters value info)
- "Call every function in FILTERS.
- Functions are called with arguments VALUE, current export
- back-end and INFO. A function returning a nil value will be
- skipped. If it returns the empty string, the process ends and
- VALUE is ignored.
- Call is done in a LIFO fashion, to be sure that developer
- specified filters, if any, are called first."
- (catch 'exit
- (dolist (filter filters value)
- (let ((result (funcall filter value (plist-get info :back-end) info)))
- (cond ((not result) value)
- ((equal value "") (throw 'exit nil))
- (t (setq value result)))))))
- (defun org-export-install-filters (info)
- "Install filters properties in communication channel.
- INFO is a plist containing the current communication channel.
- Return the updated communication channel."
- (let (plist)
-
- (mapc (lambda (p)
- (setq plist (plist-put plist (car p) (eval (cdr p)))))
- org-export-filters-alist)
-
- (let ((back-end-filters (intern (format "org-%s-filters-alist"
- (plist-get info :back-end)))))
- (when (boundp back-end-filters)
- (mapc (lambda (p)
-
- (let ((key (car p)) (value (cdr p)))
- (when value
- (setq plist
- (plist-put
- plist key
- (if (atom value) (cons value (plist-get plist key))
- (append value (plist-get plist key))))))))
- (eval back-end-filters))))
-
- (org-combine-plists info plist)))
- (defun org-export-as
- (backend &optional subtreep visible-only body-only ext-plist noexpand)
- "Transcode current Org buffer into BACKEND code.
- If narrowing is active in the current buffer, only transcode its
- narrowed part.
- If a region is active, transcode that region.
- When optional argument SUBTREEP is non-nil, transcode the
- sub-tree at point, extracting information from the headline
- properties first.
- When optional argument VISIBLE-ONLY is non-nil, don't export
- contents of hidden elements.
- When optional argument BODY-ONLY is non-nil, only return body
- code, without preamble nor postamble.
- Optional argument EXT-PLIST, when provided, is a property list
- with external parameters overriding Org default settings, but
- still inferior to file-local settings.
- Optional argument NOEXPAND, when non-nil, prevents included files
- to be expanded and Babel code to be executed.
- Return code as a string."
-
- (org-export-barf-if-invalid-backend backend)
- (save-excursion
- (save-restriction
-
-
-
- (cond ((org-region-active-p)
- (narrow-to-region (region-beginning) (region-end)))
- (subtreep
- (org-narrow-to-subtree)
- (goto-char (point-min))
- (forward-line)
- (narrow-to-region (point) (point-max))))
-
-
- (let ((info (org-export-install-filters
- (org-export-get-environment backend subtreep ext-plist)))
-
-
-
-
- (tree (let ((buf (or (buffer-file-name (buffer-base-buffer))
- (current-buffer))))
- (org-export-with-current-buffer-copy
- (unless noexpand
- (org-macro-replace-all)
- (org-export-expand-include-keyword)
-
-
-
-
-
-
- (let ((org-current-export-file buf))
- (org-export-blocks-preprocess)))
- (goto-char (point-min))
-
-
-
- (run-hook-with-args
- 'org-export-before-parsing-hook backend)
-
- (org-element-parse-buffer nil visible-only)))))
-
- (setq tree
- (org-export-filter-apply-functions
- (plist-get info :filter-parse-tree) tree info))
-
-
- (setq info
- (org-combine-plists
- info (org-export-collect-tree-properties tree info)))
-
-
-
- (let* ((body (org-element-normalize-string (org-export-data tree info)))
- (template (cdr (assq 'template
- (plist-get info :translate-alist))))
- (output (org-export-filter-apply-functions
- (plist-get info :filter-final-output)
- (if (or (not (functionp template)) body-only) body
- (funcall template body info))
- info)))
-
- (when org-export-copy-to-kill-ring (org-kill-new output))
- output)))))
- (defun org-export-to-buffer
- (backend buffer &optional subtreep visible-only body-only ext-plist noexpand)
- "Call `org-export-as' with output to a specified buffer.
- BACKEND is the back-end used for transcoding, as a symbol.
- BUFFER is the output buffer. If it already exists, it will be
- erased first, otherwise, it will be created.
- Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST
- and NOEXPAND are similar to those used in `org-export-as', which
- see.
- Return buffer."
- (let ((out (org-export-as
- backend subtreep visible-only body-only ext-plist noexpand))
- (buffer (get-buffer-create buffer)))
- (with-current-buffer buffer
- (erase-buffer)
- (insert out)
- (goto-char (point-min)))
- buffer))
- (defun org-export-to-file
- (backend file &optional subtreep visible-only body-only ext-plist noexpand)
- "Call `org-export-as' with output to a specified file.
- BACKEND is the back-end used for transcoding, as a symbol. FILE
- is the name of the output file, as a string.
- Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST
- and NOEXPAND are similar to those used in `org-export-as', which
- see.
- Return output file's name."
-
-
- (unless (file-writable-p file) (error "Output file not writable"))
-
- (let ((out (org-export-as
- backend subtreep visible-only body-only ext-plist noexpand)))
- (with-temp-buffer
- (insert out)
- (let ((coding-system-for-write org-export-coding-system))
- (write-file file))))
-
- file)
- (defun org-export-output-file-name (extension &optional subtreep pub-dir)
- "Return output file's name according to buffer specifications.
- EXTENSION is a string representing the output file extension,
- with the leading dot.
- With a non-nil optional argument SUBTREEP, try to determine
- output file's name by looking for \"EXPORT_FILE_NAME\" property
- of subtree at point.
- When optional argument PUB-DIR is set, use it as the publishing
- directory.
- When optional argument VISIBLE-ONLY is non-nil, don't export
- contents of hidden elements.
- Return file name as a string, or nil if it couldn't be
- determined."
- (let ((base-name
-
-
- (file-name-sans-extension
- (or (and subtreep
- (org-entry-get
- (save-excursion
- (ignore-errors (org-back-to-heading) (point)))
- "EXPORT_FILE_NAME" t))
-
-
- (buffer-file-name (buffer-base-buffer))
-
- (let ((read-file-name-function
- (and org-completion-use-ido 'ido-read-file-name)))
- (read-file-name
- "Output file: " pub-dir nil nil nil
- (lambda (name)
- (string= (file-name-extension name t) extension))))))))
-
-
-
- (cond
- (pub-dir
- (concat (file-name-as-directory pub-dir)
- (file-name-nondirectory base-name)
- extension))
- ((string= (file-name-nondirectory base-name) base-name)
- (concat (file-name-as-directory ".") base-name extension))
- (t (concat base-name extension)))))
- (defmacro org-export-with-current-buffer-copy (&rest body)
- "Apply BODY in a copy of the current buffer.
- The copy preserves local variables and visibility of the original
- buffer.
- Point is at buffer's beginning when BODY is applied."
- (org-with-gensyms (original-buffer offset buffer-string overlays)
- `(let ((,original-buffer (current-buffer))
- (,offset (1- (point-min)))
- (,buffer-string (buffer-string))
- (,overlays (mapcar
- 'copy-overlay (overlays-in (point-min) (point-max)))))
- (with-temp-buffer
- (let ((buffer-invisibility-spec nil))
- (org-clone-local-variables
- ,original-buffer
- "^\\(org-\\|orgtbl-\\|major-mode$\\|outline-\\(regexp\\|level\\)$\\)")
- (insert ,buffer-string)
- (mapc (lambda (ov)
- (move-overlay
- ov
- (- (overlay-start ov) ,offset)
- (- (overlay-end ov) ,offset)
- (current-buffer)))
- ,overlays)
- (goto-char (point-min))
- (progn ,@body))))))
- (def-edebug-spec org-export-with-current-buffer-copy (body))
- (defun org-export-expand-include-keyword (&optional included dir)
- "Expand every include keyword in buffer.
- Optional argument INCLUDED is a list of included file names along
- with their line restriction, when appropriate. It is used to
- avoid infinite recursion. Optional argument DIR is the current
- working directory. It is used to properly resolve relative
- paths."
- (let ((case-fold-search t))
- (goto-char (point-min))
- (while (re-search-forward "^[ \t]*#\\+INCLUDE: \\(.*\\)" nil t)
- (when (eq (org-element-type (save-match-data (org-element-at-point)))
- 'keyword)
- (beginning-of-line)
-
- (let* ((value (match-string 1))
- (ind (org-get-indentation))
- (file (and (string-match "^\"\\(\\S-+\\)\"" value)
- (prog1 (expand-file-name (match-string 1 value) dir)
- (setq value (replace-match "" nil nil value)))))
- (lines
- (and (string-match
- ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\"" value)
- (prog1 (match-string 1 value)
- (setq value (replace-match "" nil nil value)))))
- (env (cond ((string-match "\\<example\\>" value) 'example)
- ((string-match "\\<src\\(?: +\\(.*\\)\\)?" value)
- (match-string 1 value))))
-
-
-
-
- (minlevel
- (and (not env)
- (if (string-match ":minlevel +\\([0-9]+\\)" value)
- (prog1 (string-to-number (match-string 1 value))
- (setq value (replace-match "" nil nil value)))
- (let ((cur (org-current-level)))
- (if cur (1+ (org-reduced-level cur)) 1))))))
-
- (delete-region (point) (progn (forward-line) (point)))
- (cond
- ((not (file-readable-p file)) (error "Cannot include file %s" file))
-
-
-
- ((member (list file lines) included)
- (error "Recursive file inclusion: %s" file))
- (t
- (cond
- ((eq env 'example)
- (insert
- (let ((ind-str (make-string ind ? ))
- (contents
-
- (replace-regexp-in-string
- "\\(^\\)\\([*]\\|[ \t]*#\\+\\)" ","
- (org-export--prepare-file-contents file lines)
- nil nil 1)))
- (format "%s#+BEGIN_EXAMPLE\n%s%s#+END_EXAMPLE\n"
- ind-str contents ind-str))))
- ((stringp env)
- (insert
- (let ((ind-str (make-string ind ? ))
- (contents
-
- (replace-regexp-in-string
- (if (string= env "org") "\\(^\\)\\(.\\)"
- "\\(^\\)\\([*]\\|[ \t]*#\\+\\)") ","
- (org-export--prepare-file-contents file lines)
- nil nil 1)))
- (format "%s#+BEGIN_SRC %s\n%s%s#+END_SRC\n"
- ind-str env contents ind-str))))
- (t
- (insert
- (with-temp-buffer
- (org-mode)
- (insert
- (org-export--prepare-file-contents file lines ind minlevel))
- (org-export-expand-include-keyword
- (cons (list file lines) included)
- (file-name-directory file))
- (buffer-string))))))))))))
- (defun org-export--prepare-file-contents (file &optional lines ind minlevel)
- "Prepare the contents of FILE for inclusion and return them as a string.
- When optional argument LINES is a string specifying a range of
- lines, include only those lines.
- Optional argument IND, when non-nil, is an integer specifying the
- global indentation of returned contents. Since its purpose is to
- allow an included file to stay in the same environment it was
- created \(i.e. a list item), it doesn't apply past the first
- headline encountered.
- Optional argument MINLEVEL, when non-nil, is an integer
- specifying the level that any top-level headline in the included
- file should have."
- (with-temp-buffer
- (insert-file-contents file)
- (when lines
- (let* ((lines (split-string lines "-"))
- (lbeg (string-to-number (car lines)))
- (lend (string-to-number (cadr lines)))
- (beg (if (zerop lbeg) (point-min)
- (goto-char (point-min))
- (forward-line (1- lbeg))
- (point)))
- (end (if (zerop lend) (point-max)
- (goto-char (point-min))
- (forward-line (1- lend))
- (point))))
- (narrow-to-region beg end)))
-
-
-
- (goto-char (point-min))
- (org-skip-whitespace)
- (beginning-of-line)
- (delete-region (point-min) (point))
- (goto-char (point-max))
- (skip-chars-backward " \r\t\n")
- (forward-line)
- (delete-region (point) (point-max))
-
-
- (when ind
- (unless (eq major-mode 'org-mode) (org-mode))
- (goto-char (point-min))
- (let ((ind-str (make-string ind ? )))
- (while (not (or (eobp) (looking-at org-outline-regexp-bol)))
-
- (unless (and (looking-at org-footnote-definition-re)
- (eq (org-element-type (org-element-at-point))
- 'footnote-definition))
- (insert ind-str))
- (forward-line))))
-
-
-
- (when minlevel
- (unless (eq major-mode 'org-mode) (org-mode))
- (let ((levels (org-map-entries
- (lambda () (org-reduced-level (org-current-level))))))
- (when levels
- (let ((offset (- minlevel (apply 'min levels))))
- (unless (zerop offset)
- (when org-odd-levels-only (setq offset (* offset 2)))
-
-
- (org-map-entries
- (lambda () (if (< offset 0) (delete-char (abs offset))
- (insert (make-string offset ?*))))))))))
- (buffer-string)))
- (defun org-export-read-attribute (attribute element &optional property)
- "Turn ATTRIBUTE property from ELEMENT into a plist.
- When optional argument PROPERTY is non-nil, return the value of
- that property within attributes.
- This function assumes attributes are defined as \":keyword
- value\" pairs. It is appropriate for `:attr_html' like
- properties."
- (let ((attributes
- (let ((value (org-element-property attribute element)))
- (and value
- (read (format "(%s)" (mapconcat 'identity value " ")))))))
- (if property (plist-get attributes property) attributes)))
- (defun org-export-get-caption (element &optional shortp)
- "Return caption from ELEMENT as a secondary string.
- When optional argument SHORTP is non-nil, return short caption,
- as a secondary string, instead.
- Caption lines are separated by a white space."
- (let ((full-caption (org-element-property :caption element)) caption)
- (dolist (line full-caption (cdr caption))
- (let ((cap (funcall (if shortp 'cdr 'car) line)))
- (when cap
- (setq caption (nconc (list " ") (copy-sequence cap) caption)))))))
- (defun org-export-snippet-backend (export-snippet)
- "Return EXPORT-SNIPPET targeted back-end as a symbol.
- Translation, with `org-export-snippet-translation-alist', is
- applied."
- (let ((back-end (org-element-property :back-end export-snippet)))
- (intern
- (or (cdr (assoc back-end org-export-snippet-translation-alist))
- back-end))))
- (defun org-export-collect-footnote-definitions (data info)
- "Return an alist between footnote numbers, labels and definitions.
- DATA is the parse tree from which definitions are collected.
- INFO is the plist used as a communication channel.
- Definitions are sorted by order of references. They either
- appear as Org data or as a secondary string for inlined
- footnotes. Unreferenced definitions are ignored."
- (let* (num-alist
- collect-fn
- (collect-fn
- (function
- (lambda (data)
-
- (org-element-map
- data 'footnote-reference
- (lambda (fn)
- (when (org-export-footnote-first-reference-p fn info)
- (let ((def (org-export-get-footnote-definition fn info)))
- (push
- (list (org-export-get-footnote-number fn info)
- (org-element-property :label fn)
- def)
- num-alist)
-
- (when (eq (org-element-property :type fn) 'standard)
- (funcall collect-fn def)))))
-
-
- info nil 'footnote-definition)))))
- (funcall collect-fn (plist-get info :parse-tree))
- (reverse num-alist)))
- (defun org-export-footnote-first-reference-p (footnote-reference info)
- "Non-nil when a footnote reference is the first one for its label.
- FOOTNOTE-REFERENCE is the footnote reference being considered.
- INFO is the plist used as a communication channel."
- (let ((label (org-element-property :label footnote-reference)))
-
- (if (not label) t
-
-
- (let* (search-refs
- (search-refs
- (function
- (lambda (data)
- (org-element-map
- data 'footnote-reference
- (lambda (fn)
- (cond
- ((string= (org-element-property :label fn) label)
- (throw 'exit fn))
-
-
-
-
- ((eq (org-element-property :type fn) 'standard)
- (funcall search-refs
- (org-export-get-footnote-definition fn info)))))
-
-
- info 'first-match 'footnote-definition)))))
- (eq (catch 'exit (funcall search-refs (plist-get info :parse-tree)))
- footnote-reference)))))
- (defun org-export-get-footnote-definition (footnote-reference info)
- "Return definition of FOOTNOTE-REFERENCE as parsed data.
- INFO is the plist used as a communication channel."
- (let ((label (org-element-property :label footnote-reference)))
- (or (org-element-property :inline-definition footnote-reference)
- (cdr (assoc label (plist-get info :footnote-definition-alist))))))
- (defun org-export-get-footnote-number (footnote info)
- "Return number associated to a footnote.
- FOOTNOTE is either a footnote reference or a footnote definition.
- INFO is the plist used as a communication channel."
- (let* ((label (org-element-property :label footnote))
- seen-refs
- search-ref
- (search-ref
- (function
- (lambda (data)
-
-
- (org-element-map
- data 'footnote-reference
- (lambda (fn)
- (let ((fn-lbl (org-element-property :label fn)))
- (cond
-
- ((and (not fn-lbl) (eq fn footnote))
- (throw 'exit (1+ (length seen-refs))))
-
- ((and label (string= label fn-lbl))
- (throw 'exit (1+ (length seen-refs))))
-
-
-
- ((not fn-lbl) (push 'inline seen-refs) nil)
-
-
-
-
-
-
-
-
-
- ((not (member fn-lbl seen-refs))
- (push fn-lbl seen-refs)
- (funcall search-ref
- (org-export-get-footnote-definition fn info))
- nil))))
-
-
- info 'first-match 'footnote-definition)))))
- (catch 'exit (funcall search-ref (plist-get info :parse-tree)))))
- (defun org-export-get-relative-level (headline info)
- "Return HEADLINE relative level within current parsed tree.
- INFO is a plist holding contextual information."
- (+ (org-element-property :level headline)
- (or (plist-get info :headline-offset) 0)))
- (defun org-export-low-level-p (headline info)
- "Non-nil when HEADLINE is considered as low level.
- INFO is a plist used as a communication channel.
- A low level headlines has a relative level greater than
- `:headline-levels' property value.
- Return value is the difference between HEADLINE relative level
- and the last level being considered as high enough, or nil."
- (let ((limit (plist-get info :headline-levels)))
- (when (wholenump limit)
- (let ((level (org-export-get-relative-level headline info)))
- (and (> level limit) (- level limit))))))
- (defun org-export-get-headline-number (headline info)
- "Return HEADLINE numbering as a list of numbers.
- INFO is a plist holding contextual information."
- (cdr (assoc headline (plist-get info :headline-numbering))))
- (defun org-export-numbered-headline-p (headline info)
- "Return a non-nil value if HEADLINE element should be numbered.
- INFO is a plist used as a communication channel."
- (let ((sec-num (plist-get info :section-numbers))
- (level (org-export-get-relative-level headline info)))
- (if (wholenump sec-num) (<= level sec-num) sec-num)))
- (defun org-export-number-to-roman (n)
- "Convert integer N into a roman numeral."
- (let ((roman '((1000 . "M") (900 . "CM") (500 . "D") (400 . "CD")
- ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
- ( 10 . "X") ( 9 . "IX") ( 5 . "V") ( 4 . "IV")
- ( 1 . "I")))
- (res ""))
- (if (<= n 0)
- (number-to-string n)
- (while roman
- (if (>= n (caar roman))
- (setq n (- n (caar roman))
- res (concat res (cdar roman)))
- (pop roman)))
- res)))
- (defun org-export-get-tags (element info &optional tags)
- "Return list of tags associated to ELEMENT.
- ELEMENT has either an `headline' or an `inlinetask' type. INFO
- is a plist used as a communication channel.
- Select tags (see `org-export-select-tags') and exclude tags (see
- `org-export-exclude-tags') are removed from the list.
- When non-nil, optional argument TAGS should be a list of strings.
- Any tag belonging to this list will also be removed."
- (org-remove-if (lambda (tag) (or (member tag (plist-get info :select-tags))
- (member tag (plist-get info :exclude-tags))
- (member tag tags)))
- (org-element-property :tags element)))
- (defun org-export-get-node-property (property blob &optional inherited)
- "Return node PROPERTY value for BLOB.
- PROPERTY is normalized symbol (i.e. `:cookie-data'). BLOB is an
- element or object.
- If optional argument INHERITED is non-nil, the value can be
- inherited from a parent headline.
- Return value is a string or nil."
- (let ((headline (if (eq (org-element-type blob) 'headline) blob
- (org-export-get-parent-headline blob))))
- (if (not inherited) (org-element-property property blob)
- (let ((parent headline) value)
- (catch 'found
- (while parent
- (when (plist-member (nth 1 parent) property)
- (throw 'found (org-element-property property parent)))
- (setq parent (org-element-property :parent parent))))))))
- (defun org-export-first-sibling-p (headline info)
- "Non-nil when HEADLINE is the first sibling in its sub-tree.
- INFO is a plist used as a communication channel."
- (not (eq (org-element-type (org-export-get-previous-element headline info))
- 'headline)))
- (defun org-export-last-sibling-p (headline info)
- "Non-nil when HEADLINE is the last sibling in its sub-tree.
- INFO is a plist used as a communication channel."
- (not (org-export-get-next-element headline info)))
- (defun org-export-solidify-link-text (s)
- "Take link text S and make a safe target out of it."
- (save-match-data
- (mapconcat 'identity (org-split-string s "[^a-zA-Z0-9_.-]+") "-")))
- (defun org-export-get-coderef-format (path desc)
- "Return format string for code reference link.
- PATH is the link path. DESC is its description."
- (save-match-data
- (cond ((not desc) "%s")
- ((string-match (regexp-quote (concat "(" path ")")) desc)
- (replace-match "%s" t t desc))
- (t desc))))
- (defun org-export-inline-image-p (link &optional rules)
- "Non-nil if LINK object points to an inline image.
- Optional argument is a set of RULES defining inline images. It
- is an alist where associations have the following shape:
- \(TYPE . REGEXP)
- Applying a rule means apply REGEXP against LINK's path when its
- type is TYPE. The function will return a non-nil value if any of
- the provided rules is non-nil. The default rule is
- `org-export-default-inline-image-rule'.
- This only applies to links without a description."
- (and (not (org-element-contents link))
- (let ((case-fold-search t)
- (rules (or rules org-export-default-inline-image-rule)))
- (catch 'exit
- (mapc
- (lambda (rule)
- (and (string= (org-element-property :type link) (car rule))
- (string-match (cdr rule)
- (org-element-property :path link))
- (throw 'exit t)))
- rules)
-
- nil))))
- (defun org-export-resolve-coderef (ref info)
- "Resolve a code reference REF.
- INFO is a plist used as a communication channel.
- Return associated line number in source code, or REF itself,
- depending on src-block or example element's switches."
- (org-element-map
- (plist-get info :parse-tree) '(example-block src-block)
- (lambda (el)
- (with-temp-buffer
- (insert (org-trim (org-element-property :value el)))
- (let* ((label-fmt (regexp-quote
- (or (org-element-property :label-fmt el)
- org-coderef-label-format)))
- (ref-re
- (format "^.*?\\S-.*?\\([ \t]*\\(%s\\)\\)[ \t]*$"
- (replace-regexp-in-string "%s" ref label-fmt nil t))))
-
-
- (when (re-search-backward ref-re nil t)
- (cond
- ((org-element-property :use-labels el) ref)
- ((eq (org-element-property :number-lines el) 'continued)
- (+ (org-export-get-loc el info) (line-number-at-pos)))
- (t (line-number-at-pos)))))))
- info 'first-match))
- (defun org-export-resolve-fuzzy-link (link info)
- "Return LINK destination.
- INFO is a plist holding contextual information.
- Return value can be an object, an element, or nil:
- - If LINK path matches a target object (i.e. <<path>>) or
- element (i.e. \"#+TARGET: path\"), return it.
- - If LINK path exactly matches the name affiliated keyword
- \(i.e. #+NAME: path) of an element, return that element.
- - If LINK path exactly matches any headline name, return that
- element. If more than one headline share that name, priority
- will be given to the one with the closest common ancestor, if
- any, or the first one in the parse tree otherwise.
- - Otherwise, return nil.
- Assume LINK type is \"fuzzy\"."
- (let* ((path (org-element-property :path link))
- (match-title-p (eq (aref path 0) ?*)))
- (cond
-
-
-
- ((and (not match-title-p)
- (loop for target in (plist-get info :target-list)
- when (string= (org-element-property :value target) path)
- return target)))
-
-
- ((and (not match-title-p)
- (org-element-map
- (plist-get info :parse-tree) org-element-all-elements
- (lambda (el)
- (when (string= (org-element-property :name el) path) el))
- info 'first-match)))
-
-
-
-
- (t
- (let ((find-headline
- (function
-
-
- (lambda (name data)
- (org-element-map
- data 'headline
- (lambda (headline)
- (when (string=
- (org-element-property :raw-value headline)
- name)
- headline))
- info 'first-match)))))
-
-
- (or (catch 'exit
- (mapc
- (lambda (parent)
- (when (eq (org-element-type parent) 'headline)
- (let ((foundp (funcall find-headline path parent)))
- (when foundp (throw 'exit foundp)))))
- (org-export-get-genealogy link)) nil)
-
- (funcall find-headline
- (if match-title-p (substring path 1) path)
- (plist-get info :parse-tree))))))))
- (defun org-export-resolve-id-link (link info)
- "Return headline referenced as LINK destination.
- INFO is a plist used as a communication channel.
- Return value can be the headline element matched in current parse
- tree, a file name or nil. Assume LINK type is either \"id\" or
- \"custom-id\"."
- (let ((id (org-element-property :path link)))
-
- (or (org-element-map
- (plist-get info :parse-tree) 'headline
- (lambda (headline)
- (when (or (string= (org-element-property :id headline) id)
- (string= (org-element-property :custom-id headline) id))
- headline))
- info 'first-match)
-
- (cdr (assoc id (plist-get info :id-alist))))))
- (defun org-export-resolve-radio-link (link info)
- "Return radio-target object referenced as LINK destination.
- INFO is a plist used as a communication channel.
- Return value can be a radio-target object or nil. Assume LINK
- has type \"radio\"."
- (let ((path (org-element-property :path link)))
- (org-element-map
- (plist-get info :parse-tree) 'radio-target
- (lambda (radio)
- (when (equal (org-element-property :value radio) path) radio))
- info 'first-match)))
- (defun org-export-get-ordinal (element info &optional types predicate)
- "Return ordinal number of an element or object.
- ELEMENT is the element or object considered. INFO is the plist
- used as a communication channel.
- Optional argument TYPES, when non-nil, is a list of element or
- object types, as symbols, that should also be counted in.
- Otherwise, only provided element's type is considered.
- Optional argument PREDICATE is a function returning a non-nil
- value if the current element or object should be counted in. It
- accepts two arguments: the element or object being considered and
- the plist used as a communication channel. This allows to count
- only a certain type of objects (i.e. inline images).
- Return value is a list of numbers if ELEMENT is an headline or an
- item. It is nil for keywords. It represents the footnote number
- for footnote definitions and footnote references. If ELEMENT is
- a target, return the same value as if ELEMENT was the closest
- table, item or headline containing the target. In any other
- case, return the sequence number of ELEMENT among elements or
- objects of the same type."
-
-
- (unless (eq (org-element-type element) 'keyword)
-
-
- (when (eq (org-element-type element) 'target)
- (setq element
- (loop for parent in (org-export-get-genealogy element)
- when
- (memq
- (org-element-type parent)
- '(footnote-definition footnote-reference headline item
- table))
- return parent)))
- (case (org-element-type element)
-
- (headline (org-export-get-headline-number element info))
-
- (item (let ((struct (org-element-property :structure element)))
- (org-list-get-item-number
- (org-element-property :begin element)
- struct
- (org-list-prevs-alist struct)
- (org-list-parents-alist struct))))
- ((footnote-definition footnote-reference)
- (org-export-get-footnote-number element info))
- (otherwise
- (let ((counter 0))
-
- (org-element-map
- (plist-get info :parse-tree) (or types (org-element-type element))
- (lambda (el)
- (cond
- ((eq element el) (1+ counter))
- ((not predicate) (incf counter) nil)
- ((funcall predicate el info) (incf counter) nil)))
- info 'first-match))))))
- (defun org-export-get-loc (element info)
- "Return accumulated lines of code up to ELEMENT.
- INFO is the plist used as a communication channel.
- ELEMENT is excluded from count."
- (let ((loc 0))
- (org-element-map
- (plist-get info :parse-tree)
- `(src-block example-block ,(org-element-type element))
- (lambda (el)
- (cond
-
- ((eq el element))
-
-
- ((not (memq (org-element-type el) '(src-block example-block))) nil)
- ((let ((linums (org-element-property :number-lines el)))
- (when linums
-
- (let ((lines (org-count-lines
- (org-trim (org-element-property :value el)))))
- (setq loc (if (eq linums 'new) lines (+ loc lines))))))
-
- nil)))
- info 'first-match)
-
- loc))
- (defun org-export-unravel-code (element)
- "Clean source code and extract references out of it.
- ELEMENT has either a `src-block' an `example-block' type.
- Return a cons cell whose CAR is the source code, cleaned from any
- reference and protective comma and CDR is an alist between
- relative line number (integer) and name of code reference on that
- line (string)."
- (let* ((line 0) refs
-
-
- (code (let ((c (replace-regexp-in-string
- "\\`\\([ \t]*\n\\)+" ""
- (replace-regexp-in-string
- "\\(:?[ \t]*\n\\)*[ \t]*\\'" "\n"
- (org-element-property :value element)))))
-
- (unless (or org-src-preserve-indentation
- (org-element-property :preserve-indent element))
- (setq c (org-remove-indentation c)))
-
-
- (if (string= (org-element-property :language element) "org")
- (replace-regexp-in-string "^," "" c)
- (replace-regexp-in-string
- "^\\(,\\)\\(:?\\*\\|[ \t]*#\\+\\)" "" c nil nil 1))))
-
- (label-fmt (regexp-quote
- (or (org-element-property :label-fmt element)
- org-coderef-label-format)))
-
- (with-ref-re
- (format "^.*?\\S-.*?\\([ \t]*\\(%s\\)[ \t]*\\)$"
- (replace-regexp-in-string
- "%s" "\\([-a-zA-Z0-9_ ]+\\)" label-fmt nil t))))
-
- (cons
-
- (org-element-normalize-string
- (mapconcat
- (lambda (loc)
- (incf line)
- (if (not (string-match with-ref-re loc)) loc
-
- (push (cons line (match-string 3 loc)) refs)
- (replace-match "" nil nil loc 1)))
- (org-split-string code "\n") "\n"))
-
- refs)))
- (defun org-export-format-code (code fun &optional num-lines ref-alist)
- "Format CODE by applying FUN line-wise and return it.
- CODE is a string representing the code to format. FUN is
- a function. It must accept three arguments: a line of
- code (string), the current line number (integer) or nil and the
- reference associated to the current line (string) or nil.
- Optional argument NUM-LINES can be an integer representing the
- number of code lines accumulated until the current code. Line
- numbers passed to FUN will take it into account. If it is nil,
- FUN's second argument will always be nil. This number can be
- obtained with `org-export-get-loc' function.
- Optional argument REF-ALIST can be an alist between relative line
- number (i.e. ignoring NUM-LINES) and the name of the code
- reference on it. If it is nil, FUN's third argument will always
- be nil. It can be obtained through the use of
- `org-export-unravel-code' function."
- (let ((--locs (org-split-string code "\n"))
- (--line 0))
- (org-element-normalize-string
- (mapconcat
- (lambda (--loc)
- (incf --line)
- (let ((--ref (cdr (assq --line ref-alist))))
- (funcall fun --loc (and num-lines (+ num-lines --line)) --ref)))
- --locs "\n"))))
- (defun org-export-format-code-default (element info)
- "Return source code from ELEMENT, formatted in a standard way.
- ELEMENT is either a `src-block' or `example-block' element. INFO
- is a plist used as a communication channel.
- This function takes care of line numbering and code references
- inclusion. Line numbers, when applicable, appear at the
- beginning of the line, separated from the code by two white
- spaces. Code references, on the other hand, appear flushed to
- the right, separated by six white spaces from the widest line of
- code."
-
- (let* ((code-info (org-export-unravel-code element))
- (code (car code-info))
- (code-lines (org-split-string code "\n"))
- (refs (and (org-element-property :retain-labels element)
- (cdr code-info)))
-
- (num-start (case (org-element-property :number-lines element)
- (continued (org-export-get-loc element info))
- (new 0)))
- (num-fmt
- (and num-start
- (format "%%%ds "
- (length (number-to-string
- (+ (length code-lines) num-start))))))
-
-
-
- (max-width
- (+ (apply 'max (mapcar 'length code-lines))
- (if (not num-start) 0 (length (format num-fmt num-start))))))
- (org-export-format-code
- code
- (lambda (loc line-num ref)
- (let ((number-str (and num-fmt (format num-fmt line-num))))
- (concat
- number-str
- loc
- (and ref
- (concat (make-string
- (- (+ 6 max-width)
- (+ (length loc) (length number-str))) ? )
- (format "(%s)" ref))))))
- num-start refs)))
- (defun org-export-table-has-special-column-p (table)
- "Non-nil when TABLE has a special column.
- All special columns will be ignored during export."
-
-
-
-
- (let ((special-column-p 'empty))
- (catch 'exit
- (mapc
- (lambda (row)
- (when (eq (org-element-property :type row) 'standard)
- (let ((value (org-element-contents
- (car (org-element-contents row)))))
- (cond ((member value '(("/") ("#") ("!") ("$") ("*") ("_") ("^")))
- (setq special-column-p 'special))
- ((not value))
- (t (throw 'exit nil))))))
- (org-element-contents table))
- (eq special-column-p 'special))))
- (defun org-export-table-has-header-p (table info)
- "Non-nil when TABLE has an header.
- INFO is a plist used as a communication channel.
- A table has an header when it contains at least two row groups."
- (let ((rowgroup 1) row-flag)
- (org-element-map
- table 'table-row
- (lambda (row)
- (cond
- ((> rowgroup 1) t)
- ((and row-flag (eq (org-element-property :type row) 'rule))
- (incf rowgroup) (setq row-flag nil))
- ((and (not row-flag) (eq (org-element-property :type row) 'standard))
- (setq row-flag t) nil)))
- info)))
- (defun org-export-table-row-is-special-p (table-row info)
- "Non-nil if TABLE-ROW is considered special.
- INFO is a plist used as the communication channel.
- All special rows will be ignored during export."
- (when (eq (org-element-property :type table-row) 'standard)
- (let ((first-cell (org-element-contents
- (car (org-element-contents table-row)))))
-
- (or
-
- (equal first-cell '("/"))
-
-
- (and (org-export-table-has-special-column-p
- (org-export-get-parent table-row))
- (member first-cell '(("^") ("_") ("$") ("!"))))
-
- (let ((special-row-p 'empty))
- (catch 'exit
- (mapc
- (lambda (cell)
- (let ((value (org-element-contents cell)))
-
-
- (cond ((not value))
- ((and (not (cdr value))
- (stringp (car value))
- (string-match "\\`<[lrc]?\\([0-9]+\\)?>\\'"
- (car value)))
- (setq special-row-p 'cookie))
- (t (throw 'exit nil)))))
- (org-element-contents table-row))
- (eq special-row-p 'cookie)))))))
- (defun org-export-table-row-group (table-row info)
- "Return TABLE-ROW's group.
- INFO is a plist used as the communication channel.
- Return value is the group number, as an integer, or nil special
- rows and table rules. Group 1 is also table's header."
- (unless (or (eq (org-element-property :type table-row) 'rule)
- (org-export-table-row-is-special-p table-row info))
- (let ((group 0) row-flag)
- (catch 'found
- (mapc
- (lambda (row)
- (cond
- ((and (eq (org-element-property :type row) 'standard)
- (not (org-export-table-row-is-special-p row info)))
- (unless row-flag (incf group) (setq row-flag t)))
- ((eq (org-element-property :type row) 'rule)
- (setq row-flag nil)))
- (when (eq table-row row) (throw 'found group)))
- (org-element-contents (org-export-get-parent table-row)))))))
- (defun org-export-table-cell-width (table-cell info)
- "Return TABLE-CELL contents width.
- INFO is a plist used as the communication channel.
- Return value is the width given by the last width cookie in the
- same column as TABLE-CELL, or nil."
- (let* ((row (org-export-get-parent table-cell))
- (column (let ((cells (org-element-contents row)))
- (- (length cells) (length (memq table-cell cells)))))
- (table (org-export-get-parent-table table-cell))
- cookie-width)
- (mapc
- (lambda (row)
- (cond
-
- ((org-export-table-row-is-special-p row info)
- (let ((value (org-element-contents
- (elt (org-element-contents row) column))))
-
-
- (when (and value
- (not (cdr value))
- (stringp (car value))
- (string-match "\\`<[lrc]?\\([0-9]+\\)?>\\'" (car value))
- (match-string 1 (car value)))
- (setq cookie-width
- (string-to-number (match-string 1 (car value)))))))
-
- ((eq (org-element-property :type row) 'rule))))
- (org-element-contents table))
-
- cookie-width))
- (defun org-export-table-cell-alignment (table-cell info)
- "Return TABLE-CELL contents alignment.
- INFO is a plist used as the communication channel.
- Return alignment as specified by the last alignment cookie in the
- same column as TABLE-CELL. If no such cookie is found, a default
- alignment value will be deduced from fraction of numbers in the
- column (see `org-table-number-fraction' for more information).
- Possible values are `left', `right' and `center'."
- (let* ((row (org-export-get-parent table-cell))
- (column (let ((cells (org-element-contents row)))
- (- (length cells) (length (memq table-cell cells)))))
- (table (org-export-get-parent-table table-cell))
- (number-cells 0)
- (total-cells 0)
- cookie-align)
- (mapc
- (lambda (row)
- (cond
-
-
- ((org-export-table-row-is-special-p row info)
- (let ((value (org-element-contents
- (elt (org-element-contents row) column))))
-
-
- (when (and value
- (not (cdr value))
- (stringp (car value))
- (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'"
- (car value))
- (match-string 1 (car value)))
- (setq cookie-align (match-string 1 (car value))))))
-
- ((eq (org-element-property :type row) 'rule))
-
-
-
-
- ((not cookie-align)
- (let ((value (org-export-data
- (org-element-contents
- (elt (org-element-contents row) column))
- info)))
- (incf total-cells)
- (when (string-match org-table-number-regexp value)
- (incf number-cells))))))
- (org-element-contents table))
-
-
- (cond ((equal cookie-align "l") 'left)
- ((equal cookie-align "r") 'right)
- ((equal cookie-align "c") 'center)
- ((>= (/ (float number-cells) total-cells) org-table-number-fraction)
- 'right)
- (t 'left))))
- (defun org-export-table-cell-borders (table-cell info)
- "Return TABLE-CELL borders.
- INFO is a plist used as a communication channel.
- Return value is a list of symbols, or nil. Possible values are:
- `top', `bottom', `above', `below', `left' and `right'. Note:
- `top' (resp. `bottom') only happen for a cell in the first
- row (resp. last row) of the table, ignoring table rules, if any.
- Returned borders ignore special rows."
- (let* ((row (org-export-get-parent table-cell))
- (table (org-export-get-parent-table table-cell))
- borders)
-
-
-
-
- (let (rule-flag)
- (catch 'exit
- (mapc (lambda (row)
- (cond ((eq (org-element-property :type row) 'rule)
- (setq rule-flag t))
- ((not (org-export-table-row-is-special-p row info))
- (if rule-flag (throw 'exit (push 'above borders))
- (throw 'exit nil)))))
-
- (cdr (memq row (reverse (org-element-contents table)))))
-
-
- (when rule-flag (push 'above borders))
- (push 'top borders)))
-
-
- (let (rule-flag)
- (catch 'exit
- (mapc (lambda (row)
- (cond ((eq (org-element-property :type row) 'rule)
- (setq rule-flag t))
- ((not (org-export-table-row-is-special-p row info))
- (if rule-flag (throw 'exit (push 'below borders))
- (throw 'exit nil)))))
-
- (cdr (memq row (org-element-contents table))))
-
-
- (when rule-flag (push 'below borders))
- (push 'bottom borders)))
-
-
-
-
- (catch 'exit
- (let ((column (let ((cells (org-element-contents row)))
- (- (length cells) (length (memq table-cell cells))))))
- (mapc
- (lambda (row)
- (unless (eq (org-element-property :type row) 'rule)
- (when (equal (org-element-contents
- (car (org-element-contents row)))
- '("/"))
- (let ((column-groups
- (mapcar
- (lambda (cell)
- (let ((value (org-element-contents cell)))
- (when (member value '(("<") ("<>") (">") nil))
- (car value))))
- (org-element-contents row))))
-
-
- (when (or (and (not (zerop column))
- (member (elt column-groups (1- column))
- '(">" "<>")))
- (member (elt column-groups column) '("<" "<>")))
- (push 'left borders))
-
-
- (when (or (and (/= (1+ column) (length column-groups))
- (member (elt column-groups (1+ column))
- '("<" "<>")))
- (member (elt column-groups column) '(">" "<>")))
- (push 'right borders))
- (throw 'exit nil)))))
-
-
- (reverse (org-element-contents table)))))
-
- borders))
- (defun org-export-table-cell-starts-colgroup-p (table-cell info)
- "Non-nil when TABLE-CELL is at the beginning of a row group.
- INFO is a plist used as a communication channel."
-
-
-
- (or (eq (org-element-map
- (org-export-get-parent table-cell)
- 'table-cell 'identity info 'first-match)
- table-cell)
- (memq 'left (org-export-table-cell-borders table-cell info))))
- (defun org-export-table-cell-ends-colgroup-p (table-cell info)
- "Non-nil when TABLE-CELL is at the end of a row group.
- INFO is a plist used as a communication channel."
-
-
- (or (eq (car (last (org-element-contents
- (org-export-get-parent table-cell))))
- table-cell)
- (memq 'right (org-export-table-cell-borders table-cell info))))
- (defun org-export-table-row-starts-rowgroup-p (table-row info)
- "Non-nil when TABLE-ROW is at the beginning of a column group.
- INFO is a plist used as a communication channel."
- (unless (or (eq (org-element-property :type table-row) 'rule)
- (org-export-table-row-is-special-p table-row info))
- (let ((borders (org-export-table-cell-borders
- (car (org-element-contents table-row)) info)))
- (or (memq 'top borders) (memq 'above borders)))))
- (defun org-export-table-row-ends-rowgroup-p (table-row info)
- "Non-nil when TABLE-ROW is at the end of a column group.
- INFO is a plist used as a communication channel."
- (unless (or (eq (org-element-property :type table-row) 'rule)
- (org-export-table-row-is-special-p table-row info))
- (let ((borders (org-export-table-cell-borders
- (car (org-element-contents table-row)) info)))
- (or (memq 'bottom borders) (memq 'below borders)))))
- (defun org-export-table-row-starts-header-p (table-row info)
- "Non-nil when TABLE-ROW is the first table header's row.
- INFO is a plist used as a communication channel."
- (and (org-export-table-has-header-p
- (org-export-get-parent-table table-row) info)
- (org-export-table-row-starts-rowgroup-p table-row info)
- (= (org-export-table-row-group table-row info) 1)))
- (defun org-export-table-row-ends-header-p (table-row info)
- "Non-nil when TABLE-ROW is the last table header's row.
- INFO is a plist used as a communication channel."
- (and (org-export-table-has-header-p
- (org-export-get-parent-table table-row) info)
- (org-export-table-row-ends-rowgroup-p table-row info)
- (= (org-export-table-row-group table-row info) 1)))
- (defun org-export-table-dimensions (table info)
- "Return TABLE dimensions.
- INFO is a plist used as a communication channel.
- Return value is a CONS like (ROWS . COLUMNS) where
- ROWS (resp. COLUMNS) is the number of exportable
- rows (resp. columns)."
- (let (first-row (columns 0) (rows 0))
-
- (org-element-map
- table 'table-row
- (lambda (row)
- (when (eq (org-element-property :type row) 'standard)
- (incf rows)
- (unless first-row (setq first-row row)))) info)
-
- (org-element-map first-row 'table-cell (lambda (cell) (incf columns)) info)
-
- (cons rows columns)))
- (defun org-export-table-cell-address (table-cell info)
- "Return address of a regular TABLE-CELL object.
- TABLE-CELL is the cell considered. INFO is a plist used as
- a communication channel.
- Address is a CONS cell (ROW . COLUMN), where ROW and COLUMN are
- zero-based index. Only exportable cells are considered. The
- function returns nil for other cells."
- (let* ((table-row (org-export-get-parent table-cell))
- (table (org-export-get-parent-table table-cell)))
-
- (unless (or (org-export-table-row-is-special-p table-row info)
- (and (org-export-table-has-special-column-p table)
- (eq (car (org-element-contents table-row)) table-cell)))
- (cons
-
- (let ((row-count 0))
- (org-element-map
- table 'table-row
- (lambda (row)
- (cond ((eq (org-element-property :type row) 'rule) nil)
- ((eq row table-row) row-count)
- (t (incf row-count) nil)))
- info 'first-match))
-
- (let ((col-count 0))
- (org-element-map
- table-row 'table-cell
- (lambda (cell)
- (if (eq cell table-cell) col-count (incf col-count) nil))
- info 'first-match))))))
- (defun org-export-get-table-cell-at (address table info)
- "Return regular table-cell object at ADDRESS in TABLE.
- Address is a CONS cell (ROW . COLUMN), where ROW and COLUMN are
- zero-based index. TABLE is a table type element. INFO is
- a plist used as a communication channel.
- If no table-cell, among exportable cells, is found at ADDRESS,
- return nil."
- (let ((column-pos (cdr address)) (column-count 0))
- (org-element-map
-
- (let ((row-pos (car address)) (row-count 0))
- (org-element-map
- table 'table-row
- (lambda (row)
- (cond ((eq (org-element-property :type row) 'rule) nil)
- ((= row-count row-pos) row)
- (t (incf row-count) nil)))
- info 'first-match))
- 'table-cell
- (lambda (cell)
- (if (= column-count column-pos) cell
- (incf column-count) nil))
- info 'first-match)))
- (defun org-export-collect-headlines (info &optional n)
- "Collect headlines in order to build a table of contents.
- INFO is a plist used as a communication channel.
- When optional argument N is an integer, it specifies the depth of
- the table of contents. Otherwise, it is set to the value of the
- last headline level. See `org-export-headline-levels' for more
- information.
- Return a list of all exportable headlines as parsed elements."
- (unless (wholenump n) (setq n (plist-get info :headline-levels)))
- (org-element-map
- (plist-get info :parse-tree)
- 'headline
- (lambda (headline)
-
- (let ((relative-level (org-export-get-relative-level headline info)))
- (unless (> relative-level n) headline)))
- info))
- (defun org-export-collect-elements (type info &optional predicate)
- "Collect referenceable elements of a determined type.
- TYPE can be a symbol or a list of symbols specifying element
- types to search. Only elements with a caption are collected.
- INFO is a plist used as a communication channel.
- When non-nil, optional argument PREDICATE is a function accepting
- one argument, an element of type TYPE. It returns a non-nil
- value when that element should be collected.
- Return a list of all elements found, in order of appearance."
- (org-element-map
- (plist-get info :parse-tree) type
- (lambda (element)
- (and (org-element-property :caption element)
- (or (not predicate) (funcall predicate element))
- element))
- info))
- (defun org-export-collect-tables (info)
- "Build a list of tables.
- INFO is a plist used as a communication channel.
- Return a list of table elements with a caption."
- (org-export-collect-elements 'table info))
- (defun org-export-collect-figures (info predicate)
- "Build a list of figures.
- INFO is a plist used as a communication channel. PREDICATE is
- a function which accepts one argument: a paragraph element and
- whose return value is non-nil when that element should be
- collected.
- A figure is a paragraph type element, with a caption, verifying
- PREDICATE. The latter has to be provided since a \"figure\" is
- a vague concept that may depend on back-end.
- Return a list of elements recognized as figures."
- (org-export-collect-elements 'paragraph info predicate))
- (defun org-export-collect-listings (info)
- "Build a list of src blocks.
- INFO is a plist used as a communication channel.
- Return a list of src-block elements with a caption."
- (org-export-collect-elements 'src-block info))
- (defun org-export-get-parent (blob)
- "Return BLOB parent or nil.
- BLOB is the element or object considered."
- (org-element-property :parent blob))
- (defun org-export-get-genealogy (blob)
- "Return full genealogy relative to a given element or object.
- BLOB is the element or object being considered.
- Ancestors are returned from closest to farthest, the last one
- being the full parse tree."
- (let (genealogy (parent blob))
- (while (setq parent (org-element-property :parent parent))
- (push parent genealogy))
- (nreverse genealogy)))
- (defun org-export-get-parent-headline (blob)
- "Return BLOB parent headline or nil.
- BLOB is the element or object being considered."
- (let ((parent blob))
- (while (and (setq parent (org-element-property :parent parent))
- (not (eq (org-element-type parent) 'headline))))
- parent))
- (defun org-export-get-parent-element (object)
- "Return first element containing OBJECT or nil.
- OBJECT is the object to consider."
- (let ((parent object))
- (while (and (setq parent (org-element-property :parent parent))
- (memq (org-element-type parent) org-element-all-objects)))
- parent))
- (defun org-export-get-parent-table (object)
- "Return OBJECT parent table or nil.
- OBJECT is either a `table-cell' or `table-element' type object."
- (let ((parent object))
- (while (and (setq parent (org-element-property :parent parent))
- (not (eq (org-element-type parent) 'table))))
- parent))
- (defun org-export-get-previous-element (blob info)
- "Return previous element or object.
- BLOB is an element or object. INFO is a plist used as
- a communication channel. Return previous exportable element or
- object, a string, or nil."
- (let (prev)
- (catch 'exit
- (mapc (lambda (obj)
- (cond ((eq obj blob) (throw 'exit prev))
- ((memq obj (plist-get info :ignore-list)))
- (t (setq prev obj))))
- (org-element-contents (org-export-get-parent blob))))))
- (defun org-export-get-next-element (blob info)
- "Return next element or object.
- BLOB is an element or object. INFO is a plist used as
- a communication channel. Return next exportable element or
- object, a string, or nil."
- (catch 'found
- (mapc (lambda (obj)
- (unless (memq obj (plist-get info :ignore-list))
- (throw 'found obj)))
- (cdr (memq blob (org-element-contents (org-export-get-parent blob)))))
- nil))
- (defconst org-export-dictionary
- '(("Author"
- ("ca" :default "Autor")
- ("cs" :default "Autor")
- ("da" :default "Ophavsmand")
- ("de" :default "Autor")
- ("eo" :html "Aŭtoro")
- ("es" :default "Autor")
- ("fi" :html "Tekijä")
- ("fr" :default "Auteur")
- ("hu" :default "Szerzõ")
- ("is" :html "Höfundur")
- ("it" :default "Autore")
- ("ja" :html "著者" :utf-8 "著者")
- ("nl" :default "Auteur")
- ("no" :default "Forfatter")
- ("nb" :default "Forfatter")
- ("nn" :default "Forfattar")
- ("pl" :default "Autor")
- ("ru" :html "Автор" :utf-8 "Автор")
- ("sv" :html "Författare")
- ("uk" :html "Автор" :utf-8 "Автор")
- ("zh-CN" :html "作者" :utf-8 "作者")
- ("zh-TW" :html "作者" :utf-8 "作者"))
- ("Date"
- ("ca" :default "Data")
- ("cs" :default "Datum")
- ("da" :default "Dato")
- ("de" :default "Datum")
- ("eo" :default "Dato")
- ("es" :default "Fecha")
- ("fi" :html "Päivämäärä")
- ("hu" :html "Dátum")
- ("is" :default "Dagsetning")
- ("it" :default "Data")
- ("ja" :html "日付" :utf-8 "日付")
- ("nl" :default "Datum")
- ("no" :default "Dato")
- ("nb" :default "Dato")
- ("nn" :default "Dato")
- ("pl" :default "Data")
- ("ru" :html "Дата" :utf-8 "Дата")
- ("sv" :default "Datum")
- ("uk" :html "Дата" :utf-8 "Дата")
- ("zh-CN" :html "日期" :utf-8 "日期")
- ("zh-TW" :html "日期" :utf-8 "日期"))
- ("Equation"
- ("fr" :ascii "Equation" :default "Équation"))
- ("Figure")
- ("Footnotes"
- ("ca" :html "Peus de pàgina")
- ("cs" :default "Pozn\xe1mky pod carou")
- ("da" :default "Fodnoter")
- ("de" :html "Fußnoten")
- ("eo" :default "Piednotoj")
- ("es" :html "Pies de página")
- ("fi" :default "Alaviitteet")
- ("fr" :default "Notes de bas de page")
- ("hu" :html "Lábjegyzet")
- ("is" :html "Aftanmálsgreinar")
- ("it" :html "Note a piè di pagina")
- ("ja" :html "脚注" :utf-8 "脚注")
- ("nl" :default "Voetnoten")
- ("no" :default "Fotnoter")
- ("nb" :default "Fotnoter")
- ("nn" :default "Fotnotar")
- ("pl" :default "Przypis")
- ("ru" :html "Сноски" :utf-8 "Сноски")
- ("sv" :default "Fotnoter")
- ("uk" :html "Примітки"
- :utf-8 "Примітки")
- ("zh-CN" :html "脚注" :utf-8 "脚注")
- ("zh-TW" :html "腳註" :utf-8 "腳註"))
- ("List of Listings"
- ("fr" :default "Liste des programmes"))
- ("List of Tables"
- ("fr" :default "Liste des tableaux"))
- ("Listing %d:"
- ("fr"
- :ascii "Programme %d :" :default "Programme nº %d :"
- :latin1 "Programme %d :"))
- ("Listing %d: %s"
- ("fr"
- :ascii "Programme %d : %s" :default "Programme nº %d : %s"
- :latin1 "Programme %d : %s"))
- ("See section %s"
- ("fr" :default "cf. section %s"))
- ("Table %d:"
- ("fr"
- :ascii "Tableau %d :" :default "Tableau nº %d :" :latin1 "Tableau %d :"))
- ("Table %d: %s"
- ("fr"
- :ascii "Tableau %d : %s" :default "Tableau nº %d : %s"
- :latin1 "Tableau %d : %s"))
- ("Table of Contents"
- ("ca" :html "Índex")
- ("cs" :default "Obsah")
- ("da" :default "Indhold")
- ("de" :default "Inhaltsverzeichnis")
- ("eo" :default "Enhavo")
- ("es" :html "Índice")
- ("fi" :html "Sisällysluettelo")
- ("fr" :ascii "Sommaire" :default "Table des matières")
- ("hu" :html "Tartalomjegyzék")
- ("is" :default "Efnisyfirlit")
- ("it" :default "Indice")
- ("ja" :html "目次" :utf-8 "目次")
- ("nl" :default "Inhoudsopgave")
- ("no" :default "Innhold")
- ("nb" :default "Innhold")
- ("nn" :default "Innhald")
- ("pl" :html "Spis treści")
- ("ru" :html "Содержание"
- :utf-8 "Содержание")
- ("sv" :html "Innehåll")
- ("uk" :html "Зміст" :utf-8 "Зміст")
- ("zh-CN" :html "目录" :utf-8 "目录")
- ("zh-TW" :html "目錄" :utf-8 "目錄"))
- ("Unknown reference"
- ("fr" :ascii "Destination inconnue" :default "Référence inconnue")))
- "Dictionary for export engine.
- Alist whose CAR is the string to translate and CDR is an alist
- whose CAR is the language string and CDR is a plist whose
- properties are possible charsets and values translated terms.
- It is used as a database for `org-export-translate'. Since this
- function returns the string as-is if no translation was found,
- the variable only needs to record values different from the
- entry.")
- (defun org-export-translate (s encoding info)
- "Translate string S according to language specification.
- ENCODING is a symbol among `:ascii', `:html', `:latex', `:latin1'
- and `:utf-8'. INFO is a plist used as a communication channel.
- Translation depends on `:language' property. Return the
- translated string. If no translation is found, try to fall back
- to `:default' encoding. If it fails, return S."
- (let* ((lang (plist-get info :language))
- (translations (cdr (assoc lang
- (cdr (assoc s org-export-dictionary))))))
- (or (plist-get translations encoding)
- (plist-get translations :default)
- s)))
- (defvar org-export-dispatch-menu-entries nil
- "List of menu entries available for `org-export-dispatch'.
- This variable shouldn't be set directly. Set-up :menu-entry
- keyword in either `org-export-define-backend' or
- `org-export-define-derived-backend' instead.")
- (defun org-export-dispatch ()
- "Export dispatcher for Org mode.
- It provides an access to common export related tasks in a buffer.
- Its interface comes in two flavours: standard and expert. While
- both share the same set of bindings, only the former displays the
- valid keys associations. Set `org-export-dispatch-use-expert-ui'
- to switch to one or the other.
- Return an error if key pressed has no associated command."
- (interactive)
- (let* ((input (org-export-dispatch-ui (list org-export-initial-scope)
- nil
- org-export-dispatch-use-expert-ui))
- (action (car input))
- (optns (cdr input)))
- (case action
-
- (publish-current-file (org-e-publish-current-file (memq 'force optns)))
- (publish-current-project
- (org-e-publish-current-project (memq 'force optns)))
- (publish-choose-project
- (org-e-publish (assoc (org-icompleting-read
- "Publish project: "
- org-e-publish-project-alist nil t)
- org-e-publish-project-alist)
- (memq 'force optns)))
- (publish-all (org-e-publish-all (memq 'force optns)))
- (otherwise
- (funcall action
- (memq 'subtree optns)
- (memq 'visible optns)
- (memq 'body optns))))))
- (defun org-export-dispatch-ui (options first-key expertp)
- "Handle interface for `org-export-dispatch'.
- OPTIONS is a list containing current interactive options set for
- export. It can contain any of the following symbols:
- `body' toggles a body-only export
- `subtree' restricts export to current subtree
- `visible' restricts export to visible part of buffer.
- `force' force publishing files.
- FIRST-KEY is the key pressed to select the first level menu. It
- is nil when this menu hasn't been selected yet.
- EXPERTP, when non-nil, triggers expert UI. In that case, no help
- buffer is provided, but indications about currently active
- options are given in the prompt. Moreover, \[?] allows to switch
- back to standard interface."
- (let* ((fontify-key
- (lambda (key &optional access-key)
-
-
-
-
-
- (if (or (eq access-key t) (eq access-key first-key))
- (org-add-props key nil 'face 'org-warning)
- (org-no-properties key))))
-
-
- (backends (sort (copy-sequence org-export-dispatch-menu-entries)
- (lambda (a b) (< (car a) (car b)))))
-
-
-
- (allowed-keys
- (nconc (list ?1 ?2 ?3 ?4)
- (mapcar 'car
- (if (not first-key) backends
- (nth 2 (assq first-key backends))))
- (cond ((eq first-key ?P) (list ?f ?p ?x ?a))
- ((not first-key) (list ?P)))
- (when expertp (list ??))
- (list ?q)))
-
- (help
- (unless expertp
- (concat
-
- (format "Options
- [%s] Body only: %s [%s] Visible only: %s
- [%s] Export scope: %s [%s] Force publishing: %s\n\n"
- (funcall fontify-key "1" t)
- (if (memq 'body options) "On " "Off")
- (funcall fontify-key "2" t)
- (if (memq 'visible options) "On " "Off")
- (funcall fontify-key "3" t)
- (if (memq 'subtree options) "Subtree" "Buffer ")
- (funcall fontify-key "4" t)
- (if (memq 'force options) "On " "Off"))
-
- (mapconcat
- (lambda (entry)
- (let ((top-key (car entry)))
- (concat
- (format "[%s] %s\n"
- (funcall fontify-key (char-to-string top-key))
- (nth 1 entry))
- (let ((sub-menu (nth 2 entry)))
- (unless (functionp sub-menu)
-
- (let ((index -1))
- (concat
- (mapconcat
- (lambda (sub-entry)
- (incf index)
- (format (if (zerop (mod index 2)) " [%s] %-24s"
- "[%s] %s\n")
- (funcall fontify-key
- (char-to-string (car sub-entry))
- top-key)
- (nth 1 sub-entry)))
- sub-menu "")
- (when (zerop (mod index 2)) "\n"))))))))
- backends "\n")
-
- (format "\n[%s] Publish
- [%s] Current file [%s] Current project
- [%s] Choose project [%s] All projects\n\n"
- (funcall fontify-key "P")
- (funcall fontify-key "f" ?P)
- (funcall fontify-key "p" ?P)
- (funcall fontify-key "x" ?P)
- (funcall fontify-key "a" ?P))
- (format "\[%s] %s"
- (funcall fontify-key "q" t)
- (if first-key "Main menu" "Exit")))))
-
- (standard-prompt (unless expertp "Export command: "))
- (expert-prompt
- (when expertp
- (format
- "Export command (Options: %s%s%s%s) [%s]: "
- (if (memq 'body options) (funcall fontify-key "b" t) "-")
- (if (memq 'subtree options) (funcall fontify-key "s" t) "-")
- (if (memq 'visible options) (funcall fontify-key "v" t) "-")
- (if (memq 'force options) (funcall fontify-key "f" t) "-")
- (concat allowed-keys)))))
-
-
- (if expertp
- (org-export-dispatch-action
- expert-prompt allowed-keys backends options first-key expertp)
- (save-window-excursion
- (delete-other-windows)
- (unwind-protect
- (progn
- (with-current-buffer
- (get-buffer-create "*Org Export Dispatcher*")
- (erase-buffer)
- (save-excursion (insert help)))
- (org-fit-window-to-buffer
- (display-buffer "*Org Export Dispatcher*"))
- (org-export-dispatch-action
- standard-prompt allowed-keys backends options first-key expertp))
- (and (get-buffer "*Org Export Dispatcher*")
- (kill-buffer "*Org Export Dispatcher*")))))))
- (defun org-export-dispatch-action
- (prompt allowed-keys backends options first-key expertp)
- "Read a character from command input and act accordingly.
- PROMPT is the displayed prompt, as a string. ALLOWED-KEYS is
- a list of characters available at a given step in the process.
- BACKENDS is a list of menu entries. OPTIONS, FIRST-KEY and
- EXPERTP are the same as defined in `org-export-dispatch-ui',
- which see.
- Toggle export options when required. Otherwise, return value is
- a list with action as CAR and a list of interactive export
- options as CDR."
- (let ((key (let ((k (read-char-exclusive prompt)))
-
-
- (if (< k 27) (+ k 96) k))))
- (cond
-
-
- ((not (memq key allowed-keys))
- (org-export-dispatch-ui options first-key expertp))
-
-
- ((eq key ?q) (if (not first-key) (error "Export aborted")
- (org-export-dispatch-ui options nil expertp)))
-
-
- ((eq key ??) (org-export-dispatch-ui options first-key nil))
-
- ((memq key '(?1 ?2 ?3 ?4))
- (org-export-dispatch-ui
- (let ((option (case key (?1 'body) (?2 'visible) (?3 'subtree)
- (?4 'force))))
- (if (memq option options) (remq option options)
- (cons option options)))
- first-key expertp))
-
-
- ((or first-key
- (and (eq first-key ?P) (memq key '(?f ?p ?x ?a)))
- (functionp (nth 2 (assq key backends))))
- (cons (cond
- ((not first-key) (nth 2 (assq key backends)))
-
-
- ((eq first-key ?P)
- (case key
- (?f 'publish-current-file)
- (?p 'publish-current-project)
- (?x 'publish-choose-project)
- (?a 'publish-all)))
- (t (nth 2 (assq key (nth 2 (assq first-key backends))))))
- options))
-
- (t (org-export-dispatch-ui options key expertp)))))
- (provide 'org-export)
|