Commits

camlspotter  committed 8c49c16

inline => one_line

  • Participants
  • Parent commits aca1df0

Comments (0)

Files changed (1)

File extensions/hatenaWriter.py

 def isstring(s):
     return isinstance(s, unicode) or isinstance(s, str)
 
-class InlineFailure(Exception):
+class OneLineFailure(Exception):
     """hoge"""
 
-def inline_failure():
-    raise InlineFailure
+def one_line_failure():
+    raise OneLineFailure
 
 class Block():
     def __init__(self, parent):
     def to_string(self, indent):
         return '\n'.join([self.elem_to_string(indent, x) for x in self.contents])
 
-    def try_inline_elem(self, elem): # string is special and thus stupid
+    def try_one_line_elem(self, elem): # string is special and thus stupid
         if isstring(elem):
             return elem
         else:
-            return elem.try_inline()
+            return elem.try_one_line()
 
-    def try_inline_internal(self):
-        return ' '.join([self.try_inline_elem(elem) for elem in self.contents])
+    def try_one_line_internal(self):
+        return ' '.join([self.try_one_line_elem(elem) for elem in self.contents])
 
-    # may raise InlineFailure
-    def try_inline(self):
-        inline_failure()
+    # may raise OneLineFailure
+    def try_one_line(self):
+        one_line_failure()
         
 class Title(Block):
     def __init__(self, parent, level):
         self.level = level
 
     def to_string(self, indent):
-        return '*' * self.level + ' ' + Block.try_inline_internal(self)
+        return '*' * self.level + ' ' + Block.try_one_line_internal(self)
 
 class Par(Block):
     def __init__(self, parent):
         else:
             return ' ' * indent + '<p>\n' + Block.to_string(self, indent)
 
-    def try_inline(self):
+    def try_one_line(self):
         if self.is_first_item():
-            return self.try_inline_internal()
+            return self.try_one_line_internal()
         else:
             print "HOGE" + str(self.contents)
-            inline_failure()
+            one_line_failure()
 
 class HTML(Block):
     def __init__(self, parent, tag):
 
     def to_string(self, indent):
         try:
-            return ' ' * indent + '<' + self.tag() + '>' + self.try_inline_internal() + '</' + self.tag() + '>'
-        except InlineFailure:
+            return ' ' * indent + '<' + self.tag() + '>' + self.try_one_line_internal() + '</' + self.tag() + '>'
+        except OneLineFailure:
             return ' ' * indent + '<' + self.tag() + '>\n' + Block.to_string(self, indent+2) + '\n' + ' ' * indent + '</' + self.tag() + '>' 
 
 class LItem(HTML):