diff --git a/src/Common/StringParsing.fs b/src/Common/StringParsing.fs index 9ce65ee7..f02edb25 100644 --- a/src/Common/StringParsing.fs +++ b/src/Common/StringParsing.fs @@ -108,8 +108,11 @@ module String = let removeSpaces (lines: string list) = let spaces = lines - |> Seq.filter (String.IsNullOrWhiteSpace >> not) - |> Seq.map (fun line -> line |> Seq.takeWhile Char.IsWhiteSpace |> Seq.length) + |> Seq.choose (fun line -> + if not <| String.IsNullOrWhiteSpace line then + line |> Seq.takeWhile Char.IsWhiteSpace |> Seq.length |> Some + else + None) |> fun xs -> if Seq.isEmpty xs then 0 else Seq.min xs lines diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index 04cd96a9..e0d222dd 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -2264,8 +2264,11 @@ module internal SymbolReader = do replacedParagraphs |> Seq.collect collectParagraphIndirectLinks - |> Seq.filter (linkNotDefined doc) - |> Seq.map (getTypeLink ctx) + |> Seq.choose (fun line -> + if linkNotDefined doc line then + getTypeLink ctx line |> Some + else + None) |> Seq.iter (addLinkToType doc) doc.With(paragraphs = replacedParagraphs) diff --git a/src/FSharp.Formatting.Common/Templating.fs b/src/FSharp.Formatting.Common/Templating.fs index 043543b3..8d05ce51 100644 --- a/src/FSharp.Formatting.Common/Templating.fs +++ b/src/FSharp.Formatting.Common/Templating.fs @@ -48,10 +48,15 @@ type FrontMatterFile = // Allow empty lines in frontmatter let isBlankLine = String.IsNullOrWhiteSpace line isBlankLine || line.Contains(":")) - |> Seq.filter (String.IsNullOrWhiteSpace >> not) - |> Seq.map (fun line -> - let parts = line.Split(":") - parts.[0].ToLowerInvariant(), parts.[1]) + |> Seq.choose (fun line -> + let parts = line.Split(":") |> Array.toList + + if not <| String.IsNullOrWhiteSpace line then + match parts with + | first :: second :: _ -> Some(first.ToLowerInvariant(), second) + | _ -> None + else + None) |> Map.ofSeq match