Next / Previous / Contents / TCC Help System / NM Tech homepage

4.10. ArticleHandler.characters(): Observe text content

The SAX interface stipulates that the content handler have a method called .characters() that is called to pass it all textual content. We care about such content only if we are currently inside a code fragment.

litsource
# - - -   A r t i c l e H a n d l e r . c h a r a c t e r s   - - -

    def characters ( self, text ):
        """Handle text within an element.

          [ text is a string ->
              if  self.outFile is not None ->
                self.outFile  +:=  text
              else -> I ]
        """

        #-- 1 --
        if  self.outFile is not None:
            self.outFile.write ( text )