Skip to content

Commit b5a1e50

Browse files
authored
Merge pull request #1194 from fsprojects/repo-assist/test-outputblock-anchorlink-2026-04-29-f38ec86010d3f790
[Repo Assist] test: add OutputBlock, AnchorLink, and code-block language specifier tests
2 parents 05372b1 + 4ff7084 commit b5a1e50

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/FSharp.Markdown.Tests/Markdown.fs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,48 @@ let ``ToLatex EmbedParagraphs delegates to Render()`` () =
19771977
let result = Markdown.ToLatex(doc)
19781978
result |> should contain "latex text"
19791979

1980+
// --------------------------------------------------------------------------------------
1981+
// ToMd: untested paragraph types — OutputBlock, code-block language specifier
1982+
// --------------------------------------------------------------------------------------
1983+
1984+
[<Test>]
1985+
let ``ToMd preserves fenced code block language specifier`` () =
1986+
// Existing test only checks the code body; this test verifies the language tag is kept.
1987+
let md = "```fsharp\nlet x = 1\n```"
1988+
let result = toMd md
1989+
result |> should contain "```fsharp"
1990+
1991+
[<Test>]
1992+
let ``ToMd serialises OutputBlock non-HTML as fenced code block`` () =
1993+
// OutputBlock with a non-HTML kind should be wrapped in a fenced code block.
1994+
let doc = MarkdownDocument([ OutputBlock("hello output", "text/plain", None) ], dict [])
1995+
let result = Markdown.ToMd(doc, newline = "\n")
1996+
result |> should contain "```"
1997+
result |> should contain "hello output"
1998+
1999+
[<Test>]
2000+
let ``ToMd serialises OutputBlock HTML as raw HTML`` () =
2001+
// OutputBlock with kind "text/html" should emit the HTML directly, not wrapped in a fence.
2002+
let doc = MarkdownDocument([ OutputBlock("<p>output</p>", "text/html", None) ], dict [])
2003+
let result = Markdown.ToMd(doc, newline = "\n")
2004+
result |> should contain "<p>output</p>"
2005+
result |> should not' (contain "```")
2006+
2007+
// --------------------------------------------------------------------------------------
2008+
// ToHtml: AnchorLink renders as a named anchor element
2009+
// --------------------------------------------------------------------------------------
2010+
2011+
[<Test>]
2012+
let ``ToHtml renders AnchorLink as named anchor`` () =
2013+
// AnchorLink is used internally by ApiDocs to emit in-page anchors.
2014+
// It should produce <a name="id">&#160;</a> in HTML output.
2015+
let doc =
2016+
MarkdownDocument([ Paragraph([ AnchorLink("my-section", MarkdownRange.zero) ], MarkdownRange.zero) ], dict [])
2017+
2018+
let result = Markdown.ToHtml(doc)
2019+
result |> should contain "name=\"my-section\""
2020+
result |> should contain "<a "
2021+
19802022
// --------------------------------------------------------------------------------------
19812023
// Markdown.ToFsx: code-with-output tests
19822024
// --------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)