chore: gitignore and repo cleanup
This commit is contained in:
120
tests/test_parser.py
Normal file
120
tests/test_parser.py
Normal file
@@ -0,0 +1,120 @@
|
||||
import pytest
|
||||
from markitect.parser import parse_markdown_to_ast
|
||||
|
||||
def test_parse_basic_markdown():
|
||||
md_content = "# Heading\nThis is a paragraph."
|
||||
expected_ast = [
|
||||
{
|
||||
'type': 'heading_open',
|
||||
'tag': 'h1',
|
||||
'attrs': {},
|
||||
'map': [0, 1],
|
||||
'nesting': 1,
|
||||
'level': 0,
|
||||
'content': '',
|
||||
'markup': '#',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': True,
|
||||
'hidden': False
|
||||
},
|
||||
{
|
||||
'type': 'inline',
|
||||
'tag': '',
|
||||
'attrs': {},
|
||||
'map': [0, 1],
|
||||
'nesting': 0,
|
||||
'level': 1,
|
||||
'children': [
|
||||
{
|
||||
'type': 'text',
|
||||
'tag': '',
|
||||
'attrs': {},
|
||||
'nesting': 0,
|
||||
'level': 0,
|
||||
'content': 'Heading',
|
||||
'markup': '',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': False,
|
||||
'hidden': False
|
||||
}
|
||||
],
|
||||
'content': 'Heading',
|
||||
'markup': '',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': True,
|
||||
'hidden': False
|
||||
},
|
||||
{
|
||||
'type': 'heading_close',
|
||||
'tag': 'h1',
|
||||
'attrs': {},
|
||||
'nesting': -1,
|
||||
'level': 0,
|
||||
'content': '',
|
||||
'markup': '#',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': True,
|
||||
'hidden': False
|
||||
},
|
||||
{
|
||||
'type': 'paragraph_open',
|
||||
'tag': 'p',
|
||||
'attrs': {},
|
||||
'map': [1, 2],
|
||||
'nesting': 1,
|
||||
'level': 0,
|
||||
'content': '',
|
||||
'markup': '',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': True,
|
||||
'hidden': False
|
||||
},
|
||||
{
|
||||
'type': 'inline',
|
||||
'tag': '',
|
||||
'attrs': {},
|
||||
'map': [1, 2],
|
||||
'nesting': 0,
|
||||
'level': 1,
|
||||
'children': [
|
||||
{
|
||||
'type': 'text',
|
||||
'tag': '',
|
||||
'attrs': {},
|
||||
'nesting': 0,
|
||||
'level': 0,
|
||||
'content': 'This is a paragraph.',
|
||||
'markup': '',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': False,
|
||||
'hidden': False
|
||||
}
|
||||
],
|
||||
'content': 'This is a paragraph.',
|
||||
'markup': '',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': True,
|
||||
'hidden': False
|
||||
},
|
||||
{
|
||||
'type': 'paragraph_close',
|
||||
'tag': 'p',
|
||||
'attrs': {},
|
||||
'nesting': -1,
|
||||
'level': 0,
|
||||
'content': '',
|
||||
'markup': '',
|
||||
'info': '',
|
||||
'meta': {},
|
||||
'block': True,
|
||||
'hidden': False
|
||||
}
|
||||
]
|
||||
assert parse_markdown_to_ast(md_content) == expected_ast
|
||||
Reference in New Issue
Block a user