Commits

camlspotter committed 910ec02

confluence inlined block

  • Participants
  • Parent commits 56ccfd4

Comments (0)

Files changed (1)

File extensions/confluenceWriter.py

         else:
             self.contents.extend([elem])
 
+    def append_inlined(self, elem):
+        if isstring(elem):
+            self.append_string(elem)
+        else:
+            self.append_string(elem.try_inline())
+
     def elem_to_string(self, indent, x):
         if isinstance(x, unicode) or isinstance(x,str):
             return ' ' * indent + re.sub(r'[\n\r]+', ' ', x)
             print "HOGE" + str(self.contents)
             inline_failure()
 
+class PAREN(Block):
+    def __init__(self, parent, open, close):
+        Block.__init__(self, parent)
+        self.open = open
+        self.close = close
+
+    def to_string(self, indent):
+        try:
+            return ' ' * indent + self.open + self.try_inline_internal() + self.close
+        except InlineFailure:
+            return ' ' * indent + self.open + '\n' + Block.to_string(self, indent+2) + '\n' + ' ' * indent + self.close
+
+    def try_inline(self):
+        return self.open + self.try_inline_internal() + self.close
+
 class HTML(Block):
     def __init__(self, parent, tag):
         Block.__init__(self, parent)
         parent = self.block.parent
         self.block = parent
 
+    def new_inlined_block(self, blockCls, *args):
+        b = blockCls(self.block, *args)
+        self.block = b
+
+    def end_inlined_block(self):
+        b = self.block
+        parent = self.block.parent
+        self.block = parent
+        self.block.append(b.try_inline())
+
     def visit_document(self, node):
         pass
     def depart_document(self, node):
 #        self.add_text('*')
 
     def visit_literal(self, node):
-        self.add_text('<tt>')
+        self.new_inlined_block(PAREN, '{{', '}}') 
     def depart_literal(self, node):
-        self.add_text('</tt>')
+        self.end_inlined_block()
 
 #    def visit_subscript(self, node):
 #        self.add_text('_')