コード例 #1
0
ファイル: write_html.py プロジェクト: h-2/seqan-1
 def _translateLink(self, a_node):
     if not a_node.attrs.get('href', '').startswith('seqan:'):
         return
     target = a_node.attrs['href'][6:]
     target_path, target_title, target_obj = self.path_converter.convert(
         target)
     # Shorten path title if not manually specified.
     if (a_node.children and a_node.plainText == target_title
             and self.doc.local_name_counter.get(target_title, 1) <= 1):
         short_title = proc_doc.splitSecondLevelEntry(target_title)[1]
         a_node.children = [proc_doc.TextNode(text=short_title)]
     if target_title:
         target_title = proc_doc.TextNode(text=target_title)
     else:
         target_title = proc_doc.TextNode(text=target)
     # TODO(holtgrew): Catch target_title being None, target_path not found!
     if target_path is not None:
         if target_obj:
             a_node.attrs['data-lang-entity'] = target_obj.kind
         a_node.attrs['href'] = target_path
         if not a_node.children:
             a_node.addChild(target_title)
     else:
         class_attr = a_node.attrs.get('class', '')
         if class_attr:
             class_attr += ' '
         class_attr += 'error'
         a_node.attrs['class'] = class_attr
         if a_node.attrs.get('href'):
             del a_node.attrs['href']
コード例 #2
0
ファイル: write_html.py プロジェクト: h-2/seqan-1
 def transLink(entity_name, text=None):
     if not text:
         text = entity_name
     text_node = proc_doc.TextNode(type='a')
     text_node.attrs['href'] = 'seqan:%s' % entity_name
     text_node.children = [proc_doc.TextNode(text=text)]
     link_converter.visit(text_node)
     return transTextNode(text_node, path_mgr)
コード例 #3
0
ファイル: write_html.py プロジェクト: weese/seqan
 def _translateLink(self, a_node):
     if not a_node.attrs.get('href', '').startswith('seqan:'):
         return
     target = a_node.attrs['href'][6:]
     target_path, target_title, target_obj = self.path_converter.convert(target)
     if target_title:
         target_title = proc_doc.TextNode(text=target_title)
     else:
         target_title = proc_doc.TextNode(text=target)
     # TODO(holtgrew): Catch target_title being None, target_path not found!
     if target_path is not None:
         if target_obj:
             a_node.attrs['data-lang-entity'] = target_obj.kind
         a_node.attrs['href'] = target_path
         if not a_node.children:
             a_node.addChild(target_title)
     else:
         class_attr = a_node.attrs.get('class', '')
         if class_attr:
             class_attr += ' '
         class_attr += 'error'
         a_node.attrs['class'] = class_attr
         if a_node.attrs.get('href'):
             del a_node.attrs['href']