Is there a FPC component to convert Markdown to XHTML? lazarus / 62-General ---------------------------------------------------------------------- bulrush · 2016-06-27 18:09 I was just curious if there was a non-visual component that converted Markdown to XHTML for making EPUB books. Shelling out to pandoc for each of 33 chapters is time-consuming. I tried to do it with regular expressions and discovered that's not the way to do it. Is anyone up for the challenge? ---------------------------------------------------------------------- Leledumbo · 2016-06-27 20:24 Might be fun, but I won't give any guarantee. I still need to finish my lightweight mustache implementation. Shouldn't be difficult since the language is line oriented and kinda simple, I haven't checked its regularity so I'm not sure if a regular expression is enough to match the whole language. But a state machine with backtracking stack should do. ---------------------------------------------------------------------- bulrush · 2016-06-28 15:21 Here's Multimarkdown: http://fletcher.github.io/MultiMarkdown-5/. I'd start with Multimarkdown because it has more features. MMD is a superset of Markdown. If you would be so kind, be sure to output XHTML, not HTML, as XHTML is used to make EPUB books. XHTML tag reference: http://www.webreference.com/xml/reference/xhtml.html. Some variations on Markdown use CSS like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i # header 1 {color:#c0c0c0; font-weight:bold;} which is converted to XHTML: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i

header 1

but I was unable to find a link for that, yet. Online markdown editor here: http://dillinger.io/. I don't know what flavor of Markdown they use. Another online MD editor: http://markdownlivepreview.com/. For reference, the Perl module to convert Markdown to XHTML: https://metacpan.org/pod/Text::Markup. Some people have talked about using a parse tree to convert MD to XHTML. I have never taken a class about parse trees. Is this a good method of converting MD to XHTML? Do you have a link for a beginner to learn how to use parse trees? I do not have the skill to make the component myself but I'd like to learn a bit about parsing. ---------------------------------------------------------------------- bulrush · 2016-06-28 15:42 If you get around to doing it I will be glad to help you test it. ---------------------------------------------------------------------- Leledumbo · 2016-06-28 18:41 Quote from: bulrush on June 28, 2016, 05:21:30 pmSome people have talked about using a parse tree to convert MD to XHTML. I have never taken a class about parse trees. Is this a good method of converting MD to XHTML? Do you have a link for a beginner to learn how to use parse trees? I do not have the skill to make the component myself but I'd like to learn a bit about parsing. Two of my favorite "books": http://compilers.iecc.com/crenshaw/https://www.inf.ethz.ch/personal/wi rth/CompilerConstruction/index.htmlNeither of them uses syntax tree (I don't want to use term parse tree as parse tree is closer to the grammar instead of the source code, while syntax tree is the real tree resembling the source code) in the final code, but chapter 16 of the 2nd link explains (with sample code) how it could be implemented. Language processing, be it compilation, transpilation, conversion, whatsoever, can be simply viewed as a tree transformation. In the case of Markdown, if you decide to implement it this way, is simply: Markdown input as string -> Markdown syntax tree data structure -> (X)HTML syntax tree data structure -> (X)HTML output as string. ---------------------------------------------------------------------- M.A.R.C. · 2018-02-22 06:23 Only for reference, Here: https://github.com/mriscoc/fpc-markdown there is a basic Markdown to HTML converter native for FPC and with code examples written in Lazarus.