Skip to content

Parse markdown file to python object, which contains markdown tree headings

License

Notifications You must be signed in to change notification settings

phpusr/markdown-tree-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-tree-parser

Parse markdown file to python object, which contains markdown tree headings

Usage examples

import unittest

from markdown_tree_parser.parser import parse_string


class TestParser(unittest.TestCase):

    def test_code_block(self):
        text = '''
Title
=====

# Code

Code 1
------
Some text
\```
# TODO
\```

Code 2
------
\```python
# TODO
print('test')
\```

# Heading
'''
        out = parse_string(text)
        self.assertEqual(out.title, 'Title')
        self.assertEqual(out[0][0].text, 'Code 1')
        self.assertEqual(out[0][0].source, 'Some text\n```\n# TODO\n```\n')
        self.assertEqual(out[0][1].text, 'Code 2')
        self.assertEqual(out[0][1].source, "```python\n# TODO\nprint('test')\n```\n")
        self.assertEqual(out[1].text, 'Heading')

        
if __name__ == '__main__':
    unittest.main()

About

Parse markdown file to python object, which contains markdown tree headings

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages