260 lines
6.8 KiB
V
260 lines
6.8 KiB
V
module markdownparser2
|
|
|
|
fn test_parse_inline_basic() {
|
|
// Test basic inline parsing
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Plain text'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Plain text'
|
|
}
|
|
|
|
fn test_parse_inline_empty() {
|
|
// Test parsing empty text
|
|
text := ''
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
assert elements.len == 0 // No elements for empty text
|
|
}
|
|
|
|
fn test_parse_inline_whitespace_only() {
|
|
// Test parsing whitespace-only text
|
|
text := ' '
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
assert elements.len == 0 // No elements for whitespace-only text
|
|
}
|
|
|
|
fn test_parse_inline_with_bold() {
|
|
// Test parsing text with bold markers
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with **bold** content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with **bold** content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of bold elements
|
|
}
|
|
|
|
fn test_parse_inline_with_italic() {
|
|
// Test parsing text with italic markers
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with *italic* content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with *italic* content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of italic elements
|
|
}
|
|
|
|
fn test_parse_inline_with_link() {
|
|
// Test parsing text with link markers
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with [link](https://example.com) content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with [link](https://example.com) content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of link elements
|
|
}
|
|
|
|
fn test_parse_inline_with_image() {
|
|
// Test parsing text with image markers
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with  content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with  content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of image elements
|
|
}
|
|
|
|
fn test_parse_inline_with_code() {
|
|
// Test parsing text with inline code markers
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with `code` content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with `code` content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of inline code elements
|
|
}
|
|
|
|
fn test_parse_inline_with_strikethrough() {
|
|
// Test parsing text with strikethrough markers
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with ~~strikethrough~~ content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with ~~strikethrough~~ content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of strikethrough elements
|
|
}
|
|
|
|
fn test_parse_inline_with_footnote_reference() {
|
|
// Test parsing text with footnote reference markers
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with footnote[^1] content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with footnote[^1] content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of footnote reference elements
|
|
}
|
|
|
|
fn test_parse_inline_with_multiple_elements() {
|
|
// Test parsing text with multiple inline elements
|
|
// Note: Currently the parser doesn't parse inline elements separately
|
|
text := 'Text with **bold**, *italic*, and [link](https://example.com) content'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, inline elements are not parsed separately
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with **bold**, *italic*, and [link](https://example.com) content'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper parsing of multiple inline elements
|
|
}
|
|
|
|
fn test_parse_inline_with_escaped_characters() {
|
|
// Test parsing text with escaped characters
|
|
// Note: Currently the parser doesn't handle escaped characters specially
|
|
text := 'Text with \\*escaped\\* characters'
|
|
mut parser := Parser{
|
|
text: ''
|
|
pos: 0
|
|
line: 1
|
|
column: 1
|
|
doc: new_document()
|
|
}
|
|
|
|
elements := parser.parse_inline(text)
|
|
|
|
// Currently, escaped characters are not handled specially
|
|
assert elements.len == 1
|
|
assert elements[0].typ == .text
|
|
assert elements[0].content == 'Text with \\*escaped\\* characters'
|
|
|
|
// TODO: When inline parsing is implemented, this test should be updated to check for
|
|
// proper handling of escaped characters
|
|
}
|