Skip to content

Commit 2bc1cca

Browse files
authored
Merge pull request #1187 from fsprojects/repo-assist/test-tomd-table-html-2026-04-24-4780fc0504066a65
[Repo Assist] test: add ToMd table alignment and InlineHtmlBlock tests
2 parents e276ebc + 3317104 commit 2bc1cca

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/FSharp.Markdown.Tests/Markdown.fs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,56 @@ let ``ToMd handles a table`` () =
14061406
result |> should contain "A"
14071407
result |> should contain "B"
14081408

1409+
// --------------------------------------------------------------------------------------
1410+
// ToMd table column alignment — left, center, right, default
1411+
// --------------------------------------------------------------------------------------
1412+
1413+
[<Test>]
1414+
let ``ToMd preserves left-aligned table columns`` () =
1415+
let md = "A | B\n:--- | :---\nX | Y"
1416+
let result = toMd md
1417+
result |> should contain ":---"
1418+
1419+
[<Test>]
1420+
let ``ToMd preserves center-aligned table columns`` () =
1421+
let md = "A | B\n:---: | :---:\nX | Y"
1422+
let result = toMd md
1423+
result |> should contain ":---:"
1424+
1425+
[<Test>]
1426+
let ``ToMd preserves right-aligned table columns`` () =
1427+
let md = "A | B\n---: | ---:\nX | Y"
1428+
let result = toMd md
1429+
result |> should contain "---:"
1430+
1431+
[<Test>]
1432+
let ``ToMd preserves default-aligned table columns`` () =
1433+
let md = "A | B\n--- | ---\nX | Y"
1434+
let result = toMd md
1435+
// default alignment renders as "---"
1436+
result |> should contain "---"
1437+
1438+
[<Test>]
1439+
let ``ToMd preserves table with mixed column alignments`` () =
1440+
let md = "Left | Center | Right | Default\n:--- | :---: | ---: | ---\na | b | c | d"
1441+
let result = toMd md
1442+
result |> should contain ":---:"
1443+
result |> should contain "---:"
1444+
result |> should contain "Left"
1445+
result |> should contain "Right"
1446+
1447+
// --------------------------------------------------------------------------------------
1448+
// ToMd InlineHtmlBlock round-trip
1449+
// --------------------------------------------------------------------------------------
1450+
1451+
[<Test>]
1452+
let ``ToMd preserves an inline HTML block`` () =
1453+
let md = "<div class=\"note\">\nThis is a note.\n</div>"
1454+
let result = toMd md
1455+
result |> should contain "<div"
1456+
result |> should contain "This is a note."
1457+
result |> should contain "</div>"
1458+
14091459
[<Test>]
14101460
let ``ToMd table rows each appear on their own line`` () =
14111461
// Previously, all data rows were joined into one string with a hardcoded "\n",

0 commit comments

Comments
 (0)