Next / Previous / Contents / Shipman's homepage

23.15. MonthCell.__annoBlock(): Annotation block with a label

This method generates one of the blocks displaying specific kinds of day-annotation data such as “Route”. For the generated output, see Section 4.6, “XHTML for day-annotation elements”.

noteweb
# - - -   M o n t h C e l l . _ _ a n n o B l o c k

    def __annoBlock ( self, parent, label, narr ):
        '''Generate a label block of day annotation.

          [ (parent is an et.Element) and
            (label is a string) and
            (narr is a Narrative instance) ->
              parent  +:=  a div with class=LOC_NARRATIVE_CLASS
                  containing label and an XHTML rendering of narr ]
        '''
        #-- 1 --
        # [ parent  +:=  a div element with class=LOC_NARRATIVE_CLASS
        #   div  :=  that div element ]
        div  =  et.SubElement ( parent, 'div' )
        div.attrib['class']  =  LOC_NARRATIVE_CLASS

The block's label is wrapped in a span; see Section 5.2, “Inline markup rules” and Section 23.9, “MonthCell.__span(): Add a span inline”.

noteweb
        #-- 2 --
        # [ div  +:=  a span element with class=LOC_LABEL_CLASS
        #             containing label ]
        self.__span ( div, LOC_LABEL_CLASS, "%s " % label )

The content of the div depends on whether the given narr has one paragraph or multiple paragraphs.

noteweb
        #-- 3 --
        # [ div  +:=  XHTML rendering of narr ]
        if  len(narr) == 1:
            #-- 3.1 --
            # [ div  +:=  contents of the first paragraph of narr ]
            self.__paraContent ( div, narr[0] )
        else:
            #-- 3.2 --
            # [ div  +:=  child div elements containing the
            #             paragraphs of narr ]
            self.__narrative ( div, narr )