From a13d6702e2d8ee0507073805f7ed712fba06e26d Mon Sep 17 00:00:00 2001 From: Nicholas Hirschey Date: Fri, 18 Nov 2022 12:11:41 -0800 Subject: [PATCH 1/5] allow spaces in artifacts directory path --- build/build.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/build.fs b/build/build.fs index 21fe64105..7e6738cf0 100644 --- a/build/build.fs +++ b/build/build.fs @@ -103,9 +103,9 @@ let generateDocs _ = ("install --no-cache --version " + release.NugetVersion + " --add-source " - + artifactsDir + + "\"" + artifactsDir + "\"" + " --tool-path " - + artifactsDir + + "\"" + artifactsDir + "\"" + " fsdocs-tool") |> ignore From b6edc971b7ee5597d5c8d2a7989e8ffe35addae8 Mon Sep 17 00:00:00 2001 From: Nicholas Hirschey Date: Fri, 18 Nov 2022 12:11:52 -0800 Subject: [PATCH 2/5] syntax highlight api code --- .../GenerateModel.fs | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index 1f0e022df..dad2540df 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -1877,22 +1877,10 @@ module internal SymbolReader = html.Append("") |> ignore | "code" -> - let lang = - match elem.Attributes("lang") |> Seq.isEmpty with - | true -> "" - | false -> - let lang = elem.Attribute("lang").Value - $"{lang} language-{lang}" - - html.Append("
") |> ignore
-                    html.Append($"") |> ignore
-
-                    let code = elem.Value.TrimEnd('\r', '\n', ' ')
-                    let codeAsHtml = HttpUtility.HtmlEncode code
-                    html.Append(codeAsHtml) |> ignore
-
-                    html.Append("") |> ignore
-                    html.Append("
") |> ignore + let code = + let code = Literate.ParseMarkdownString ("```\n" + elem.Value + "\n```") + Literate.ToHtml(code, lineNumbers = false) + html.Append(code) |> ignore // 'a' is not part of the XML doc standard but is widely used | "a" -> html.Append(elem.ToString()) |> ignore // This allows any HTML to be transferred through From c1ff1a22f0cbff937f49be0fe5a0d0ad7dee5663 Mon Sep 17 00:00:00 2001 From: Nicholas Hirschey Date: Fri, 18 Nov 2022 12:23:50 -0800 Subject: [PATCH 3/5] update release notes --- RELEASE_NOTES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5efd42f56..2bf01b6d2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +## 17.1.0 +* [Add syntax highlighting to API docs](https://github.com/fsprojects/FSharp.Formatting/pull/780) + ## 17.0.0 * Update to .NET 7.0.100 From b162b21804b309e7eecff90b72921947a329a879 Mon Sep 17 00:00:00 2001 From: Nicholas Hirschey Date: Fri, 18 Nov 2022 12:28:35 -0800 Subject: [PATCH 4/5] format source --- build/build.fs | 8 ++++++-- src/FSharp.Formatting.ApiDocs/GenerateModel.fs | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build/build.fs b/build/build.fs index 7e6738cf0..eec34fa93 100644 --- a/build/build.fs +++ b/build/build.fs @@ -103,9 +103,13 @@ let generateDocs _ = ("install --no-cache --version " + release.NugetVersion + " --add-source " - + "\"" + artifactsDir + "\"" + + "\"" + + artifactsDir + + "\"" + " --tool-path " - + "\"" + artifactsDir + "\"" + + "\"" + + artifactsDir + + "\"" + " fsdocs-tool") |> ignore diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index dad2540df..5a8bd477b 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -1877,9 +1877,10 @@ module internal SymbolReader = html.Append("") |> ignore | "code" -> - let code = - let code = Literate.ParseMarkdownString ("```\n" + elem.Value + "\n```") + let code = + let code = Literate.ParseMarkdownString("```\n" + elem.Value + "\n```") Literate.ToHtml(code, lineNumbers = false) + html.Append(code) |> ignore // 'a' is not part of the XML doc standard but is widely used | "a" -> html.Append(elem.ToString()) |> ignore From 94e833aa3d741e70b75f7d3d8f52da44d364f59c Mon Sep 17 00:00:00 2001 From: Nicholas Hirschey Date: Sat, 19 Nov 2022 14:50:30 -0800 Subject: [PATCH 5/5] re-fix trailing spaces. --- src/FSharp.Formatting.ApiDocs/GenerateModel.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index 5a8bd477b..db4d83746 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -1878,7 +1878,7 @@ module internal SymbolReader = html.Append("") |> ignore | "code" -> let code = - let code = Literate.ParseMarkdownString("```\n" + elem.Value + "\n```") + let code = Literate.ParseMarkdownString("```\n" + elem.Value.TrimEnd('\r', '\n', ' ') + "\n```") Literate.ToHtml(code, lineNumbers = false) html.Append(code) |> ignore