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”.
# - - - 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”.
#-- 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.
If narr has only one child
pararagraph, we go directly to Section 23.18, “MonthCell.__paraContent(): Content of
one paragraph” to avoid getting
another level of div elements around
the content.
In the multi-paragraph case, separate child div elements are generated for each
paragraph by Section 23.16, “MonthCell.__narrative(): Render a
Narrative instance”.
#-- 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 )