[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-657499-105":3,"detail-sidebar-cat-0-en-105":81,"doc-detail-657499-en":130},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","a-markdown-interpreter-for-tex-version-3162","A Markdown Interpreter for TEX - Version 3.16.2","","Technical documentation for the Markdown package that converts CommonMark markup into TeX commands. The system is provided as a Lua module and as plain TeX, LaTeX, and ConTeXt macro packages, supporting direct typesetting of TeX documents containing markdown. The documentation explains prerequisites and required Lua/TEX modules, then details exposed interfaces (Lua, plain TeX, LaTeX, ConTeXt) and the internal implementation across each interface, including caching and parsing components.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/a-markdown-interpreter-for-tex-version-3162/657499/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/a-markdown-interpreter-for-tex-version-3162/657499.png","ImageObject",300,407,{"name":42,"@type":43},"Logic","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-29","2026-10-26",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",7,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What does the Markdown package do with CommonMark markup?","Question",{"text":63,"@type":64},"It converts CommonMark markup into TeX commands so TeX documents containing markdown can be typeset directly.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"Which interfaces does the package expose?",{"text":68,"@type":64},"It provides a Lua interface and macro interfaces for plain TeX, LaTeX, and ConTeXt.",{"name":70,"@type":61,"acceptedAnswer":71},"What prerequisites are required for the Lua and plain TeX parts?",{"text":72,"@type":64},"The Lua part depends on modules such as LPeg and MD5 (and supports additional libraries), while the plain TeX part requires a loaded plain TeX/format plus Lua prerequisites and packages like expl3.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},657499,1793030777,{"code":4,"msg":82,"data":83},"success",[84,88,92,96,101,105,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":85,"show_sort_weight":86,"slug":87},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":89,"show_sort_weight":90,"slug":91},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":93,"show_sort_weight":94,"slug":95},"Exam",70,"exam",{"id":97,"doc_module":4,"doc_module_name":25,"category_name":98,"show_sort_weight":99,"slug":100},5,"Comic",60,"comic",{"id":102,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":103,"slug":104},6,50,"technology",{"id":55,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":97,"slug":129},19,"General","general",{"code":4,"msg":82,"data":131},{"doc_id":79,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":102,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":144,"read_time":145},1099513958762,"https://ap-avatar.wpscdn.com/avatar/1000023916a998db790?x-image-process=image/resize,m_fixed,w_180,h_180&k=1784791008015729253","A Markdown Interpreter for TEX  \nVít Starý Novotný, Andrej Genčur Version 3.16.2-0-gdb771a1b[witiko@mail.muni.cz](witiko@mail.muni.cz) 2026-09-29  \nContents  \n1 Introduction 1  \n1.1 Requirements . . . . . . . 2  \n1.2 Feedback . . . . . . . . . 6  \n1.3 Acknowledgements .... 7  \n2 Interfaces 7  \n2. 1 Lua Interface . . . . . . . 7  \n2.2 Plain TEX Interface .... 57  \n2.3 LATEX Interface ...... 168  \n2.4 ConTEXt Interface .... 177  \n3 Implementation 182  \n3.1 Lua Implementation ... 182  \n3.2 Plain TEX Implementation429  \n3.3 LATEX Implementation .. 477  \n3.4 ConTEXt Implementation 525  \nReferences 536  \nIndex 538  \nList of Figures  \n1 A block diagram of the Markdown package .................. 8  \n2 A sequence diagram of typesetting a document using the TEX interface .. 53  \n3 A sequence diagram of typesetting a document using the Lua CLI ..... 54  \n4 An example directed graph ........................... 83  \n5 An example mindmap .............................. 84  \n6 An example UML sequence diagram ...................... 85  \n7 The banner of the Markdown package ..................... 86  \n8 A pushdown automaton that recognizes TEX comments ........... 303  \n1 Introduction  \nThe Markdown package 1 converts CommonMark2 markup to TEX commands. The functionality is provided both as a Lua module and as plain TEX, LATEX, and ConTEXt macro packages that can be used to directly typeset TEX documents containing markdown markup. Unlike other converters, the Markdown package does not require any external programs, and makes it easy to redefine how each and every markdown element is rendered. Creative abuse of the markdown syntax is encouraged.   \nThis document is a technical documentation for the Markdown package. It consists of three sections. This section introduces the package and outlines its prerequisites.  \n1 See [https://ctan.org/pkg/markdown](https://ctan.org/pkg/markdown).  \n2 See [https://commonmark.org/](https://commonmark.org/) .  \nSection 2 describes the interfaces exposed by the package. Section 3 describes the implementation of the package. The technical documentation contains only a limited number of tutorials and code examples. You can find more of these in the user manual.3  \n1 local metadata = {  \n2 version = \"(((VERSION)))\",  \n3 comment = \"A module for the conversion from markdown \"  \n4 . . \"to plain TeX\",  \n5 author = \"John MacFarlane, Hans Hagen, Vít Starý Novotný, \"  \n6 . . \"Andrej Genčur\",  \n7 copyright = {\"2009-2016 John MacFarlane, Hans Hagen\",  \n8 \"2016-2026 Vít Starý Novotný, Andrej Genčur\"},  \n9 license = \"LPPL 1 .3c\"  \n10 }  \n11  \n12 if not modules then modules = { } end  \n13 modules['markdown'] = metadata  \n1.1 Requirements  \nThis section gives an overview of all resources required by the package.  \n1.1.1 Lua Requirements  \nThe Lua part of the package requires that the following Lua modules are available from within the LuaTEX engine (though not necessarily in the LuaMetaTEX engine) .  \nLPeg ě 0.10 A pattern-matching library for the writing of recursive descent parsers via the Parsing Expression Grammars ( pegs) . It is used by the Lunamark library to parse the markdown input. LPeg ě 0.10 is included in LuaTEX ě 0.72.0 (TEX Live ě 2013) .  \n14 local lpeg = require(\"lpeg\")  \nMD5 A library that provides md5 crypto functions. It is used by the Lunamark library to compute the digest of the input for caching purposes. MD5 is included in all releases of LuaTEX (TEX Live ě 2008) .  \n15 local md5 = require(\"md5\")  \nKpathsea A package that implements the loading of third-party Lua libraries and looking up files in the TEX directory structure.  \n3 See [http://mirrors.ctan.org/macros/generic/markdown/markdown.html](http://mirrors.ctan.org/macros/generic/markdown/markdown.html).  \nOnly load the package outside the ConTEXt format, where we can use the resolversapi [1, Section 11.5] .  \n16 if resolvers == nil then  \n17 (function()  \nIf Kpathsea has not been loaded before or if LuaTEX has not yet been initialized, configure Kpa","cbCaiobrm1gaMeus","https://ap.wps.com/l/cbCaiobrm1gaMeus","pdf",1510943,548,"English","# Introduction\n## Requirements\n## Interfaces\n## Implementation","[{\"question\":\"What does the Markdown package do with CommonMark markup?\",\"answer\":\"It converts CommonMark markup into TeX commands so TeX documents containing markdown can be typeset directly.\"},{\"question\":\"Which interfaces does the package expose?\",\"answer\":\"It provides a Lua interface and macro interfaces for plain TeX, LaTeX, and ConTeXt.\"},{\"question\":\"What prerequisites are required for the Lua and plain TeX parts?\",\"answer\":\"The Lua part depends on modules such as LPeg and MD5 (and supports additional libraries), while the plain TeX part requires a loaded plain TeX/format plus Lua prerequisites and packages like expl3.\"}]","A Markdown Interpreter for TEX - Version 3.16.2 | PDF",1792981474,1381]