pydev-ts
authorMichael Wagner <michael@wagnertech.de>
Tue, 12 Nov 2019 15:49:09 +0000 (16:49 +0100)
committerMichael Wagner <michael@wagnertech.de>
Tue, 12 Nov 2019 15:49:09 +0000 (16:49 +0100)
doc/.dummy [new file with mode: 0644]
python/mDoc/mdoc.py
python/mDoc/mdoc/worker.py
python/mDoc/tpl/latex.tpl

diff --git a/doc/.dummy b/doc/.dummy
new file mode 100644 (file)
index 0000000..e69de29
index 2386fec..5c4fd5f 100755 (executable)
@@ -7,8 +7,6 @@ Created on 02.08.2019
 
 import sys
 from mdoc import worker
-from test import xxx
-from test.xxx import MyClass
 
 usage = 'mdoc <source> <target-format>'
 
index b98ad57..120bf5e 100644 (file)
@@ -7,37 +7,49 @@ Created on 02.08.2019
 from mutil.XmlExtractor import XmlExtractor
 from mutil import XmlExtractor as XMLE
 import re
-
+'''
 def outfirst(outfile, tpllayer, attrs, value):
     if tpllayer["value"]:
         ostr = tpllayer["value"]
         if "$value" in ostr:
-            ostr = re.sub(r"\$value", value, ostr)
+            ostr = re.sub(r"\$value", value, ostr, flags=re.MULTILINE)
         print (ostr, end="", file=outfile)
 
 def outlast(outfile, tpllayer, attrs, value):
     if tpllayer["value"]:
         print (file=outfile)
-
+'''
 def process_file_layer(source, outfile, globals, hierarc):
 
 
     (ctl,elem, value, attrs) = source.extractElement(XMLE.EC_BEG)
     while ctl != XMLE.EC_END:
-        item = None
+        items = None
         nexthiera = {}
         if elem in hierarc:
-            item = hierarc[elem]
-            nexthiera = hierarc[elem]["items"]
+            items = hierarc[elem]
         elif elem in globals:
-            item = globals[elem]
+            items = globals[elem]
         else:
             print ("Warning: No mapping for item:" +elem)
-        if item:
-            outfirst(outfile, item, attrs, value)
-        process_file_layer(source, outfile, globals, nexthiera)
-        if item:
-            outlast(outfile, item, attrs, value)
+        if items:
+            # search for "first"
+            for item in items:
+                if "position" in item["attrs"]:
+                    if item["attrs"]["position"] == "first":
+                        print (item["value"], end="", file=outfile)
+            # proceed working
+            for item in items:
+                if not "position" in item["attrs"]:
+                    nexthiera = item["items"]
+                    if value:
+                        print (value, end="", file=outfile)
+                    process_file_layer(source, outfile, globals, nexthiera)
+            # search for "last"
+            for item in items:
+                if "position" in item["attrs"]:
+                    if item["attrs"]["position"] == "last":
+                        print (item["value"], end="", file=outfile)
         (ctl,elem, value, attrs) = source.extractElement(ctl)
         
 def convert (file, format):
@@ -48,11 +60,11 @@ def convert (file, format):
     # read whole template
     tple = XmlExtractor()
     tpl = tple.readFile("tpl/"+format+".tpl")
-    globals = tpl["mdoc"]["items"]["global"]["items"]
-    hierarc = tpl["mdoc"]["items"]["hierarchical"]["items"]
+    globals = tpl["mdoc"][0]["items"]["global"][0]["items"]
+    hierarc = tpl["mdoc"][0]["items"]["hierarchical"][0]["items"]
     
     # open output file
-    ext = tpl["mdoc"]["attrs"]["extension"]
+    ext = tpl["mdoc"][0]["attrs"]["extension"]
     outname = re.sub(r"\.xml", "."+ext, file)
     outfile = open(outname, "w")
     #print ("hallo", file=outfile)
index fbcbbbb..266d650 100644 (file)
@@ -4,9 +4,8 @@
 <hierarchical>
 <article>
 <test>testdata</test>
-<articleinfo>
-<![CDATA[
-\documentclass[12pt, a4paper, parskip=half]{scrartcl}
+<articleinfo position="first">
+<![CDATA[\documentclass[12pt, a4paper, parskip=half]{scrartcl}
 \usepackage[utf8]{inputenc}% muss zum Editor passen -> http://texwelt.de/wissen/fragen/2656/
 \usepackage[T1]{fontenc}
 \usepackage[ngerman]{babel}
 
 \setcounter{secnumdepth}{0} % keine Kapitelnummerierung
 ]]>
-<title>
-<![CDATA[\title{$value}]]>
-</title>
+</articleinfo>
+<articleinfo>
+       <title position="first"><![CDATA[\title{]]></title>
+       <title/>
+       <title position="last"><![CDATA[}]]></title>
+</articleinfo>
+<articleinfo position="last">
+<![CDATA[
+\begin{document}
+\pagenumbering{gobble} % no page numbers
+
+\maketitle
+]]>
 </articleinfo>
 </article>
 </hierarchical>