|call script|grep "cl1-Text" etc/Testdocument.tex|
|call script|mdoc-extract etc/Testdocument.xml cl1.1|
|call script|grep "cl1.1-Text" etc/Testdocument.tex|
+|call script|grep "cl1.1+cl2-Text" etc/Testdocument.tex|
|call script|mdoc-extract etc/Testdocument.xml cl2|
|call script|grep "cl2-Text" etc/Testdocument.tex|
+|call script|grep "cl1.1+cl2-Text" etc/Testdocument.tex|
<text include="cl1">cl1-Text</text>
<text exclude="cl1">nicht cl1-text</text>
<text include="cl1.1">cl1.1-Text</text>
+<text include="cl1.1:cl2">cl1.1+cl2-Text</text>
<text exclude="cl1.1">nicht cl1.1-text</text>
<text include="cl2">cl2-Text</text>
<text exclude="cl2">nicht cl2-text</text>
.\" Manpage for mdoc-extract.
.\" Contact mail@wagnertech.de to correct errors or typos.
-.TH MDOC-EXTRACT 1 "27 Jan 2020" Linux "Linux Manual"
+.TH MDOC-EXTRACT 1 "08 Dez 2021" Linux "Linux Manual"
.SH NAME
mdoc-extract \- mdoc extraction tool
.SH SYNOPSIS
.I exclude
tags. The value of these tags is the class name from which on this advise is valid. Advices are inherited
to subclasses. Subclasses are named by "base.sub". Advices for "base.sub" are valid for CLASS=base.sub,
-CLASS=base.sub.subsub and so on, but not for CLASS=base.
+CLASS=base.sub.subsub and so on, but not for CLASS=base. There can also be more than one class in an advice.
+These classes are separated by ":".
.TP
\fBINPUT\fR
Input xml file name
.nf
<document>
<text>This text is always used</text>
- <text include="base.sub">This text appears only in "base.sub"
- and its subclasses</text>
+ <text include="base.sub:otherbase">This text appears only in "base.sub"
+ and its subclasses as well as for "otherbase" and its subclasses.</text>
<text exclude="base.sub">This text does not appear in "base.sub"
and its subclasses</text>
</document>
'''
from mutil.XmlExtractor import XmlExtractor
from mutil import XmlExtractor as XMLE
-from pickle import NONE, FALSE, TRUE
def eval_class(classs, item):
item_hira = item.split(".")
return False,ilen
return True,ilen
+def eval_attribute(classs, attribute):
+ for item in attribute.split(":"):
+ ret,ilen = eval_class(classs, item)
+ if ret:
+ return True,ilen
+ return False,ilen
+
def is_for_print(classs, attrs):
include = False
exclude = False
ilen = 0
elen = 0
if "include" in attrs:
- include,ilen = eval_class(classs, attrs["include"])
+ include,ilen = eval_attribute(classs, attrs["include"])
if "exclude" in attrs:
- exclude,elen = eval_class(classs, attrs["exclude"])
+ exclude,elen = eval_attribute(classs, attrs["exclude"])
if ilen > 0 and elen == 0:
return include
elif elen > 0 and ilen == 0: