In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Commit 7db02298 authored by eckhart's avatar eckhart

- more natural xml-representation

parent e7dda4f5
......@@ -530,15 +530,18 @@ class Node(collections.abc.Sized):
for child in self.children:
subtree = child._tree_repr(tab, open_fn, close_fn, data_fn,
density, inline, inline_fn)
subtree = [subtree] if inline else subtree.split('\n')
content.append((sep + usetab).join(s for s in subtree))
if subtree:
subtree = [subtree] if inline else subtree.split('\n')
content.append((sep + usetab).join(s for s in subtree))
return head + usetab + (sep + usetab).join(content) + tail
res = cast(str, self.result) # safe, because if there are no children, result is a string
if not inline and not head:
res = res.strip()
if density & 1 and res.find('\n') < 0: # and head[0] == "<":
# except for XML, add a gap between opening statement and content
gap = ' ' if not inline and head and head.rstrip()[-1:] != '>' else ''
return head.rstrip() + gap + data_fn(self.result) + tail.lstrip()
return head.rstrip() + gap + data_fn(res) + tail.lstrip()
else:
return head + '\n'.join([usetab + data_fn(s) for s in res.split('\n')]) + tail
......
......@@ -682,7 +682,7 @@ class XMLCompiler(Compiler):
def on_document(self, node):
self.tree.omit_tags.add('CharData')
self.tree.inline_tags.update({'to', 'from', 'heading', 'body', 'remark'})
return self.fallback_compiler(node)
def extract_attributes(self, node_sequence):
......
......@@ -255,6 +255,20 @@ class TestSerialization:
tree3 = parse_sxpr('(A `(attr "value") `(attr2 "value2") "B")')
assert tree.as_sxpr() == tree3.as_sxpr()
def test_sexpr(self):
tree = parse_sxpr('(A (B "C") (D "E"))')
s = tree.as_sxpr()
assert s == '(A\n (B\n "C"\n )\n (D\n "E"\n )\n)', s
tree = parse_sxpr('(A (B (C "D") (E "F")) (G "H"))')
s = tree.as_sxpr()
assert s == '(A\n (B\n (C\n "D"\n )\n (E\n "F"\n )' \
'\n )\n (G\n "H"\n )\n)', s
tree = parse_sxpr('(A (B (C "D\nX") (E "F")) (G " H \n Y "))')
s = tree.as_sxpr()
assert s == '(A\n (B\n (C\n "D"\n "X"\n )' \
'\n (E\n "F"\n )\n )\n (G\n " H "\n " Y "\n )\n)', s
def test_xml_inlining(self):
tree = parse_sxpr('(A (B "C") (D "E"))')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment