text_ids.append(text_node.id) end_paragraph_node = sdoc.sdoc2.node_store.create_inline_node( 'end_paragraph') text_ids.append(end_paragraph_node.id) # Checking where we need to add paragraph. if len(text_ids): if list_of_texts[-1]: text_ids.pop() return text_ids # ------------------------------------------------------------------------------------------------------------------ def prune_whitespace(self, leading=False, trailing=False): """ Method for removing white space in text. :param bool leading: if True, remove whitespaces from start. :param bool trailing: if True, remove whitespaces from end. """ if leading: self._argument = self._argument.lstrip() if trailing: self._argument = self._argument.rstrip() self._argument = re.sub(r'\s+', ' ', self._argument) # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('TEXT', TextNode)
""" super().__init__('end_paragraph', options, argument) # ------------------------------------------------------------------------------------------------------------------ def is_block_command(self): """ Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def is_inline_command(self): """ Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def prepare_content_tree(self): """ Not implemented for end paragraph nodes. """ raise NotImplementedError() # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('end_paragraph', EndParagraphNode)
def __init__(self, options, argument): """ Object constructor. :param dict[str,str] options: The options of this section. :param str argument: The title of this section. """ super().__init__('sub3section', options, argument) # ------------------------------------------------------------------------------------------------------------------ def get_command(self): """ Returns the command of this node, i.e. sub3section. :rtype: str """ return 'sub3section' # ------------------------------------------------------------------------------------------------------------------ def get_hierarchy_level(self, parent_hierarchy_level=-1): """ Returns 5. :rtype: int """ return 5 # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('sub3section', Sub3SectionNode) node_store.register_inline_command('subsubsubsection', Sub3SectionNode)
""" Object constructor. :param dict[str,str] options: The options of this section. :param str argument: The title of this section. """ super().__init__('sub3section', options, argument) # ------------------------------------------------------------------------------------------------------------------ def get_command(self): """ Returns the command of this node, i.e. sub3section. :rtype: str """ return 'sub3section' # ------------------------------------------------------------------------------------------------------------------ def get_hierarchy_level(self, parent_hierarchy_level=-1): """ Returns 5. :rtype: int """ return 5 # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('sub3section', Sub3SectionNode) node_store.register_inline_command('subsubsubsection', Sub3SectionNode)
Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def prune_whitespace(self): """ Removes spaces from end of a paragraph. """ first = self._child_nodes[0] last = self._child_nodes[-1] for node_id in self._child_nodes: node = node_store.in_scope(node_id) if isinstance(node, TextNode): if node.id == first: node.prune_whitespace(leading=True) if node.id == last: node.prune_whitespace(trailing=True) if node.id != last and node.id != first: node.prune_whitespace() node_store.out_scope(node) # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('paragraph', ParagraphNode)
""" return False # ------------------------------------------------------------------------------------------------------------------ def is_inline_command(self): """ Returns True. :rtype: bool """ return True # ------------------------------------------------------------------------------------------------------------------ def prepare_content_tree(self): """ Method which checks if all child nodes is phrasing. """ for node_id in self._child_nodes: node = node_store.in_scope(node_id) if isinstance(node, TextNode): node.prune_whitespace() # if not node.is_phrasing(): # raise RuntimeError("Node: id:%s, %s is not phrasing" % (str(node.id), node.name)) node_store.out_scope(node) # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('item', ItemNode)
def is_block_command(self): """ Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def is_inline_command(self): """ Returns True. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def is_phrasing(self): """ Returns True. :rtype: bool """ return True # ---------------------------------------------------------------------------------------------------------------------- node_store.register_block_command('unknown', UnknownNode) node_store.register_inline_command('unknown', UnknownNode)
def __init__(self, options, argument): """ Object constructor. :param dict[str,str] options: The options of this section. :param str argument: The title of this section. """ super().__init__('section', options, argument) # ------------------------------------------------------------------------------------------------------------------ def get_command(self): """ Returns the command of this node, i.e. section. :rtype: str """ return 'section' # ------------------------------------------------------------------------------------------------------------------ def get_hierarchy_level(self, parent_hierarchy_level=-1): """ Returns 2. :rtype: int """ return 2 # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('section', SectionNode)
# ------------------------------------------------------------------------------------------------------------------ def is_phrasing(self): """ Returns True. :rtype: bool """ return True # ------------------------------------------------------------------------------------------------------------------ def is_inline_command(self): """ Returns True. :rtype: bool """ return True # ------------------------------------------------------------------------------------------------------------------ def is_block_command(self): """ Returns False. :rtype: bool """ return False # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('hyperlink', HyperlinkNode)
# ------------------------------------------------------------------------------------------------------------------ def __init__(self, options, argument): """ Object constructor. :param dict[str,str] options: The options of this section. :param str argument: The title of this section. """ super().__init__('section', options, argument) # ------------------------------------------------------------------------------------------------------------------ def get_command(self): """ Returns the command of this node, i.e. section. :rtype: str """ return 'section' # ------------------------------------------------------------------------------------------------------------------ def get_hierarchy_level(self, parent_hierarchy_level=-1): """ Returns 2. :rtype: int """ return 2 # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('section', SectionNode)
sdoc.sdoc2.node_store.store_node(text_node) text_ids.append(text_node.id) end_paragraph_node = sdoc.sdoc2.node_store.create_inline_node('end_paragraph') text_ids.append(end_paragraph_node.id) # Checking where we need to add paragraph. if len(text_ids): if list_of_texts[-1]: text_ids.pop() return text_ids # ------------------------------------------------------------------------------------------------------------------ def prune_whitespace(self, leading=False, trailing=False): """ Method for removing white space in text. :param bool leading: if True, remove whitespaces from start. :param bool trailing: if True, remove whitespaces from end. """ if leading: self._argument = self._argument.lstrip() if trailing: self._argument = self._argument.rstrip() self._argument = re.sub(r'\s+', ' ', self._argument) # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('TEXT', TextNode)
def __init__(self, options, argument): """ Object constructor. :param dict[str,str] options: The options of this chapter. :param str argument: The title of this chapter. """ super().__init__('chapter', options, argument) # ------------------------------------------------------------------------------------------------------------------ def get_command(self): """ Returns the command of this node, i.e. chapter. :rtype: str """ return 'chapter' # ------------------------------------------------------------------------------------------------------------------ def get_hierarchy_level(self, parent_hierarchy_level=-1): """ Returns 1. :rtype: int """ return 1 # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('chapter', ChapterNode)
# ------------------------------------------------------------------------------------------------------------------ def is_block_command(self): """ Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def is_inline_command(self): """ Returns True. :rtype: bool """ return True # ------------------------------------------------------------------------------------------------------------------ def is_phrasing(self): """ Returns True. :rtype: bool """ return True # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('smile', SmileNode)
return False # ------------------------------------------------------------------------------------------------------------------ def is_inline_command(self): """ Returns True. :rtype: bool """ return True # ------------------------------------------------------------------------------------------------------------------ def prepare_content_tree(self): """ Method which checks if all child nodes is phrasing. """ for node_id in self._child_nodes: node = node_store.in_scope(node_id) if isinstance(node, TextNode): node.prune_whitespace() # if not node.is_phrasing(): # raise RuntimeError("Node: id:%s, %s is not phrasing" % (str(node.id), node.name)) node_store.out_scope(node) # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('item', ItemNode)
""" Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def prune_whitespace(self): """ Removes spaces from end of a paragraph. """ first = self._child_nodes[0] last = self._child_nodes[-1] for node_id in self._child_nodes: node = node_store.in_scope(node_id) if isinstance(node, TextNode): if node.id == first: node.prune_whitespace(leading=True) if node.id == last: node.prune_whitespace(trailing=True) if node.id != last and node.id != first: node.prune_whitespace() node_store.out_scope(node) # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('paragraph', ParagraphNode)
super().__init__('end_paragraph', options, argument) # ------------------------------------------------------------------------------------------------------------------ def is_block_command(self): """ Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def is_inline_command(self): """ Returns False. :rtype: bool """ return False # ------------------------------------------------------------------------------------------------------------------ def prepare_content_tree(self): """ Not implemented for end paragraph nodes. """ raise NotImplementedError() # ---------------------------------------------------------------------------------------------------------------------- node_store.register_inline_command('end_paragraph', EndParagraphNode)