def _code_line(self, line):
        """Add a code line."""
        assert self._containers
        container = self._containers[-1]
        # Handle extra spaces.
        text = line
        while text:
            if text.startswith('  '):
                r = re.match(r'(^ +)', text)
                n = len(r.group(1))
                container.addElement(S(c=n))
                text = text[n:]
            elif '  ' in text:
                assert not text.startswith(' ')
                i = text.index('  ')
                container.addElement(Span(text=text[:i]))
                text = text[i:]
            else:
                container.addElement(Span(text=text))
                text = ''
def _code_line ( self , line ) : assert self . _containers container = self . _containers [ - 1 ] text = line while text : if text . startswith ( '  ' ) : r = re . match ( r'(^ +)' , text ) n = len ( r . group ( 1 ) ) container . addElement ( S ( c = n ) ) text = text [ n : ] elif '  ' in text : assert not text . startswith ( ' ' ) i = text . index ( '  ' ) container . addElement ( Span ( text = text [ : i ] ) ) text = text [ i : ] else : container . addElement ( Span ( text = text ) ) text = ''
Add a code line.