def __init__(self, lines): if lines[0].startswith('```'): # code fence content = ''.join(lines[1:-1]) self.language = lines[0].strip()[3:] else: # indented code content = ''.join([line[4:] for line in lines]) self.language = '' self.children = (span_token.RawText(content), )
def __init__(self, match): lines, open_info = match self.language = span_token.EscapeSequence.strip(open_info[2]) self.children = (span_token.RawText(''.join(lines)), )
def __init__(self, lines): self.language = '' self.children = (span_token.RawText(''.join(lines).strip('\n') + '\n'), )
def test_no_children(self): token = span_token.RawText('some text') with self.assertRaises(AttributeError): token.children
def test_attribute(self): token = span_token.RawText('some text') self.assertEqual(token.content, 'some text')
def __init__(self, lines): self.language = lines[0].strip()[3:] self._children = (span_token.RawText(''.join(lines[1:])), )
def __init__(self, lines): self.language = '' self._children = (span_token.RawText(''.join(line[4:] for line in lines)), )