!|test.util.CallScript|
+|call script|!-rm etc/Testdocument.tex |true-!|
|call script|mdoc-extract etc/Testdocument.xml default|
|call script|grep "nicht cl1-text" etc/Testdocument.tex|
|call script|mdoc-extract etc/Testdocument.xml cl1|
|call script|grep "cl2-Text" etc/Testdocument.tex|
|call script|grep "cl1.1+cl2-Text" etc/Testdocument.tex|
+mdoc-extract writes into named file
+
+!|test.util.CallScript|
+|call script|!-rm out.txt |true-!|
+|call script|mdoc-extract etc/Testdocument.xml default out.txt|
+|call script|ls out.txt|
--- /dev/null
+<mdoc format="html" extension="html">
+<global>
+ <b><pre><![CDATA[<b>]]></pre><post><![CDATA[</b>]]></post></b>
+ <p><pre><![CDATA[<p>]]></pre><post><![CDATA[</p>]]></post></p>
+</global>
+<hierarchical>
+<newsletter>
+ <pre><![CDATA[<!DOCTYPE html>
+<html>
+<head>
+<title>Newsletter Maxjosefstift</title>
+<meta charset="UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
+<style>
+body {font-family: "Times New Roman", Georgia, Serif;}
+h1, h2, h3, h4, h5, h6 {
+ font-family: "Playfair Display";
+ letter-spacing: 5px;
+}
+</style>
+</head>
+<body>
+
+
+<!-- Header -->
+
+<!-- Page content -->
+<div class="w3-content" style="max-width:700px">
+ <img class="w3-image" src="https://mcusercontent.com/c49e44a2c411ce9d2e4c53eec/images/aea1f0bf-cdd7-4e4a-96c4-e7f561987359.jpg" alt="MJS Logo" width="700" height="350">
+
+<!-- Einleitung -->
+<div class="w3-container w3-padding-64" id="contact">]]></pre>
+ <post><![CDATA[</div>
+
+<!-- Footer -->
+<footer class="w3-center w3-light-grey w3-padding-32">
+<p>Impressum:<br/>
+ OStDin Kristina Kalb-Heubisch, Schulleiterin<br/>
+ Dr. Dunja Jaber, PR-Team Gymnasium Max-Josef-Stift<br/>
+ Mühlbaurstr. 15<br/>
+ 81677 München<br/>
+ Telefon: 089-998435-0<br/>
+ Telefax: 089-998435-155<br/>
+ E-Mail: sekretariat@maxjosefstift.de<br/>
+ Nutzungsbedingungen siehe https://www.maxjosefstift.de/impressum2.html</p>
+<p>Sie möchten diesen Newsletter nicht mehr erhalten?</p>
+<p>Eine Email genügt, zu adressieren an newsletter@maxjosefstift.de mit dem Betreff „Abmelden“.</p>
+ <p>Powered by <a href="http://www.w3schools.com/w3css/default.asp" title="W3.CSS" target="_blank" class="w3-hover-text-green">w3.css</a> and
+ <a href="http://wagnertech.de">WagnerTech UG</a></p>
+</footer>
+
+</body>
+</html>]]></post>
+ <h1><pre><![CDATA[<h2 class="w3-center">]]></pre><post><![CDATA[</h2>]]></post></h1>
+ <img><pre><![CDATA[<img width="700" src="$src"/>]]></pre></img>
+</newsletter>
+</hierarchical>
+</mdoc>
+
from mdoc import extractor
import re
-usage = 'mdoc-extract <source> <class>'
+usage = 'mdoc-extract <source> <class> [target]'
def command_dispatch(args):
# check runtime parameters
if len(args) < 2:
- raise RuntimeError("mdoc-extract needs 2 arguments.")
+ raise RuntimeError("mdoc-extract needs 2/3 arguments.")
file = args[0]
classs = args[1]
- target = re.sub(r'\..*', '.tex', file)
+ if len(args) == 3:
+ target = args[2]
+ else:
+ target = re.sub(r'\..*', '.tex', file)
return extractor.extract(file, classs, target)