Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions crates/forge_markdown_stream/src/heading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,18 @@ mod tests {

#[test]
fn test_h1_simple() {
insta::assert_snapshot!(render(1, "Hello World"), @"<dim><h1>#</h1></dim> <h1>HELLO WORLD</h1>");
insta::assert_snapshot!(render(1, "Hello World"), @"

<dim><h1>#</h1></dim> <h1>HELLO WORLD</h1>
");
}

#[test]
fn test_h2_simple() {
insta::assert_snapshot!(render(2, "Chapter One"), @"<dim><h2>##</h2></dim> <h2>Chapter One</h2>");
insta::assert_snapshot!(render(2, "Chapter One"), @"

<dim><h2>##</h2></dim> <h2>Chapter One</h2>
");
}

#[test]
Expand All @@ -143,12 +149,18 @@ mod tests {

#[test]
fn test_h1_with_inline_bold() {
insta::assert_snapshot!(render(1, "Hello **bold** world"), @"<dim><h1>#</h1></dim> <h1>HELLO <b>BOLD</b> WORLD</h1>");
insta::assert_snapshot!(render(1, "Hello **bold** world"), @"

<dim><h1>#</h1></dim> <h1>HELLO <b>BOLD</b> WORLD</h1>
");
}

#[test]
fn test_h2_with_inline_italic() {
insta::assert_snapshot!(render(2, "Hello *italic* text"), @"<dim><h2>##</h2></dim> <h2>Hello <i>italic</i> text</h2>");
insta::assert_snapshot!(render(2, "Hello *italic* text"), @"

<dim><h2>##</h2></dim> <h2>Hello <i>italic</i> text</h2>
");
}

#[test]
Expand All @@ -165,24 +177,34 @@ mod tests {

#[test]
fn test_empty_content() {
insta::assert_snapshot!(render(1, ""), @"<dim><h1>#</h1></dim> <h1></h1>");
insta::assert_snapshot!(render(1, ""), @"

<dim><h1>#</h1></dim> <h1></h1>
");
}

#[test]
fn test_custom_margin() {
insta::assert_snapshot!(render_with_margin(1, "Title", " "), @"<dim><h1>#</h1></dim> <h1>TITLE</h1>");
insta::assert_snapshot!(render_with_margin(1, "Title", " "), @"

<dim><h1>#</h1></dim> <h1>TITLE</h1>
");
insta::assert_snapshot!(render_with_margin(3, "Section", ">>> "), @">>> <dim><h3>###</h3></dim> <h3>Section</h3>");
}

#[test]
fn test_no_margin() {
insta::assert_snapshot!(render_with_margin(1, "Title", ""), @"<dim><h1>#</h1></dim> <h1>TITLE</h1>");
insta::assert_snapshot!(render_with_margin(1, "Title", ""), @"

<dim><h1>#</h1></dim> <h1>TITLE</h1>
");
insta::assert_snapshot!(render_with_margin(3, "Section", ""), @"<dim><h3>###</h3></dim> <h3>Section</h3>");
}

#[test]
fn test_wrapping_narrow_width() {
insta::assert_snapshot!(render_with_width(1, "This is a very long heading that should wrap", 20), @r"
insta::assert_snapshot!(render_with_width(1, "This is a very long heading that should wrap", 20), @"

<dim><h1>#</h1></dim> <h1>THIS IS A VERY</h1>

<dim><h1>#</h1></dim> <h1>LONG HEADING THAT</h1>
Expand All @@ -193,7 +215,7 @@ mod tests {

#[test]
fn test_h3_wrapping() {
insta::assert_snapshot!(render_with_width(3, "A long section title that wraps", 15), @r"
insta::assert_snapshot!(render_with_width(3, "A long section title that wraps", 15), @"
<dim><h3>###</h3></dim> <h3>A long</h3>
<dim><h3>###</h3></dim> <h3>section</h3>
<dim><h3>###</h3></dim> <h3>title that</h3>
Expand All @@ -203,7 +225,10 @@ mod tests {

#[test]
fn test_special_characters() {
insta::assert_snapshot!(render(2, "Hello & Goodbye < World >"), @"<dim><h2>##</h2></dim> <h2>Hello & Goodbye < World ></h2>");
insta::assert_snapshot!(render(2, "Hello & Goodbye < World >"), @"

<dim><h2>##</h2></dim> <h2>Hello & Goodbye < World ></h2>
");
}

#[test]
Expand All @@ -213,7 +238,10 @@ mod tests {

#[test]
fn test_mixed_inline_styles() {
insta::assert_snapshot!(render(2, "**Bold** and *italic* and `code`"), @"<dim><h2>##</h2></dim> <h2><b>Bold</b> and <i>italic</i> and <code>code</code></h2>");
insta::assert_snapshot!(render(2, "**Bold** and *italic* and `code`"), @"

<dim><h2>##</h2></dim> <h2><b>Bold</b> and <i>italic</i> and <code>code</code></h2>
");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/forge_markdown_stream/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ mod tests {

#[test]
fn test_empty_content() {
insta::assert_snapshot!(render(0, ListBullet::Dash, ""), @" <dash>•</dash> ");
insta::assert_snapshot!(render(0, ListBullet::Dash, ""), @" <dash>•</dash>");
}

#[test]
Expand All @@ -332,7 +332,7 @@ mod tests {
"This is a very long list item that should wrap to multiple lines",
40,
);
insta::assert_snapshot!(result, @r"
insta::assert_snapshot!(result, @"
<dash>•</dash> This is a very long list item that
should wrap to multiple lines
");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"\", \"\"], vec![\"\", \"\"],])"
---
┌──┬──┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Feature\", \"Status\"], vec![\"**Important**\", \"Done\"],])"
---
┌──────────────────┬────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Function\", \"Description\"],\nvec![\"`render()`\", \"Renders the output\"],\nvec![\"`parse()`\", \"Parses input data\"],])"
---
┌───────────────────────┬────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"HTML\", \"Content\"], vec![\"<div>\", \"element\"],\nvec![\"<span class='x'>\", \"styled\"],])"
---
┌──────────────────┬─────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Note\", \"Details\"], vec![\"*emphasis*\", \"Regular text\"],])"
---
┌─────────────────┬──────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Resource\", \"URL\"],\nvec![\"Documentation\", \"[docs](https://example.com)\"],])"
---
┌───────────────┬────────────────────────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Item\", \"Description\"],\nvec![\"**Bold** and *italic*\", \"Mixed `code` here\"],\nvec![\"Normal\", \"[link](url) text\"],])"
---
┌───────────────────────────────┬──────────────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Complex\", \"Content\"],\nvec![\"***bold italic***\", \"~~strikethrough~~\"],])"
---
┌───────────────────────────┬──────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render_with_margin(vec![vec![\"A\", \"B\"], vec![\"1\", \"2\"],], \" \")"
---
┌───┬───┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"A\", \"B\"], vec![\"\", \"value\"], vec![\"data\", \"\"],])"
---
┌──────┬───────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"**Bold Header**\", \"`Code Header`\"],\nvec![\"data1\", \"data2\"],])"
---
┌────────────────────┬──────────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Header\", \"Description\"],\nvec![\"Short\",\n\"This is a much longer piece of content that should demonstrate how the table handles varying content lengths\"],])"
---
┌───────┬─────────────────────────────────────────────────────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render_with_width(vec![vec![\"Title\", \"Content\"],\nvec![\"Article\",\n\"This has **bold** and *italic* and `code` in a long sentence that wraps\"],],\n50)"
---
┌───────┬────────────────────────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"ID\", \"Value\"], vec![\"1\", \"one\"], vec![\"2\", \"two\"],\nvec![\"3\", \"three\"], vec![\"4\", \"four\"],])"
---
┌────┬───────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render_with_width(vec![vec![\"Name\", \"Bio\"],\nvec![\"Alice\", \"Software engineer with 10 years of experience\"],\nvec![\"Bob\", \"Data scientist specializing in machine learning\"],], 50)"
---
┌───────┬───────────────────────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render_with_width(vec![vec![\"Long Header One\", \"Long Header Two\"],\nvec![\"value1\", \"value2\"],], 40)"
---
┌─────────────────┬─────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render_with_margin(vec![vec![\"A\", \"B\"], vec![\"1\", \"2\"],], \"\")"
---
┌───┬───┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"ID\", \"Price\", \"Quantity\"], vec![\"1001\", \"$19.99\", \"150\"],\nvec![\"1002\", \"$249.50\", \"25\"], vec![\"1003\", \"$5.00\", \"1000\"],])"
---
┌──────┬─────────┬──────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Feature\", \"Status\", \"Description\", \"Link\"],\nvec![\"**Authentication**\", \"✅ `completed`\",\n\"Implements *JWT-based* authentication with ~~basic~~ **OAuth2** support\",\n\"[Docs](https://example.com)\",],\nvec![\"**Database Layer**\", \"🚧 `in-progress`\",\n\"Uses `PostgreSQL` with **Diesel ORM** for *type-safe* queries\",\n\"[GitHub](https://github.com)\",],\nvec![\"**API Gateway**\", \"⏳ `planned`\",\n\"RESTful API with `async/await` and ~~synchronous~~ **asynchronous** handlers\",\n\"[Spec](https://api.example.com)\",],\nvec![\"**Testing**\", \"✅ `completed`\",\n\"Includes *unit tests*, **integration tests**, and `snapshot testing`\",\n\"[Coverage](https://coverage.io)\",],\nvec![\"**Deployment**\", \"🚧 `in-progress`\",\n\"Docker containerization with `K8s` orchestration and **CI/CD** pipeline\",\n\"[Deploy](https://deploy.com)\",],])"
---
┌─────────┬───────────┬───────────────────────────────────┬────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Name\", \"Age\"], vec![\"Alice\", \"30\"],])"
---
┌───────┬─────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Header\"], vec![\"Value\"],])"
---
┌────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Items\"], vec![\"First\"], vec![\"Second\"], vec![\"Third\"],\nvec![\"Fourth\"], vec![\"Fifth\"],])"
---
┌────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Only\", \"Headers\"],])"
---
┌──────┬─────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Symbol\", \"Meaning\"], vec![\"<\", \"less than\"],\nvec![\">\", \"greater than\"], vec![\"&\", \"ampersand\"], vec![\"\\\"\", \"quote\"],])"
---
┌────────┬──────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"A\", \"B\", \"C\"], vec![\"1\", \"2\", \"3\"], vec![\"x\", \"y\", \"z\"],])"
---
┌───┬───┬───┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"A\", \"B\", \"C\"], vec![\"1\", \"2\"], vec![\"x\"],])"
---
┌───┬───┬───┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"名前\", \"年齢\"], vec![\"田中\", \"25\"],])"
---
┌──────┬──────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"言語\", \"説明\"], vec![\"**日本語**\", \"*Japanese*\"],\nvec![\"`中文`\", \"Chinese\"],])"
---
┌───────────────────┬─────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Short\", \"Much Longer Header\"], vec![\"a\", \"b\"],])"
---
┌───────┬────────────────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render_with_width(vec![vec![\"Column A\", \"Column B\"],\nvec![\"value1\", \"value2\"],], 25)"
---
┌──────────┬──────────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"Header\", \"Value\"], vec![\" spaces \", \" \"],])"
---
┌────────────┬───────┐
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/table.rs
source: crates/forge_markdown_stream/src/table.rs
expression: "render(vec![vec![\"A\", \"B\", \"C\", \"D\", \"E\", \"F\"],\nvec![\"1\", \"2\", \"3\", \"4\", \"5\", \"6\"],])"
---
┌───┬───┬───┬───┬───┬───┐
Expand Down
Loading