import lib // Integration tests: converting complex markdown documents // Full blog post with mixed content fn test_full_blog_post(): Unit with {Test} = { let md = "# Welcome to My Blog\n\nThis is my **first post** about *Lux*.\n\n## Getting Started\n\nHere's some code:\n\n```lux\nfn main(): Unit = Console.print(\"hello\")\n```\n\nCheck out [the docs](https://example.com) for more.\n\n---\n\nThanks for reading!" let html = lib.toHtml(md) Test.assert(String.contains(html, "
"), "has code block with lang")
Test.assert(String.contains(html, "the docs"), "has link")
Test.assert(String.contains(html, "
"), "has horizontal rule")
Test.assert(String.contains(html, "Thanks for reading!"), "has closing paragraph")
}
// Document with various list types
fn test_mixed_lists(): Unit with {Test} = {
let md = "Shopping list:\n\n- Apples\n- Bananas\n- Cherries\n\nSteps:\n\n1. Preheat oven\n2. Mix ingredients\n3. Bake for 30 min"
let html = lib.toHtml(md)
Test.assert(String.contains(html, ""), "has unordered list")
Test.assert(String.contains(html, ""), "has ordered list")
Test.assert(String.contains(html, "- Apples
"), "has UL item")
Test.assert(String.contains(html, "- Preheat oven
"), "has OL item")
}
// Nested inline formatting
fn test_nested_inline(): Unit with {Test} = {
let result = lib.inlineToHtml("**bold and *italic* inside**")
Test.assert(String.contains(result, ""), "has strong tag")
Test.assert(String.contains(result, "italic"), "has nested italic")
}
// Multiple paragraphs
fn test_multiple_paragraphs(): Unit with {Test} = {
let md = "First paragraph.\n\nSecond paragraph.\n\nThird paragraph."
let html = lib.toHtml(md)
Test.assert(String.contains(html, "First paragraph.
"), "first para")
Test.assert(String.contains(html, "Second paragraph.
"), "second para")
Test.assert(String.contains(html, "Third paragraph.
"), "third para")
}
// Code block preserves content exactly
fn test_code_block_preserves_content(): Unit with {Test} = {
let md = "```html\n\n Hello & world
\n\n```"
let html = lib.toHtml(md)
Test.assert(String.contains(html, "language-html"), "has language class")
Test.assert(String.contains(html, "<div>"), "HTML tags in code are escaped")
Test.assert(String.contains(html, "& world"), "ampersand in code is escaped")
}
// Heading with various inline elements
fn test_heading_with_link(): Unit with {Test} = {
let md = "## [Lux](https://example.com) Language"
let html = lib.toHtml(md)
Test.assert(String.contains(html, ""), "has h2")
Test.assert(String.contains(html, "Lux"), "has link in heading")
}
// Blockquote with inline formatting
fn test_blockquote_with_formatting(): Unit with {Test} = {
let md = "> This is a **bold** quote"
let html = lib.toHtml(md)
Test.assert(String.contains(html, ""), "has blockquote")
Test.assert(String.contains(html, "bold"), "has bold in blockquote")
}
// Document starting with code block
fn test_leading_code_block(): Unit with {Test} = {
let md = "```\ncode first\n```\n\nThen text."
let html = lib.toHtml(md)
Test.assert(String.contains(html, "code first"), "code block first")
Test.assert(String.contains(html, "Then text.
"), "paragraph after code")
}
// Images in context
fn test_image_in_paragraph(): Unit with {Test} = {
let md = "Here is a photo:\n\n\n\nBeautiful, right?"
let html = lib.toHtml(md)
Test.assert(String.contains(html, "
"), "has image")
}
// List items with headings
fn test_list_with_headings(): Unit with {Test} = {
let md = "- ## Chapter 1\n- ## Chapter 2\n- ## Chapter 3"
let html = lib.toHtml(md)
Test.assert(String.contains(html, "Chapter 1
"), "heading in list item 1")
Test.assert(String.contains(html, "Chapter 2
"), "heading in list item 2")
Test.assert(String.contains(html, "Chapter 3
"), "heading in list item 3")
}