From 6c831dc78f091a3e62562172eec96c27b2231102 Mon Sep 17 00:00:00 2001 From: Nero <41307858+nero@users.noreply.github.com> Date: Sat, 2 Jul 2022 20:55:45 +0000 Subject: [PATCH] Improve multi-language support --- README.md | 10 ++++------ md2html | 18 +++++++++++++++++- md2tex | 8 ++++++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 39baa3c..20d530f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Many people don't like to read markdown. ## Usage -These are AWK scripts. The input markdown goes into stdin. The output document comes out of stdout. @@ -24,12 +23,12 @@ pdflatex README.tex If the awk option `stylesheet` is given, the HTML document can made prettier with external CSS. ``` -awk -v stylesheet='/style.css' -f md2html < README.md +md2html -v stylesheet='/style.css' < README.md ``` ## Supported constructs -- Headlines up to level 3 +- Headlines up to level 6 - Paragraphs - Bold, italic and inline monospace - Image figures if they are in the same folder @@ -40,7 +39,6 @@ awk -v stylesheet='/style.css' -f md2html < README.md ## Not supported - Tables -- More than 3 levels of nested headlines - Images from an url -- Inline images -- Unicode characters (im german, maybe i will add it for umlauts) +- Images inline in text +- Unicode characters (im german, maybe i will add at least umlaut support) diff --git a/md2html b/md2html index 8a4cd40..d4f1107 100755 --- a/md2html +++ b/md2html @@ -7,6 +7,7 @@ BEGIN { prefix = "html/body/" print("") level("html/head") + meta["lang"]="en" toc=0 } @@ -46,7 +47,11 @@ function level(new) { for (i = common; i < length(a); i++) { if (a[i]) { - printf("%0" indent "s<%s>\n", "", a[i]) + if (a[i]=="body") { + printf("%0" indent "s<%s lang=%s>\n", "", a[i], meta["lang"]) + } else { + printf("%0" indent "s<%s>\n", "", a[i]) + } indent = indent + 2 } } @@ -188,6 +193,9 @@ awk ' BEGIN { indent = 4 level("summary") + lang="en" + tocname["en"]="Table of contents" + tocname["de"]="Inhaltsverzeichnis" } function oneliner(tag, str, args) { @@ -242,6 +250,14 @@ function inline(text) { return text } +/