Beispiel #1
0
 def visit_definition_list_item( self, node ):
     # First create a container frame for the whole item. Its first child
     # carries the term and the classifiers, the second child frame carry the definition.
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'standard' )
     self.parent = self.currentFrame = newFrame
     # Create frame for term and classifiers
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'glossary_term' )
     self.currentFrame = newFrame
     content = getContentManager( self.styles, newFrame )
     # assemble the string of item and classifiers, first the term:
     term_str = node[0][0].astext() + ': '
     # now any classifiers:
     if len( node ) > 2:
         term_str += u'('
         term_str += u'; '.join( n[0].astext() for n in node[1:-1] )
         term_str += u')'
     GenericText( content, text = term_str, translator = self.styles['translator']['default'] )
Beispiel #2
0
 def visit_subtitle( self, node ):
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'heading0' )
     if self.currentFrame == self.parent: # probably supervluous as subtitle can only occur after doctitle
         newFrame.update( y_hook = 'top' )
     else:
         newFrame.update( y_hook = 'bottom' )
     self.currentFrame = newFrame
     self.current_content = getContentManager( self.styles, self.currentFrame )
     self.make_refs( self.current_content, node )
Beispiel #3
0
 def visit_section( self, node ):
     self.section_level += 1
     # create container frame to allow clean insertion
     # of blank lines before the next section.
     newFrame = getFrame( self.styles, self.currentFrame, self.parent,
         style = 'section_container' + str( self.section_level ) )
     if self.parent is not self.currentFrame:
         newFrame.update( x_anchor = self.currentFrame )
     self.currentFrame = self.parent = newFrame
     self.make_refs( None, node )
Beispiel #4
0
    def visit_transition( self, node ):
        # prepare string
        s = self.styles['transition']['default']['text']
        if len( s ) == 1:
            s *= int( self.parent.width * self.styles['transition']['default']['ratio'] )

            # frame for the hor line
        newFrame = getFrame( self.styles, self.currentFrame, self.parent )
        self.currentFrame = newFrame
        self.current_content = getContentManager( self.styles, self.currentFrame )
        GenericText( self.current_content, text = s,
            translator = self.styles['transition']['default']['translator'] )
Beispiel #5
0
    def visit_list_item( self, node ):
        item_style = 'list_item'
        if isinstance( node.parent, nodes.bullet_list ):
            # is this a TOC?
            if 'contents' in self.get_classes( node ):
                item_style = 'toc_item'
                # autonumbered?
                if 'auto-toc' in node.parent['classes']:
                    itemtext = node[0][0][0][0].astext()
                else: # empty place holder frame
                    itemtext = u' '
            else:
                itemtext = node.parent['bullet']

        else: # enumerated list
            itemtext = node.parent['prefix']
            func = utils.__dict__['to_' + node.parent['enumtype']]
            number = node.parent.index( node ) + 1
            if 'start' in node.parent:
                number += node.parent['start'] - 1
            itemtext += func( number )
            itemtext += node.parent['suffix']

        # frame for the TOC or simplly list item (the section number if present,
        newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = item_style )
        self.currentFrame = newFrame
        if node is node.parent[0]:
            newFrame.update( y_hook = 'top' )

        content = getContentManager( self.styles, newFrame, )
        content.wrapper_cfg = None # this is ugly, I know
        GenericText( content, text = itemtext, translator = self.styles.translator.default)


        # create a container for the list item body:
        newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'list_body' )
        newFrame.update( x_anchor = self.currentFrame )
        self.currentFrame = self.parent = newFrame
Beispiel #6
0
    def visit_title( self, node ):
        if isinstance( node.parent, nodes.section ):
            frame_style = 'section_title' + str( self.section_level )
        elif             isinstance( node.parent, nodes.document ):
            frame_style = 'document_title'
        elif isinstance( node.parent, nodes.topic ):
            frame_style = 'topic'

        newFrame = getFrame( self.styles,
            self.currentFrame, self.parent, style = frame_style )
        self.currentFrame = newFrame
        self.current_content = getContentManager( self.styles, self.currentFrame,
            style = 'x_align ' + frame_style )
        if not isinstance( node.parent, nodes.section ): # don't know when this might be true, but anyway.
            self.make_refs( self.current_content, node )
Beispiel #7
0
 def visit_Text( self, node ):
     font_style = None
     if ( isinstance( node.parent, nodes.emphasis ) or
         isinstance( node.parent, nodes.strong ) ):
         font_style = self.styles['translator']['emphasis']
         GenericText( self.current_content, text = node.astext(), translator = font_style )
         
     elif isinstance(node.parent, nodes.literal_block):
         for l in node.astext().splitlines():
             newFrame = getFrame( self.styles, self.currentFrame, self.parent )
             self.currentFrame = newFrame
             content = getContentManager( self.styles, self.currentFrame)
             GenericText(content, text = l)
         
     else:
         c = self.get_classes( node.parent )
         for attr in c:
             if attr in self.styles['translator']:
                 font_style = self.styles['translator'][attr]
                 break
         GenericText( self.current_content, text = node.astext(), translator = font_style )
Beispiel #8
0
 def visit_bullet_list( self, node ):
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'list_container' )
     if self.parent is not self.currentFrame:
         newFrame.update( x_anchor = self.currentFrame )
     self.currentFrame = self.parent = newFrame
Beispiel #9
0
 def visit_block_quote( self, node ):
     # create a container frame
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'block_quote_container' )
     self.parent = self.currentFrame = newFrame
Beispiel #10
0
 def visit_definition( self, node ):
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'glossary_definition' )
     self.currentFrame = self.parent = newFrame
Beispiel #11
0
 def visit_literal_block( self, node ):
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'literal_block_container')
     if self.parent is not self.currentFrame:
         newFrame.update( x_anchor = self.currentFrame )
     self.parent = self.currentFrame = newFrame
Beispiel #12
0
 def visit_line( self, node ):
     newFrame = getFrame( self.styles, self.currentFrame, self.parent)
     self.currentFrame = newFrame
     self.current_content = getContentManager( self.styles, self.currentFrame, style = 'wrapper pending2' )
Beispiel #13
0
 def visit_line_block( self, node ):
     newFrame = getFrame( self.styles, self.currentFrame, self.parent, style = 'list_container' ) # need custom style for this?
     self.currentFrame = self.parent = newFrame
Beispiel #14
0
 def visit_paragraph( self, node ):
     newFrame = getFrame( self.styles, self.currentFrame, self.parent )
     if node is node.parent[0]:
         newFrame.update( y_hook = 'top', y_offset = -1 )
     self.currentFrame = newFrame
     self.current_content = getContentManager( self.styles, self.currentFrame )