From b40c73f27a0d96de6ddb52c53a7dcb877ef36202 Mon Sep 17 00:00:00 2001 From: skaller Date: Tue, 20 Feb 2024 05:03:19 +1100 Subject: [PATCH] Extens flx_pretty to partially support fdoc files. --- src/packages/flx_web.fdoc | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/packages/flx_web.fdoc b/src/packages/flx_web.fdoc index 2867ff959..0a55aa530 100644 --- a/src/packages/flx_web.fdoc +++ b/src/packages/flx_web.fdoc @@ -101,6 +101,20 @@ xlat_felix = Dynlink::load-plugin-func2 [bool * string, string, string] ( dll-name="flx2html", setup-str="", entry-point="flx2html" ); +interface fdoc_t { + whatami : 1 -> string; + html_raw : 1 -> string; + html_page : 1 -> string; + html_title: 1 -> string; + mathjax_required: 1 -> bool; +} + + +var xlat_fdoc = Dynlink::load-plugin-func2 [fdoc_t, string, string] ( + dll-name="fdoc2html", setup-str="", entry-point="fdoc2html" + ); + + var filename = System::argv 1; if filename == "--style" do @@ -110,8 +124,26 @@ elif filename == "--mathjax" do else eprintln$ "Formatting file " + filename; var b = load filename; - needs_mathjax', txt := xlat_felix (b,""); - println$ "
\n"+txt+"\n
"; + match Filename::get_extension filename with + | ".flx" => + def var needs_mathjax', var txt = xlat_felix (b,""); + println$ "
\n"+txt+"\n
"; + | ".fdoc" => + var result = xlat_fdoc (b, filename); + var needs_mathjax = #(result.mathjax_required); + var html = #(result.html_page); + var title = #(result.html_title); + val data = + ""+Css4Html::flx_head+ + if needs_mathjax then mathjax else "" endif + + if title != "" then ""+title+"" else "" endif + + ""+ + html+ + "\n\r" + ; + println$ data+"\n"; + | _ => println "NO FILE"; + endmatch; done @