Socket
Socket
Sign inDemoInstall

markdown-tree-parser

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    markdown-tree-parser

Markdown tree parser


Maintainers
1

Readme

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()

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc