diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 6026ae5db..63bf216fb 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "fantomas": { - "version": "5.0.0-beta-008", + "version": "6.0.0-alpha-008", "commands": [ "fantomas" ] diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index db72a6354..10624f7e0 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -22,7 +22,7 @@ jobs: run: dotnet tool restore - name: Restore packages run: dotnet paket restore - - name: Check code formatting conforms (run 'dotnet fantomas src tests docs build --recurse' to repair) - run: dotnet fantomas src tests docs build -r --check + - name: Check code formatting conforms (run 'dotnet fantomas src tests docs build' to repair) + run: dotnet fantomas src tests docs build --check - name: Build and test run: dotnet run --project ./build/build.fsproj diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml index d35e2ff6f..3e78cef7a 100644 --- a/.github/workflows/push-main.yml +++ b/.github/workflows/push-main.yml @@ -22,8 +22,8 @@ jobs: run: dotnet tool restore - name: Restore packages run: dotnet paket restore - - name: Check code formatting conforms (run 'dotnet fantomas src tests docs build --recurse' to repair) - run: dotnet fantomas src tests docs build -r --check + - name: Check code formatting conforms (run 'dotnet fantomas src tests docs build' to repair) + run: dotnet fantomas src tests docs build --check - name: Build and test run: dotnet run --project ./build/build.fsproj - name: Deploy docs diff --git a/build/build.fs b/build/build.fs index eec34fa93..6efe871be 100644 --- a/build/build.fs +++ b/build/build.fs @@ -67,7 +67,9 @@ let solutionFile = "FSharp.Formatting.sln" let build _ = solutionFile - |> DotNet.build (fun opts -> { opts with Configuration = configuration }) + |> DotNet.build (fun opts -> + { opts with + Configuration = configuration }) let tests _ = solutionFile diff --git a/src/Common/StringParsing.fs b/src/Common/StringParsing.fs index 70dcf771e..5be823ba1 100644 --- a/src/Common/StringParsing.fs +++ b/src/Common/StringParsing.fs @@ -140,17 +140,26 @@ module StringPosition = /// Returns a string trimmed from the end let (|TrimEnd|) (text: string, n: MarkdownRange) = let trimmed = text.TrimEnd() - (trimmed, { n with EndColumn = n.EndColumn - text.Length + trimmed.Length }) + + (trimmed, + { n with + EndColumn = n.EndColumn - text.Length + trimmed.Length }) /// Returns a string trimmed from the start let (|TrimStart|) (text: string, n: MarkdownRange) = let trimmed = text.TrimStart() - (trimmed, { n with StartColumn = n.StartColumn + text.Length - trimmed.Length }) + + (trimmed, + { n with + StartColumn = n.StartColumn + text.Length - trimmed.Length }) /// Returns a string trimmed from the end using characters given as a parameter let (|TrimEndUsing|) chars (text: string, n: MarkdownRange) = let trimmed = text.TrimEnd(Array.ofSeq chars) - (trimmed, { n with EndColumn = n.EndColumn - text.Length + trimmed.Length }) + + (trimmed, + { n with + EndColumn = n.EndColumn - text.Length + trimmed.Length }) /// Returns a string trimmed from the start together with /// the number of skipped whitespace characters @@ -160,7 +169,9 @@ module StringPosition = len, text.Substring(0, len).Replace("\t", " ").Length, - (trimmed, { n with StartColumn = n.StartColumn + text.Length - trimmed.Length }) + (trimmed, + { n with + StartColumn = n.StartColumn + text.Length - trimmed.Length }) /// Matches when a string starts with any of the specified sub-strings let (|StartsWithAny|_|) (starts: seq) (text: string, _n: MarkdownRange) = @@ -172,7 +183,11 @@ module StringPosition = /// Matches when a string starts with the specified sub-string let (|StartsWith|_|) (start: string) (text: string, n: MarkdownRange) = if text.StartsWith(start) then - Some(text.Substring(start.Length), { n with StartColumn = n.StartColumn + text.Length - start.Length }) + Some( + text.Substring(start.Length), + { n with + StartColumn = n.StartColumn + text.Length - start.Length } + ) else None @@ -182,7 +197,8 @@ module StringPosition = if text.StartsWith(start) then Some( text.Substring(start.Length).Trim(), - { n with StartColumn = n.StartColumn + text.Length - start.Length } + { n with + StartColumn = n.StartColumn + text.Length - start.Length } ) else None @@ -268,7 +284,12 @@ module StringPosition = let rest = text.Substring(id + ends.Length, text.Length - id - ends.Length) - Some(wrapped, (rest, { n with StartColumn = id + ends.Length })) + Some( + wrapped, + (rest, + { n with + StartColumn = id + ends.Length }) + ) else None else @@ -287,7 +308,7 @@ module List = let inline (|DelimitedWith|_|) startl endl input = if List.startsWith startl input then match List.partitionUntilEquals endl (List.skip startl.Length input) with - | Some (pre, post) -> Some(pre, List.skip endl.Length post, startl.Length, endl.Length) + | Some(pre, post) -> Some(pre, List.skip endl.Length post, startl.Length, endl.Length) | None -> None else None @@ -388,7 +409,9 @@ module Lines = let trimmed = s.TrimEnd([| ' ' |]) + if endsWithTwoSpaces then " " else "" - (trimmed, { n with EndColumn = n.EndColumn - s.Length + trimmed.Length })) + (trimmed, + { n with + EndColumn = n.EndColumn - s.Length + trimmed.Length })) /// Parameterized pattern that assigns the specified value to the /// first component of a tuple. Usage: diff --git a/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs index 06643a94e..3c2be9fb0 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateHtml.fs @@ -152,7 +152,7 @@ type HtmlRender(model: ApiDocModel, ?menuTemplateFolder: string) = br [] match m.ReturnInfo.ReturnType with | None -> () - | Some (_, rty) -> + | Some(_, rty) -> span [] [ !!(if m.Kind <> ApiDocMemberKind.RecordField then @@ -195,7 +195,7 @@ type HtmlRender(model: ApiDocModel, ?menuTemplateFolder: string) = | None -> () match m.ExtendedType with - | Some (_, extendedTypeHtml) -> + | Some(_, extendedTypeHtml) -> p [] [ !! "Extended Type: "; embed extendedTypeHtml ] | _ -> () @@ -219,7 +219,7 @@ type HtmlRender(model: ApiDocModel, ?menuTemplateFolder: string) = match m.ReturnInfo.ReturnType with | None -> () - | Some (_, returnTypeHtml) -> + | Some(_, returnTypeHtml) -> dl [ Class "fsdocs-returns" ] [ dt @@ -371,12 +371,12 @@ type HtmlRender(model: ApiDocModel, ?menuTemplateFolder: string) = match entity.AbbreviatedType with - | Some (_, abbreviatedTypHtml) -> dt [] [ !! "Abbreviation For: "; embed abbreviatedTypHtml ] + | Some(_, abbreviatedTypHtml) -> dt [] [ !! "Abbreviation For: "; embed abbreviatedTypHtml ] | None -> () match entity.BaseType with - | Some (_, baseTypeHtml) -> dt [] [ !! "Base Type: "; embed baseTypeHtml ] + | Some(_, baseTypeHtml) -> dt [] [ !! "Base Type: "; embed baseTypeHtml ] | None -> () match entity.AllInterfaces with @@ -395,7 +395,7 @@ type HtmlRender(model: ApiDocModel, ?menuTemplateFolder: string) = dt [] [ !!("Kind: Struct") ] match entity.DelegateSignature with - | Some (_, delegateSigHtml) -> dt [] [ !!("Delegate Signature: "); embed delegateSigHtml ] + | Some(_, delegateSigHtml) -> dt [] [ !!("Delegate Signature: "); embed delegateSigHtml ] | None -> () if entity.Symbol.IsProvided then @@ -598,7 +598,7 @@ type HtmlRender(model: ApiDocModel, ?menuTemplateFolder: string) = match nsOpt with | Some ns2 when ns.Name = ns2.Name -> ul - [ Custom("list-style-type", "none") (* Class "navbar-nav " *) ] + [ Custom("list-style-type", "none") (* Class "navbar-nav " *) ] [ for category in allByCategory do for e in category.CategoryEntites do li diff --git a/src/FSharp.Formatting.ApiDocs/GenerateMarkdown.fs b/src/FSharp.Formatting.ApiDocs/GenerateMarkdown.fs index 0d698b07e..fe0a75b5e 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateMarkdown.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateMarkdown.fs @@ -72,11 +72,11 @@ type MarkdownRender(model: ApiDocModel, ?menuTemplateFolder: string) = match m.ExtendedType with | None -> () - | Some (_, extendedTypeHtml) -> p [ !! "Extended Type: "; embedSafe extendedTypeHtml; br ] + | Some(_, extendedTypeHtml) -> p [ !! "Extended Type: "; embedSafe extendedTypeHtml; br ] match m.ReturnInfo.ReturnType with | None -> () - | Some (_, returnTypeHtml) -> + | Some(_, returnTypeHtml) -> p [ !!(if m.Kind <> ApiDocMemberKind.RecordField then "Returns: " @@ -174,11 +174,11 @@ type MarkdownRender(model: ApiDocModel, ?menuTemplateFolder: string) = (parentModule.Url(root, collectionName, qualify, model.FileExtensions.InUrl)) ] match entity.AbbreviatedType with - | Some (_, abbreviatedTyp) -> p [ !! "Abbreviation For: "; embed abbreviatedTyp ] + | Some(_, abbreviatedTyp) -> p [ !! "Abbreviation For: "; embed abbreviatedTyp ] | None -> () match entity.BaseType with - | Some (_, baseType) -> p [ !! "Base Type: "; embed baseType ] + | Some(_, baseType) -> p [ !! "Base Type: "; embed baseType ] | None -> () match entity.AllInterfaces with @@ -196,7 +196,7 @@ type MarkdownRender(model: ApiDocModel, ?menuTemplateFolder: string) = p [ !!("Kind: Struct") ] match entity.DelegateSignature with - | Some (_, delegateSigHtml) -> p [ !!("Delegate Signature: "); embed delegateSigHtml ] + | Some(_, delegateSigHtml) -> p [ !!("Delegate Signature: "); embed delegateSigHtml ] | None -> () if entity.Symbol.IsProvided then diff --git a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs index 6d766b517..cf117c453 100644 --- a/src/FSharp.Formatting.ApiDocs/GenerateModel.fs +++ b/src/FSharp.Formatting.ApiDocs/GenerateModel.fs @@ -309,7 +309,7 @@ type ApiDocMember warn ) = - let (ApiDocMemberDetails (usageHtml, paramTypes, returnType, modifiers, typars, extendedType, location, compiledName)) = + let (ApiDocMemberDetails(usageHtml, paramTypes, returnType, modifiers, typars, extendedType, location, compiledName)) = details let m = defaultArg symbol.DeclarationLocation range0 @@ -674,12 +674,7 @@ type ApiDocCollection(name: string, asms: AssemblyName list, nss: ApiDocNamespac /// High-level information about a module definition type ApiDocEntityInfo - ( - entity: ApiDocEntity, - collection: ApiDocCollection, - ns: ApiDocNamespace, - parent: ApiDocEntity option - ) = + (entity: ApiDocEntity, collection: ApiDocCollection, ns: ApiDocNamespace, parent: ApiDocEntity option) = /// The actual entity member x.Entity = entity @@ -761,7 +756,7 @@ module internal CrossReferences = match (memb.DeclaringEntity.Value.TryFullName) with | None -> "" - | Some (n) -> sprintf "%s:%s.%s" (getMemberXmlDocsSigPrefix memb) n memberName + | Some(n) -> sprintf "%s:%s.%s" (getMemberXmlDocsSigPrefix memb) n memberName | n -> n type internal CrefReference = @@ -1187,13 +1182,13 @@ module internal TypeFormatter = // of measures in a normalized form (see Andrew Kennedy technical reports). Here we detect this // embedding and use an approximate set of rules for layout out normalized measures in a nice way. match typ with - | MeasureProd (ty, MeasureOne) - | MeasureProd (MeasureOne, ty) -> formatTypeWithPrecAsHtml ctx prec ty - | MeasureProd (ty1, MeasureInv ty2) - | MeasureProd (ty1, MeasureProd (MeasureInv ty2, MeasureOne)) -> + | MeasureProd(ty, MeasureOne) + | MeasureProd(MeasureOne, ty) -> formatTypeWithPrecAsHtml ctx prec ty + | MeasureProd(ty1, MeasureInv ty2) + | MeasureProd(ty1, MeasureProd(MeasureInv ty2, MeasureOne)) -> span [] [ formatTypeWithPrecAsHtml ctx 2 ty1; !! "/"; formatTypeWithPrecAsHtml ctx 2 ty2 ] - | MeasureProd (ty1, MeasureProd (ty2, MeasureOne)) - | MeasureProd (ty1, ty2) -> + | MeasureProd(ty1, MeasureProd(ty2, MeasureOne)) + | MeasureProd(ty1, ty2) -> span [] [ formatTypeWithPrecAsHtml ctx 2 ty1; !! "*"; formatTypeWithPrecAsHtml ctx 2 ty2 ] | MeasureInv ty -> span [] [ !! "/"; formatTypeWithPrecAsHtml ctx 1 ty ] | MeasureOne -> !! "1" @@ -1505,7 +1500,7 @@ module internal SymbolReader = let argInfos, retType = match argInfos, v.HasGetterMethod, v.HasSetterMethod with - | [ AllAndLast (args, last) ], _, true -> [ args ], Some last.Type + | [ AllAndLast(args, last) ], _, true -> [ args ], Some last.Type | _, _, true -> argInfos, None | [ [] ], true, _ -> [], Some retType | _, _, _ -> argInfos, Some retType @@ -1753,12 +1748,12 @@ module internal SymbolReader = let raw = match doc.Source with - | LiterateSource.Markdown (string) -> [ KeyValuePair(current, string) ] + | LiterateSource.Markdown(string) -> [ KeyValuePair(current, string) ] | LiterateSource.Script _ -> [] for par in doc.Paragraphs do match par with - | Heading (2, [ Literal (text, _) ], _) -> + | Heading(2, [ Literal(text, _) ], _) -> current <- text.Trim() groups.Add(current, [ par ]) | par -> groups.[groups.Count - 1] <- (current, par :: snd (groups.[groups.Count - 1])) @@ -1826,7 +1821,7 @@ module internal SymbolReader = let findCommand cmd = match cmd with - | StringPosition.StartsWithWrapped ("[", "]") (ParseCommand (k, v), _rest) -> Some(k, v) + | StringPosition.StartsWithWrapped ("[", "]") (ParseCommand(k, v), _rest) -> Some(k, v) | _ -> None let rec readXmlElementAsHtml @@ -1841,7 +1836,7 @@ module internal SymbolReader = let text = (x :?> XText).Value match findCommand (text, MarkdownRange.zero) with - | Some (k, v) -> cmds.Add(k, v) + | Some(k, v) -> cmds.Add(k, v) | None -> html.Append(text) |> ignore elif x.NodeType = XmlNodeType.Element then let elem = x :?> XElement @@ -2138,9 +2133,9 @@ module internal SymbolReader = let rec collectSpanIndirectLinks span = seq { match span with - | IndirectLink (_, _, key, _) -> yield key + | IndirectLink(_, _, key, _) -> yield key | MarkdownPatterns.SpanLeaf _ -> () - | MarkdownPatterns.SpanNode (_, spans) -> + | MarkdownPatterns.SpanNode(_, spans) -> for s in spans do yield! collectSpanIndirectLinks s } @@ -2150,11 +2145,11 @@ module internal SymbolReader = seq { match par with | MarkdownPatterns.ParagraphLeaf _ -> () - | MarkdownPatterns.ParagraphNested (_, pars) -> + | MarkdownPatterns.ParagraphNested(_, pars) -> for ps in pars do for p in ps do yield! collectParagraphIndirectLinks p - | MarkdownPatterns.ParagraphSpans (_, spans) -> + | MarkdownPatterns.ParagraphSpans(_, spans) -> for s in spans do yield! collectSpanIndirectLinks s } @@ -2175,13 +2170,13 @@ module internal SymbolReader = /// Adds a cross-type link to the document defined links let addLinkToType (doc: LiterateDocument) link = match link with - | Some (k, v) -> do doc.DefinedLinks.Add(k, (v.ReferenceLink, Some v.NiceName)) + | Some(k, v) -> do doc.DefinedLinks.Add(k, (v.ReferenceLink, Some v.NiceName)) | None -> () /// Wraps the span inside an IndirectLink if it is an inline code that can be converted to a link let wrapInlineCodeLinksInSpans (ctx: ReadingContext) span = match span with - | InlineCode (code, r) -> + | InlineCode(code, r) -> match getTypeLink ctx code with | Some _ -> IndirectLink([ span ], code, code, r) | None -> span @@ -2191,13 +2186,13 @@ module internal SymbolReader = let rec wrapInlineCodeLinksInParagraphs (ctx: ReadingContext) (para: MarkdownParagraph) = match para with | MarkdownPatterns.ParagraphLeaf _ -> para - | MarkdownPatterns.ParagraphNested (info, pars) -> + | MarkdownPatterns.ParagraphNested(info, pars) -> MarkdownPatterns.ParagraphNested( info, pars |> List.map (fun innerPars -> List.map (wrapInlineCodeLinksInParagraphs ctx) innerPars) ) - | MarkdownPatterns.ParagraphSpans (info, spans) -> + | MarkdownPatterns.ParagraphSpans(info, spans) -> MarkdownPatterns.ParagraphSpans(info, List.map (wrapInlineCodeLinksInSpans ctx) spans) /// Adds the missing links to types to the document defined links @@ -2221,7 +2216,7 @@ module internal SymbolReader = |> List.filter ( findCommand >> (function - | Some (k, v) -> + | Some(k, v) -> cmds.[k] <- v false | _ -> true) @@ -2499,7 +2494,7 @@ module internal SymbolReader = let xmlDocText (xmlDoc: FSharpXmlDoc) = match xmlDoc with - | FSharpXmlDoc.FromXmlText (xmlDoc) -> String.concat "" xmlDoc.UnprocessedLines + | FSharpXmlDoc.FromXmlText(xmlDoc) -> String.concat "" xmlDoc.UnprocessedLines | _ -> "" // Create a xml documentation snippet and add it to the XmlMemberMap @@ -3023,7 +3018,7 @@ type ApiDocModel internal (substitutions, collection, entityInfos, root, qualify | false, _ -> namespaces.Add(ns.Name, (ns.Entities, ns.NamespaceDocs, ns.Substitutions)) let namespaces = - [ for (KeyValue (name, (entities, summary, substitutions))) in namespaces do + [ for (KeyValue(name, (entities, summary, substitutions))) in namespaces do printfn " found %d entities in namespace %s..." entities.Length name if entities.Length > 0 then diff --git a/src/FSharp.Formatting.CodeFormat/CodeFormat.fs b/src/FSharp.Formatting.CodeFormat/CodeFormat.fs index 164d57a2e..8b08ad81e 100644 --- a/src/FSharp.Formatting.CodeFormat/CodeFormat.fs +++ b/src/FSharp.Formatting.CodeFormat/CodeFormat.fs @@ -92,9 +92,9 @@ type CodeFormat = /// Formats the .fsx snippets as iPython notebook using the default settings. static member FormatFsx(snippets) = let snips = - [| for (Snippet (key, lines)) in snippets do + [| for (Snippet(key, lines)) in snippets do let str = - [| for (Line (originalLine, _spans)) in lines -> originalLine |] + [| for (Line(originalLine, _spans)) in lines -> originalLine |] |> String.concat Environment.NewLine yield key, str |] diff --git a/src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs b/src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs index 7851b13e4..af4725878 100644 --- a/src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs +++ b/src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs @@ -91,7 +91,7 @@ module private Helpers = let rec parseLine () = seq { match tokenizer.ScanToken(state) with - | Some (tok), nstate -> + | Some(tok), nstate -> let str = line.Substring(tok.LeftColumn, tok.RightColumn - tok.LeftColumn + 1) yield str, tok @@ -206,7 +206,11 @@ module CodeFormatter = | FSharpTokenColorKind.String, None -> None, Some(Range.Create token.LeftColumn token.RightColumn), rest | FSharpTokenColorKind.String, Some range -> - None, Some { range with RightCol = token.RightColumn }, rest + None, + Some + { range with + RightCol = token.RightColumn }, + rest | _, Some range -> None, Some range, tokens | _ -> None, None, rest | _ -> @@ -214,7 +218,11 @@ module CodeFormatter = | FSharpTokenColorKind.String, None -> Some(Range.Create token.LeftColumn token.RightColumn), None, rest | FSharpTokenColorKind.String, Some range -> - Some { range with RightCol = token.RightColumn }, None, rest + Some + { range with + RightCol = token.RightColumn }, + None, + rest | _, Some range -> None, Some range, tokens | _ -> None, None, rest @@ -242,7 +250,7 @@ module CodeFormatter = ) match tip |> ToolTipReader.tryFormatTip with - | Some (_) as res -> res + | Some(_) as res -> res | _ -> None else None @@ -256,7 +264,7 @@ module CodeFormatter = yield TokenSpan.Output(body) else match tip with - | Some (Literal msg :: _) when msg.StartsWith("custom operation:") -> + | Some(Literal msg :: _) when msg.StartsWith("custom operation:") -> // If the tool-tip says this is a custom operation, then // we want to treat it as keyword (not sure if there is a better // way to detect this, but Visual Studio also colors these later) @@ -431,8 +439,9 @@ module CodeFormatter = // Override default options if the user specified something let opts = match options with - | Some (str: string) when not (System.String.IsNullOrEmpty(str)) -> - { opts with OtherOptions = [| yield! Helpers.parseOptions str; yield! opts.OtherOptions |] } + | Some(str: string) when not (System.String.IsNullOrEmpty(str)) -> + { opts with + OtherOptions = [| yield! Helpers.parseOptions str; yield! opts.OtherOptions |] } | _ -> opts //// add our file //let opts = @@ -459,7 +468,7 @@ module CodeFormatter = let! res = fsChecker.ParseAndCheckDocument(filePath, source, opts, false) match res with - | Some (_parseResults, parsedInput, checkResults) -> + | Some(_parseResults, parsedInput, checkResults) -> Log.verbf "starting to GetAllUsesOfAllSymbolsInFile from '%s'" filePath let _symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile() @@ -505,7 +514,7 @@ module CodeFormatter = let parsed = parsed |> List.map (function - | Line (originalLine, (TokenSpan.Token (kind, body, tip)) :: rest) -> + | Line(originalLine, (TokenSpan.Token(kind, body, tip)) :: rest) -> let body = body.Substring(spaces) Line(originalLine, (TokenSpan.Token(kind, body, tip)) :: rest) | line -> line) diff --git a/src/FSharp.Formatting.CodeFormat/CommentFilter.fs b/src/FSharp.Formatting.CodeFormat/CommentFilter.fs index dbf75777a..b45c4f589 100644 --- a/src/FSharp.Formatting.CodeFormat/CommentFilter.fs +++ b/src/FSharp.Formatting.CodeFormat/CommentFilter.fs @@ -61,26 +61,28 @@ let rec getSnippets | None, _ -> getSnippets state snippets rest lines // We're inside a snippet and it ends - | Some (title, acc), StringPosition.StartsWithTrim "//" (StringPosition.StartsWithTrim "[/snippet]" _) -> + | Some(title, acc), StringPosition.StartsWithTrim "//" (StringPosition.StartsWithTrim "[/snippet]" _) -> getSnippets None ((title, acc |> List.rev) :: snippets) rest lines // We're inside snippet - add current line to it - | Some (title, acc), _ -> getSnippets (Some(title, (line, tokens) :: acc)) snippets rest lines + | Some(title, acc), _ -> getSnippets (Some(title, (line, tokens) :: acc)) snippets rest lines /// Preprocesses a line and merges all subsequent comments on a line /// into a single long comment (so that we can parse it as snippet command) let rec mergeComments (line: SnippetLine) (cmt: Token option) (acc: SnippetLine) = match line, cmt with - | [], Some (cmt) -> cmt :: acc |> List.rev + | [], Some(cmt) -> cmt :: acc |> List.rev | [], None -> acc |> List.rev | (str, tok) :: line, None when tok.TokenName = "COMMENT" || tok.TokenName = "LINE_COMMENT" -> mergeComments line (Some(str, tok)) acc - | (str, tok) :: line, Some (scmt, cmt) when tok.TokenName = "COMMENT" || tok.TokenName = "LINE_COMMENT" -> - let ncmt = { cmt with RightColumn = tok.RightColumn } + | (str, tok) :: line, Some(scmt, cmt) when tok.TokenName = "COMMENT" || tok.TokenName = "LINE_COMMENT" -> + let ncmt = + { cmt with + RightColumn = tok.RightColumn } mergeComments line (Some(scmt + str, ncmt)) acc | (str, tok) :: line, None -> mergeComments line None ((str, tok) :: acc) - | (str, tok) :: line, Some (cmt) -> mergeComments line None ((str, tok) :: cmt :: acc) + | (str, tok) :: line, Some(cmt) -> mergeComments line None ((str, tok) :: cmt :: acc) /// Continue reading shrinked code until we reach the end (*[/omit]*) tag @@ -106,7 +108,11 @@ let rec shrinkLine line (content: SnippetLine) (source: Snippet) = let line, source = shrinkLine line remcontent source - (body, { tok with TokenName = "OMIT" + (text.ToString()) }) :: line, source + (body, + { tok with + TokenName = "OMIT" + (text.ToString()) }) + :: line, + source | (String.StartsWithTrim "//" (String.StartsAndEndsWith ("[fsi:", "]") fsi), (tok: FSharpTokenInfo)) :: rest -> let line, source = shrinkLine line rest source (fsi, { tok with TokenName = "FSI" }) :: line, source diff --git a/src/FSharp.Formatting.CodeFormat/HtmlFormatting.fs b/src/FSharp.Formatting.CodeFormat/HtmlFormatting.fs index 64353b82f..ae95e3365 100644 --- a/src/FSharp.Formatting.CodeFormat/HtmlFormatting.fs +++ b/src/FSharp.Formatting.CodeFormat/HtmlFormatting.fs @@ -59,7 +59,7 @@ type ToolTipFormatter(prefix) = /// Returns all generated tool tip elements member x.WriteTipElements(writer: TextWriter) = - for (KeyValue (_, (index, html))) in tips do + for (KeyValue(_, (index, html))) in tips do writer.WriteLine(sprintf "
%s
" prefix index html) @@ -87,11 +87,11 @@ let formatToolTipSpans spans = let rec format spans = spans |> List.iter (function - | Emphasis (spans) -> + | Emphasis(spans) -> wr.Write("") format spans wr.Write("") - | Literal (string) -> + | Literal(string) -> let spaces = string.Length - string.TrimStart(' ').Length wr.Write(String.replicate spaces " ") @@ -104,7 +104,7 @@ let formatToolTipSpans spans = /// Format token spans such as tokens, omitted code etc. let rec formatTokenSpans (ctx: FormattingContext) = List.iter (function - | TokenSpan.Error (_kind, message, body) when ctx.GenerateErrors -> + | TokenSpan.Error(_kind, message, body) when ctx.GenerateErrors -> let tip = ToolTipReader.formatMultilineString (message.Trim().Split('\n')) let tipAttributes = ctx.FormatTip tip true formatToolTipSpans @@ -115,14 +115,14 @@ let rec formatTokenSpans (ctx: FormattingContext) = formatTokenSpans { ctx with FormatTip = fun _ _ _ -> "" } body ctx.Writer.Write("") - | TokenSpan.Error (_, _, body) -> formatTokenSpans ctx body + | TokenSpan.Error(_, _, body) -> formatTokenSpans ctx body - | TokenSpan.Output (body) -> + | TokenSpan.Output(body) -> ctx.Writer.Write("") ctx.Writer.Write(HttpUtility.HtmlEncode(body)) ctx.Writer.Write("") - | TokenSpan.Omitted (body, hidden) -> + | TokenSpan.Omitted(body, hidden) -> let tip = ToolTipReader.formatMultilineString (hidden.Trim().Split('\n')) let tipAttributes = ctx.FormatTip tip true formatToolTipSpans @@ -133,11 +133,11 @@ let rec formatTokenSpans (ctx: FormattingContext) = ctx.Writer.Write(body) ctx.Writer.Write("") - | TokenSpan.Token (kind, body, tip) -> + | TokenSpan.Token(kind, body, tip) -> // Generate additional attributes for ToolTip let tipAttributes = match tip with - | Some (tip) -> ctx.FormatTip tip false formatToolTipSpans + | Some(tip) -> ctx.FormatTip tip false formatToolTipSpans | _ -> "" // Get CSS class name of the token @@ -155,16 +155,18 @@ let rec formatTokenSpans (ctx: FormattingContext) = /// Generate HTML with the specified snippets let formatSnippets (ctx: FormattingContext) (snippets: Snippet[]) = - [| for (Snippet (key, lines)) in snippets do + [| for (Snippet(key, lines)) in snippets do // Skip empty lines at the beginning and at the end - let skipEmptyLines = Seq.skipWhile (fun (Line (_, spans)) -> List.isEmpty spans) >> List.ofSeq + let skipEmptyLines = Seq.skipWhile (fun (Line(_, spans)) -> List.isEmpty spans) >> List.ofSeq let lines = lines |> skipEmptyLines |> List.rev |> skipEmptyLines |> List.rev // Generate snippet to a local StringBuilder let mainStr = StringBuilder() - let ctx = { ctx with Writer = new StringWriter(mainStr) } + let ctx = + { ctx with + Writer = new StringWriter(mainStr) } let numberLength = lines.Length.ToString().Length let linesLength = lines.Length @@ -198,7 +200,7 @@ let formatSnippets (ctx: FormattingContext) (snippets: Snippet[]) = emitTag ctx.OpenTag lines - |> List.iter (fun (Line (_originalLine, spans)) -> + |> List.iter (fun (Line(_originalLine, spans)) -> formatTokenSpans ctx spans ctx.Writer.WriteLine()) diff --git a/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs b/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs index fecfe6aeb..cc447e733 100644 --- a/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs +++ b/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs @@ -42,19 +42,19 @@ type FormattingContext = /// Format token spans such as tokens, omitted code etc. let rec formatTokenSpans (ctx: FormattingContext) = List.iter (function - | TokenSpan.Error (_, _, body) -> formatTokenSpans ctx body + | TokenSpan.Error(_, _, body) -> formatTokenSpans ctx body - | TokenSpan.Output (body) -> + | TokenSpan.Output(body) -> ctx.Writer.Write(@"\fsi{") ctx.Writer.Write(latexEncode body) ctx.Writer.Write("}") - | TokenSpan.Omitted (body, _) -> + | TokenSpan.Omitted(body, _) -> ctx.Writer.Write(@"\omi{") ctx.Writer.Write(latexEncode body) ctx.Writer.Write("}") - | TokenSpan.Token (kind, body, _) -> + | TokenSpan.Token(kind, body, _) -> let tag = match kind with | TokenKind.Comment -> @"\com" @@ -86,11 +86,13 @@ let rec formatTokenSpans (ctx: FormattingContext) = /// Generate LaTEX with the specified snippets let formatSnippets (ctx: FormattingContext) (snippets: Snippet[]) = - [| for (Snippet (key, lines)) in snippets do + [| for (Snippet(key, lines)) in snippets do // Generate snippet to a local StringBuilder let mainStr = StringBuilder() - let ctx = { ctx with Writer = new StringWriter(mainStr) } + let ctx = + { ctx with + Writer = new StringWriter(mainStr) } // Generate
 tag for the snippet
            if String.IsNullOrEmpty(ctx.OpenTag) |> not then
@@ -104,7 +106,7 @@ let formatSnippets (ctx: FormattingContext) (snippets: Snippet[]) =
 
            // Print all lines of the snippet
            lines
-           |> List.iter (fun (Line (_originalLine, spans)) ->
+           |> List.iter (fun (Line(_originalLine, spans)) ->
                // Write tokens & end of the line
                formatTokenSpans ctx spans
                ctx.Writer.WriteLine())
diff --git a/src/FSharp.Formatting.CodeFormat/Pervasive.fs b/src/FSharp.Formatting.CodeFormat/Pervasive.fs
index 4b34676e6..79c62589f 100644
--- a/src/FSharp.Formatting.CodeFormat/Pervasive.fs
+++ b/src/FSharp.Formatting.CodeFormat/Pervasive.fs
@@ -36,7 +36,7 @@ type AsyncMaybeBuilder() =
 
             match r1' with
             | None -> return None
-            | Some () -> return! r2
+            | Some() -> return! r2
         }
 
     []
@@ -163,7 +163,7 @@ type FSharpChecker with
 
         let bindParsedInput (results: (FSharpParseFileResults * FSharpCheckFileResults) option) =
             match results with
-            | Some (parseResults, checkResults) -> Some(parseResults, parseResults.ParseTree, checkResults)
+            | Some(parseResults, checkResults) -> Some(parseResults, parseResults.ParseTree, checkResults)
             | None -> None
 
         if allowStaleResults then
@@ -176,7 +176,7 @@ type FSharpChecker with
                     | StillRunning worker ->
                         async {
                             match allowStaleResults, this.TryGetRecentCheckResultsForFile(filePath, options) with
-                            | true, Some (parseResults, checkFileResults, _) ->
+                            | true, Some(parseResults, checkFileResults, _) ->
                                 return Some(parseResults, checkFileResults)
                             | _ -> return! worker
                         }
diff --git a/src/FSharp.Formatting.CodeFormat/PynbFormatting.fs b/src/FSharp.Formatting.CodeFormat/PynbFormatting.fs
index b2aa32c11..9c67f2cf1 100644
--- a/src/FSharp.Formatting.CodeFormat/PynbFormatting.fs
+++ b/src/FSharp.Formatting.CodeFormat/PynbFormatting.fs
@@ -10,9 +10,9 @@ open FSharp.Formatting.CodeFormat
 
 /// Generate Pynb code cell text with the specified snippets
 let formatSnippetsAsPynb (snippets: Snippet[]) =
-    [| for (Snippet (key, lines)) in snippets do
+    [| for (Snippet(key, lines)) in snippets do
            let str =
-               [| for (Line (originalLine, _spans)) in lines -> originalLine |]
+               [| for (Line(originalLine, _spans)) in lines -> originalLine |]
                |> String.concat Environment.NewLine
 
            yield key, str |]
diff --git a/src/FSharp.Formatting.CodeFormat/SourceParser.fs b/src/FSharp.Formatting.CodeFormat/SourceParser.fs
index 8527bfb2e..eea30889d 100644
--- a/src/FSharp.Formatting.CodeFormat/SourceParser.fs
+++ b/src/FSharp.Formatting.CodeFormat/SourceParser.fs
@@ -81,7 +81,7 @@ type ToolTip private (str) =
     /// Creates a tool tip - returns 'None' if it contains no data
     static member TryCreate(tip: DataTipText) =
         match tip with
-        | DataTipText (elems) when
+        | DataTipText(elems) when
             elems
             |> List.forall (function
                 | DataTipElementNone -> true
@@ -168,7 +168,7 @@ type SourceFile(file, source, lines: string[], ?options, ?defines) =
     // Override default options if the user specified something
     let opts =
         match options with
-        | Some (str: string) when not (String.IsNullOrEmpty(str)) ->
+        | Some(str: string) when not (String.IsNullOrEmpty(str)) ->
             opts.WithProjectOptions(parseOptions str 0 [] [] |> Array.ofSeq)
         | _ -> opts
 
@@ -187,7 +187,7 @@ type SourceFile(file, source, lines: string[], ?options, ?defines) =
             let info = checker.TypeCheckSource(untypedInfo, file, 0, source, opts, obs)
 
             match info with
-            | TypeCheckSucceeded (res) when res.TypeCheckInfo.IsSome ->
+            | TypeCheckSucceeded(res) when res.TypeCheckInfo.IsSome ->
                 let errs =
                     (*[omit:(copying of errors omitted)]*)
                     seq {
@@ -230,7 +230,7 @@ type SourceFile(file, source, lines: string[], ?options, ?defines) =
               let rec parseLine () =
                   seq {
                       match tokenizer.ScanToken(!state) with
-                      | Some (tok), nstate ->
+                      | Some(tok), nstate ->
                           let str = line.Substring(tok.LeftColumn, tok.RightColumn - tok.LeftColumn + 1)
 
                           yield str, tok
@@ -282,7 +282,7 @@ type SourceFile(file, source, lines: string[], ?options, ?defines) =
                                       let tip = checkInfo.GetDataTipText(pos, lines.[line], island, identToken)
 
                                       match ToolTip.TryCreate(tip) with
-                                      | Some (_) as res -> res
+                                      | Some(_) as res -> res
                                       | _ when island.Length > 1 -> (*[omit:(alternative attempt omitted)]*)
                                           // Try to find some information about the last part of the identifier
                                           let pos = (line, tok.LeftColumn + 2)
@@ -346,7 +346,10 @@ type SourceFile(file, source, lines: string[], ?options, ?defines) =
                   [ for line in res do
                         match line.Tokens with
                         | first :: rest ->
-                            let tokens = { first with Text = first.Text.Substring(spaces) } :: rest
+                            let tokens =
+                                { first with
+                                    Text = first.Text.Substring(spaces) }
+                                :: rest
 
                             yield { line with Tokens = tokens }
                         | _ -> yield line ]
diff --git a/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs b/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs
index 69534ba7f..551ec3ebc 100644
--- a/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs
+++ b/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs
@@ -46,7 +46,7 @@ let formatMultilineString (lines: string[]) =
 /// Format comment in the tool tip
 let private formatComment xmlDoc =
     match xmlDoc with
-    | FSharpXmlDoc.FromXmlText (xmlDoc) -> [ Emphasis(formatMultilineString xmlDoc.UnprocessedLines); HardLineBreak ]
+    | FSharpXmlDoc.FromXmlText(xmlDoc) -> [ Emphasis(formatMultilineString xmlDoc.UnprocessedLines); HardLineBreak ]
     | _ ->
         // TODO: For 'XmlCommentSignature' we could get documentation
         // from 'xml' files, but we don't know where to get them...
@@ -60,7 +60,7 @@ let private formatElement tooltip =
     //    [ yield! formatMultilineString it
     //      yield HardLineBreak
     //      yield! formatComment comment ]
-    | ToolTipElement.Group (items) ->
+    | ToolTipElement.Group(items) ->
         // Trim the items to at most 10 displayed in a tool tip
         let items, trimmed =
             if items.Length <= 10 then
@@ -90,14 +90,14 @@ let private formatElement tooltip =
     //      yield ToolTipSpan.HardLineBreak
     //      yield! formatComment _doc
     //  ]
-    | ToolTipElement.CompositionError (_err) -> []
+    | ToolTipElement.CompositionError(_err) -> []
 
 /// Format entire tool tip as a value of type ToolTipSpans
 let private formatTip tip =
     let spans =
         match tip with
-        | ToolTipText ([ single ]) -> formatElement single
-        | ToolTipText (items) ->
+        | ToolTipText([ single ]) -> formatElement single
+        | ToolTipText(items) ->
             [ yield Literal "Multiple items"
               yield HardLineBreak
               for first, item in Seq.mapi (fun i it -> i = 0, it) items do
@@ -119,7 +119,7 @@ let private formatTip tip =
 /// some text in the tip. Returns None if no information is available
 let tryFormatTip =
     function
-    | ToolTipText (elems) when
+    | ToolTipText(elems) when
         elems
         |> List.forall (function
             | ToolTipElement.None -> true
diff --git a/src/FSharp.Formatting.Common/HtmlModel.fs b/src/FSharp.Formatting.Common/HtmlModel.fs
index 459bebe58..0db03e265 100644
--- a/src/FSharp.Formatting.Common/HtmlModel.fs
+++ b/src/FSharp.Formatting.Common/HtmlModel.fs
@@ -296,7 +296,7 @@ type internal HtmlProperties =
         | Results s -> sprintf "results=\"%g\"" s
         | Security s -> sprintf "security=\"%s\"" s
         | Unselectable s -> sprintf "unselectable=\"%s\"" (if s then "true" else "false")
-        | Custom (k, v) -> sprintf "%s=\"%s\"" k v
+        | Custom(k, v) -> sprintf "%s=\"%s\"" k v
 
 type internal HtmlElement =
     private
@@ -467,137 +467,137 @@ type internal HtmlElement =
 
         and helper level tag =
             match tag with
-            | A (props, children) -> format "a" props children level
-            | Abbr (props, children) -> format "abbr" props children level
-            | Address (props, children) -> format "address" props children level
-            | Area (props) -> formatVoid "area" props level
-            | Article (props, children) -> format "article" props children level
-            | Aside (props, children) -> format "aside" props children level
-            | Audio (props, children) -> format "audio" props children level
-            | B (props, children) -> format "b" props children level
-            | Base (props) -> formatVoid "base" props level
-            | Bdi (props, children) -> format "bdi" props children level
-            | Bdo (props, children) -> format "bdo" props children level
-            | Big (props, children) -> format "big" props children level
-            | Blockquote (props, children) -> format "blockquote" props children level
-            | Body (props, children) -> format "body" props children level
-            | Br (props) -> formatVoid "br" props level
-            | Button (props, children) -> format "button" props children level
-            | Canvas (props, children) -> format "canvas" props children level
-            | Caption (props, children) -> format "caption" props children level
-            | Cite (props, children) -> format "cite" props children level
-            | Code (props, children) -> format "code" props children level
-            | Col (props) -> formatVoid "col" props level
-            | Colgroup (props, children) -> format "colgroup" props children level
-            | Data (props, children) -> format "data" props children level
-            | Datalist (props, children) -> format "datalist" props children level
-            | Dd (props, children) -> format "dd" props children level
-            | Del (props, children) -> format "del" props children level
-            | Details (props, children) -> format "details" props children level
-            | Dfn (props, children) -> format "dfn" props children level
-            | Dialog (props, children) -> format "dialog" props children level
-            | Div (props, children) -> format "div" props children level
-            | Dl (props, children) -> format "dl" props children level
-            | Dt (props, children) -> format "dt" props children level
-            | Em (props, children) -> format "em" props children level
-            | Embed (props) -> formatVoid "embed" props level
-            | Fieldset (props, children) -> format "fieldset" props children level
-            | Figcaption (props, children) -> format "figcaption" props children level
-            | Figure (props, children) -> format "figure" props children level
-            | Footer (props, children) -> format "footer" props children level
-            | Form (props, children) -> format "form" props children level
-            | H1 (props, children) -> format "h1" props children level
-            | H2 (props, children) -> format "h2" props children level
-            | H3 (props, children) -> format "h3" props children level
-            | H4 (props, children) -> format "h4" props children level
-            | H5 (props, children) -> format "h5" props children level
-            | H6 (props, children) -> format "h6" props children level
-            | Head (props, children) -> format "head" props children level
-            | Header (props, children) -> format "header" props children level
-            | Hgroup (props, children) -> format "hgroup" props children level
-            | Hr (props) -> formatVoid "hr" props level
-            | Html (props, children) -> format "html" props children level
-            | I (props, children) -> format "i" props children level
-            | Iframe (props, children) -> format "iframe" props children level
-            | Img (props) -> formatVoid "img" props level
-            | Input (props) -> formatVoid "input" props level
-            | Ins (props, children) -> format "ins" props children level
-            | Kbd (props, children) -> format "kbd" props children level
-            | Keygen (props) -> formatVoid "keygen" props level
-            | Label (props, children) -> format "label" props children level
-            | Legend (props, children) -> format "legend" props children level
-            | Li (props, children) -> format "li" props children level
-            | Link (props) -> formatVoid "link" props level
-            | Main (props, children) -> format "main" props children level
-            | Map (props, children) -> format "map" props children level
-            | Mark (props, children) -> format "mark" props children level
-            | Menu (props, children) -> format "menu" props children level
-            | Menuitem (props) -> formatVoid "menuitem" props level
-            | Meta (props) -> formatVoid "meta" props level
-            | Meter (props, children) -> format "meter" props children level
-            | Nav (props, children) -> format "nav" props children level
-            | Noscript (props, children) -> format "noscript" props children level
-            | Object (props, children) -> format "object" props children level
-            | Ol (props, children) -> format "ol" props children level
-            | Optgroup (props, children) -> format "optgroup" props children level
-            | Option (props, children) -> format "option" props children level
-            | Output (props, children) -> format "output" props children level
-            | P (props, children) -> format "p" props children level
-            | Param (props) -> formatVoid "param" props level
-            | Picture (props, children) -> format "picture" props children level
-            | Pre (props, children) -> format "pre" props children level
-            | Progress (props, children) -> format "progress" props children level
-            | Q (props, children) -> format "q" props children level
-            | Rp (props, children) -> format "rp" props children level
-            | Rt (props, children) -> format "rt" props children level
-            | Ruby (props, children) -> format "ruby" props children level
-            | S (props, children) -> format "s" props children level
-            | Samp (props, children) -> format "samp" props children level
-            | Script (props, children) -> format "script" props children level
-            | Section (props, children) -> format "section" props children level
-            | Select (props, children) -> format "select" props children level
-            | Small (props, children) -> format "small" props children level
-            | Source (props) -> formatVoid "source" props level
-            | Span (props, children) -> format "span" props children level
-            | Strong (props, children) -> format "strong" props children level
-            | Style (props, children) -> format "style" props children level
-            | Sub (props, children) -> format "sub" props children level
-            | Summary (props, children) -> format "summary" props children level
-            | Sup (props, children) -> format "sup" props children level
-            | Table (props, children) -> format "table" props children level
-            | Tbody (props, children) -> format "tbody" props children level
-            | Td (props, children) -> format "td" props children level
-            | Textarea (props, children) -> format "textarea" props children level
-            | Tfoot (props, children) -> format "tfoot" props children level
-            | Th (props, children) -> format "th" props children level
-            | Thead (props, children) -> format "thead" props children level
-            | Time (props, children) -> format "time" props children level
-            | Title (props, children) -> format "title" props children level
-            | Tr (props, children) -> format "tr" props children level
-            | Track (props) -> formatVoid "track" props level
-            | U (props, children) -> format "u" props children level
-            | Ul (props, children) -> format "ul" props children level
-            | Var (props, children) -> format "var" props children level
-            | Video (props, children) -> format "video" props children level
-            | Wbr (props) -> formatVoid "wbr" props level
-            | Svg (props, children) -> format "svg" props children level
-            | Circle (props, children) -> format "circle" props children level
-            | Defs (props, children) -> format "defs" props children level
-            | Ellipse (props, children) -> format "ellipse" props children level
-            | G (props, children) -> format "g" props children level
-            | Image (props, children) -> format "image" props children level
-            | Line (props, children) -> format "line" props children level
-            | LinearGradient (props, children) -> format "radient" props children level
-            | Mask (props, children) -> format "mask" props children level
-            | Path (props, children) -> format "path" props children level
-            | Pattern (props, children) -> format "pattern" props children level
-            | Polygon (props, children) -> format "polygon" props children level
-            | Polyline (props, children) -> format "polyline" props children level
-            | RadialGradient (props, children) -> format "radient" props children level
-            | Rect (props, children) -> format "rect" props children level
-            | Stop (props, children) -> format "stop" props children level
-            | Text (props, children) -> format "text" props children level
-            | Tspan (props, children) -> format "tspan" props children level
+            | A(props, children) -> format "a" props children level
+            | Abbr(props, children) -> format "abbr" props children level
+            | Address(props, children) -> format "address" props children level
+            | Area(props) -> formatVoid "area" props level
+            | Article(props, children) -> format "article" props children level
+            | Aside(props, children) -> format "aside" props children level
+            | Audio(props, children) -> format "audio" props children level
+            | B(props, children) -> format "b" props children level
+            | Base(props) -> formatVoid "base" props level
+            | Bdi(props, children) -> format "bdi" props children level
+            | Bdo(props, children) -> format "bdo" props children level
+            | Big(props, children) -> format "big" props children level
+            | Blockquote(props, children) -> format "blockquote" props children level
+            | Body(props, children) -> format "body" props children level
+            | Br(props) -> formatVoid "br" props level
+            | Button(props, children) -> format "button" props children level
+            | Canvas(props, children) -> format "canvas" props children level
+            | Caption(props, children) -> format "caption" props children level
+            | Cite(props, children) -> format "cite" props children level
+            | Code(props, children) -> format "code" props children level
+            | Col(props) -> formatVoid "col" props level
+            | Colgroup(props, children) -> format "colgroup" props children level
+            | Data(props, children) -> format "data" props children level
+            | Datalist(props, children) -> format "datalist" props children level
+            | Dd(props, children) -> format "dd" props children level
+            | Del(props, children) -> format "del" props children level
+            | Details(props, children) -> format "details" props children level
+            | Dfn(props, children) -> format "dfn" props children level
+            | Dialog(props, children) -> format "dialog" props children level
+            | Div(props, children) -> format "div" props children level
+            | Dl(props, children) -> format "dl" props children level
+            | Dt(props, children) -> format "dt" props children level
+            | Em(props, children) -> format "em" props children level
+            | Embed(props) -> formatVoid "embed" props level
+            | Fieldset(props, children) -> format "fieldset" props children level
+            | Figcaption(props, children) -> format "figcaption" props children level
+            | Figure(props, children) -> format "figure" props children level
+            | Footer(props, children) -> format "footer" props children level
+            | Form(props, children) -> format "form" props children level
+            | H1(props, children) -> format "h1" props children level
+            | H2(props, children) -> format "h2" props children level
+            | H3(props, children) -> format "h3" props children level
+            | H4(props, children) -> format "h4" props children level
+            | H5(props, children) -> format "h5" props children level
+            | H6(props, children) -> format "h6" props children level
+            | Head(props, children) -> format "head" props children level
+            | Header(props, children) -> format "header" props children level
+            | Hgroup(props, children) -> format "hgroup" props children level
+            | Hr(props) -> formatVoid "hr" props level
+            | Html(props, children) -> format "html" props children level
+            | I(props, children) -> format "i" props children level
+            | Iframe(props, children) -> format "iframe" props children level
+            | Img(props) -> formatVoid "img" props level
+            | Input(props) -> formatVoid "input" props level
+            | Ins(props, children) -> format "ins" props children level
+            | Kbd(props, children) -> format "kbd" props children level
+            | Keygen(props) -> formatVoid "keygen" props level
+            | Label(props, children) -> format "label" props children level
+            | Legend(props, children) -> format "legend" props children level
+            | Li(props, children) -> format "li" props children level
+            | Link(props) -> formatVoid "link" props level
+            | Main(props, children) -> format "main" props children level
+            | Map(props, children) -> format "map" props children level
+            | Mark(props, children) -> format "mark" props children level
+            | Menu(props, children) -> format "menu" props children level
+            | Menuitem(props) -> formatVoid "menuitem" props level
+            | Meta(props) -> formatVoid "meta" props level
+            | Meter(props, children) -> format "meter" props children level
+            | Nav(props, children) -> format "nav" props children level
+            | Noscript(props, children) -> format "noscript" props children level
+            | Object(props, children) -> format "object" props children level
+            | Ol(props, children) -> format "ol" props children level
+            | Optgroup(props, children) -> format "optgroup" props children level
+            | Option(props, children) -> format "option" props children level
+            | Output(props, children) -> format "output" props children level
+            | P(props, children) -> format "p" props children level
+            | Param(props) -> formatVoid "param" props level
+            | Picture(props, children) -> format "picture" props children level
+            | Pre(props, children) -> format "pre" props children level
+            | Progress(props, children) -> format "progress" props children level
+            | Q(props, children) -> format "q" props children level
+            | Rp(props, children) -> format "rp" props children level
+            | Rt(props, children) -> format "rt" props children level
+            | Ruby(props, children) -> format "ruby" props children level
+            | S(props, children) -> format "s" props children level
+            | Samp(props, children) -> format "samp" props children level
+            | Script(props, children) -> format "script" props children level
+            | Section(props, children) -> format "section" props children level
+            | Select(props, children) -> format "select" props children level
+            | Small(props, children) -> format "small" props children level
+            | Source(props) -> formatVoid "source" props level
+            | Span(props, children) -> format "span" props children level
+            | Strong(props, children) -> format "strong" props children level
+            | Style(props, children) -> format "style" props children level
+            | Sub(props, children) -> format "sub" props children level
+            | Summary(props, children) -> format "summary" props children level
+            | Sup(props, children) -> format "sup" props children level
+            | Table(props, children) -> format "table" props children level
+            | Tbody(props, children) -> format "tbody" props children level
+            | Td(props, children) -> format "td" props children level
+            | Textarea(props, children) -> format "textarea" props children level
+            | Tfoot(props, children) -> format "tfoot" props children level
+            | Th(props, children) -> format "th" props children level
+            | Thead(props, children) -> format "thead" props children level
+            | Time(props, children) -> format "time" props children level
+            | Title(props, children) -> format "title" props children level
+            | Tr(props, children) -> format "tr" props children level
+            | Track(props) -> formatVoid "track" props level
+            | U(props, children) -> format "u" props children level
+            | Ul(props, children) -> format "ul" props children level
+            | Var(props, children) -> format "var" props children level
+            | Video(props, children) -> format "video" props children level
+            | Wbr(props) -> formatVoid "wbr" props level
+            | Svg(props, children) -> format "svg" props children level
+            | Circle(props, children) -> format "circle" props children level
+            | Defs(props, children) -> format "defs" props children level
+            | Ellipse(props, children) -> format "ellipse" props children level
+            | G(props, children) -> format "g" props children level
+            | Image(props, children) -> format "image" props children level
+            | Line(props, children) -> format "line" props children level
+            | LinearGradient(props, children) -> format "radient" props children level
+            | Mask(props, children) -> format "mask" props children level
+            | Path(props, children) -> format "path" props children level
+            | Pattern(props, children) -> format "pattern" props children level
+            | Polygon(props, children) -> format "polygon" props children level
+            | Polyline(props, children) -> format "polyline" props children level
+            | RadialGradient(props, children) -> format "radient" props children level
+            | Rect(props, children) -> format "rect" props children level
+            | Stop(props, children) -> format "stop" props children level
+            | Text(props, children) -> format "text" props children level
+            | Tspan(props, children) -> format "tspan" props children level
             | String str -> str
             | EncodeString str -> System.Web.HttpUtility.HtmlEncode str
 
diff --git a/src/FSharp.Formatting.Common/Menu.fs b/src/FSharp.Formatting.Common/Menu.fs
index a33a1758a..4968b3a3f 100644
--- a/src/FSharp.Formatting.Common/Menu.fs
+++ b/src/FSharp.Formatting.Common/Menu.fs
@@ -7,10 +7,7 @@ open FSharp.Formatting.Templating
 type MenuItem = { Link: string; Content: string }
 
 let private snakeCase (v: string) =
-    System
-        .Text
-        .RegularExpressions
-        .Regex
+    System.Text.RegularExpressions.Regex
         .Replace(v, "[A-Z]", "$0")
         .Replace(" ", "_")
         .ToLower()
diff --git a/src/FSharp.Formatting.Common/PynbModel.fs b/src/FSharp.Formatting.Common/PynbModel.fs
index 5dea32ed2..389d57363 100644
--- a/src/FSharp.Formatting.Common/PynbModel.fs
+++ b/src/FSharp.Formatting.Common/PynbModel.fs
@@ -14,7 +14,7 @@ type OutputData =
     | OutputData of kind: string * lines: string[]
 
     override this.ToString() =
-        let (OutputData (kind, lines)) = this
+        let (OutputData(kind, lines)) = this
 
         sprintf
             """
@@ -41,7 +41,7 @@ type Output =
             (this.data.ToString())
             (match this.execution_count with
              | None -> "null"
-             | Some (x) -> string x)
+             | Some(x) -> string x)
             this.metadata
             this.output_type
 
@@ -88,7 +88,7 @@ type Cell =
                      """"execution_count": %s, "outputs": [%s],"""
                      (match this.execution_count with
                       | None -> "null"
-                      | Some (x) -> string x)
+                      | Some(x) -> string x)
                      (this.outputs |> Array.map string |> String.concat ",\n")))
             (this.source
              |> Array.map addLineEnd
diff --git a/src/FSharp.Formatting.Common/YaafFSharpScripting.fs b/src/FSharp.Formatting.Common/YaafFSharpScripting.fs
index e011434ae..36f9b6ff2 100644
--- a/src/FSharp.Formatting.Common/YaafFSharpScripting.fs
+++ b/src/FSharp.Formatting.Common/YaafFSharpScripting.fs
@@ -326,13 +326,7 @@ type internal InteractionOutputs =
 
 /// This exception indicates that an exception happened while compiling or executing given F# code.
 type internal FsiEvaluationException
-    (
-        msg: string,
-        input: string,
-        args: string list option,
-        result: InteractionOutputs,
-        inner: System.Exception
-    ) =
+    (msg: string, input: string, args: string list option, result: InteractionOutputs, inner: System.Exception) =
     inherit Exception(msg, inner)
 
     member x.Result = result
@@ -585,35 +579,64 @@ type internal FsiOptions =
                     let parsed, (userArgs, newCont) = cont arg
                     parsed, (userArgs, unbox newCont)
                 | _, "--" -> parsed, (true, None)
-                | (true, _), a -> { parsed with ScriptArgs = a :: parsed.ScriptArgs }, state
+                | (true, _), a ->
+                    { parsed with
+                        ScriptArgs = a :: parsed.ScriptArgs },
+                    state
                 | _, FsiBoolArg "--checked" enabled -> { parsed with Checked = Some enabled }, state
                 | _, StartsWith "--codepage:" res -> { parsed with Codepage = Some(int res) }, state
-                | _, FsiBoolArg "--crossoptimize" enabled -> { parsed with CrossOptimize = Some enabled }, state
+                | _, FsiBoolArg "--crossoptimize" enabled ->
+                    { parsed with
+                        CrossOptimize = Some enabled },
+                    state
                 | _, StartsWith "--debug:" "pdbonly"
-                | _, StartsWith "-g:" "pdbonly" -> { parsed with Debug = Some DebugMode.PdbOnly }, state
+                | _, StartsWith "-g:" "pdbonly" ->
+                    { parsed with
+                        Debug = Some DebugMode.PdbOnly },
+                    state
                 | _, StartsWith "--debug:" "portable"
-                | _, StartsWith "-g:" "portable" -> { parsed with Debug = Some DebugMode.Portable }, state
+                | _, StartsWith "-g:" "portable" ->
+                    { parsed with
+                        Debug = Some DebugMode.Portable },
+                    state
                 | _, StartsWith "--debug:" "full"
                 | _, StartsWith "-g:" "full"
                 | _, FsiBoolArg "--debug" true
-                | _, FsiBoolArg "-g" true -> { parsed with Debug = Some DebugMode.Full }, state
+                | _, FsiBoolArg "-g" true ->
+                    { parsed with
+                        Debug = Some DebugMode.Full },
+                    state
                 | _, FsiBoolArg "--debug" false
-                | _, FsiBoolArg "-g" false -> { parsed with Debug = Some DebugMode.NoDebug }, state
+                | _, FsiBoolArg "-g" false ->
+                    { parsed with
+                        Debug = Some DebugMode.NoDebug },
+                    state
                 | _, StartsWith "-d:" def
-                | _, StartsWith "--define:" def -> { parsed with Defines = def :: parsed.Defines }, state
+                | _, StartsWith "--define:" def ->
+                    { parsed with
+                        Defines = def :: parsed.Defines },
+                    state
                 | _, "--exec" -> { parsed with Exec = true }, state
                 | _, "--noninteractive" -> { parsed with NonInteractive = true }, state
                 | _, "--fullpaths" -> { parsed with FullPaths = true }, state
                 | _, FsiBoolArg "--gui" enabled -> { parsed with Gui = Some enabled }, state
                 | _, StartsWith "-I:" lib
-                | _, StartsWith "--lib:" lib -> { parsed with LibDirs = lib :: parsed.LibDirs }, state
-                | _, StartsWith "--load:" load -> { parsed with Loads = load :: parsed.Loads }, state
+                | _, StartsWith "--lib:" lib ->
+                    { parsed with
+                        LibDirs = lib :: parsed.LibDirs },
+                    state
+                | _, StartsWith "--load:" load ->
+                    { parsed with
+                        Loads = load :: parsed.Loads },
+                    state
                 | _, "--noframework" -> { parsed with NoFramework = true }, state
                 | _, "--nologo" -> { parsed with NoLogo = true }, state
                 | _, StartsWith "--nowarn:" warns ->
                     let noWarns = warns.Split([| ',' |]) |> Seq.map int |> Seq.toList
 
-                    { parsed with NoWarns = noWarns @ parsed.NoWarns }, state
+                    { parsed with
+                        NoWarns = noWarns @ parsed.NoWarns },
+                    state
                 | _, FsiBoolArg "--optimize" enabled ->
                     let cont (arg: string) =
                         let optList =
@@ -627,19 +650,35 @@ type internal FsiOptions =
                                 | unknown -> failwithf "Unknown optimization option %s" unknown)
                             |> Seq.toList
 
-                        { parsed with Optimize = (enabled, optList) :: parsed.Optimize }, (false, box None)
+                        { parsed with
+                            Optimize = (enabled, optList) :: parsed.Optimize },
+                        (false, box None)
 
-                    { parsed with Optimize = (enabled, []) :: parsed.Optimize }, (false, Some cont)
+                    { parsed with
+                        Optimize = (enabled, []) :: parsed.Optimize },
+                    (false, Some cont)
                 | _, "--quiet" -> { parsed with Quiet = true }, state
                 | _, "--quotations-debug" -> { parsed with QuotationsDebug = true }, state
                 | _, FsiBoolArg "--readline" enabled -> { parsed with ReadLine = Some enabled }, state
                 | _, StartsWith "-r:" ref
-                | _, StartsWith "--reference:" ref -> { parsed with References = ref :: parsed.References }, state
+                | _, StartsWith "--reference:" ref ->
+                    { parsed with
+                        References = ref :: parsed.References },
+                    state
                 | _, FsiBoolArg "--tailcalls" enabled -> { parsed with TailCalls = Some enabled }, state
-                | _, StartsWith "--use:" useFile -> { parsed with Uses = useFile :: parsed.Uses }, state
+                | _, StartsWith "--use:" useFile ->
+                    { parsed with
+                        Uses = useFile :: parsed.Uses },
+                    state
                 | _, "--utf8output" -> { parsed with Utf8Output = true }, state
-                | _, StartsWith "--warn:" warn -> { parsed with WarnLevel = Some(int warn) }, state
-                | _, FsiBoolArg "--warnaserror" enabled -> { parsed with WarnAsError = Some enabled }, state
+                | _, StartsWith "--warn:" warn ->
+                    { parsed with
+                        WarnLevel = Some(int warn) },
+                    state
+                | _, FsiBoolArg "--warnaserror" enabled ->
+                    { parsed with
+                        WarnAsError = Some enabled },
+                    state
                 | _, StartsWith "--warnaserror" warnOpts ->
                     let parseList (l: string) =
                         l.Split [| ',' |] |> Seq.map int |> Seq.toList
@@ -659,7 +698,10 @@ type internal FsiOptions =
                         state
                     | _ -> failwithf "invalid --warnaserror argument: %s" arg
                 | _, FsiBoolArg "--multiemit" enabled -> { parsed with MultiEmit = Some enabled }, state
-                | _, unknown -> { parsed with ScriptArgs = unknown :: parsed.ScriptArgs }, (true, None))
+                | _, unknown ->
+                    { parsed with
+                        ScriptArgs = unknown :: parsed.ScriptArgs },
+                    (true, None))
             (FsiOptions.Empty, (false, None))
         |> fst
         |> (fun p ->
@@ -876,16 +918,7 @@ module internal Helper =
             Console.SetError defErr
 
 type internal FsiSession
-    (
-        fsi: obj,
-        options: FsiOptions,
-        reportGlobal,
-        liveOut,
-        liveOutFsi,
-        liveErr,
-        liveErrFsi,
-        discardStdOut
-    ) =
+    (fsi: obj, options: FsiOptions, reportGlobal, liveOut, liveOutFsi, liveErr, liveErrFsi, discardStdOut) =
     // Intialize output and input streams
     let out = new OutStreamHelper(reportGlobal, liveOut, liveOutFsi)
 
@@ -928,7 +961,8 @@ type internal FsiSession
             let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration(fsi, false)
 
             redirectOut (fun () ->
-                let session = FsiEvaluationSession.Create(fsiConfig, args, inStream, out.FsiOutWriter, err.FsiOutWriter)
+                let session =
+                    FsiEvaluationSession.Create(fsiConfig, args, inStream, out.FsiOutWriter, err.FsiOutWriter)
 
                 saveOutput () |> ignore
                 session)
@@ -976,7 +1010,10 @@ type internal FsiSession
         [ for d in diags -> d.ToString() + Environment.NewLine ] |> String.concat ""
 
     let addDiagsToFsiOutput (o: InteractionOutputs) diags =
-        { o with Output = { o.Output with FsiOutput = diagsToString diags + o.Output.FsiOutput } }
+        { o with
+            Output =
+                { o.Output with
+                    FsiOutput = diagsToString diags + o.Output.FsiOutput } }
 
     member _.EvalInteraction text =
         let i, (r, diags) = evalInteraction text
@@ -1061,7 +1098,9 @@ type internal ScriptHost() =
             ?fsiErrWriter: TextWriter,
             ?discardStdOut
         ) =
-        let opts = { FsiOptions.Default with Defines = defaultArg defines [] }
+        let opts =
+            { FsiOptions.Default with
+                Defines = defaultArg defines [] }
 
         ScriptHost.Create(
             opts,
diff --git a/src/FSharp.Formatting.Literate/Document.fs b/src/FSharp.Formatting.Literate/Document.fs
index 958c536f6..94ced79ce 100644
--- a/src/FSharp.Formatting.Literate/Document.fs
+++ b/src/FSharp.Formatting.Literate/Document.fs
@@ -93,16 +93,16 @@ type LiterateParagraph =
 
     member x.ParagraphOptions =
         match x with
-        | CodeReference (_, popts) -> popts
-        | FsiMergedOutputReference (_, popts) -> popts
-        | FsiOutputReference (_, popts) -> popts
-        | OutputReference (_, popts) -> popts
-        | ItValueReference (_, popts) -> popts
-        | ItRawReference (_, popts) -> popts
-        | ValueReference (_, popts) -> popts
-        | LiterateCode (_, _, popts) -> popts
-        | LanguageTaggedCode (_, _, popts) -> popts
-        | RawBlock (_, popts) -> popts
+        | CodeReference(_, popts) -> popts
+        | FsiMergedOutputReference(_, popts) -> popts
+        | FsiOutputReference(_, popts) -> popts
+        | OutputReference(_, popts) -> popts
+        | ItValueReference(_, popts) -> popts
+        | ItRawReference(_, popts) -> popts
+        | ValueReference(_, popts) -> popts
+        | LiterateCode(_, _, popts) -> popts
+        | LanguageTaggedCode(_, _, popts) -> popts
+        | RawBlock(_, popts) -> popts
 
     interface MarkdownEmbedParagraphs with
         member x.Render() =
@@ -179,5 +179,5 @@ type LiterateDocument(paragraphs, formattedTips, links, source, sourceFile, root
 module MarkdownPatterns =
     let (|LiterateParagraph|_|) =
         function
-        | EmbedParagraphs (:? LiterateParagraph as lp, _) -> Some lp
+        | EmbedParagraphs(:? LiterateParagraph as lp, _) -> Some lp
         | _ -> None
diff --git a/src/FSharp.Formatting.Literate/Evaluator.fs b/src/FSharp.Formatting.Literate/Evaluator.fs
index b8d314871..dd27ea5c6 100644
--- a/src/FSharp.Formatting.Literate/Evaluator.fs
+++ b/src/FSharp.Formatting.Literate/Evaluator.fs
@@ -187,7 +187,8 @@ type FsiEvaluator
 
     let fsiOptions =
         if addHtmlPrinter then
-            { fsiOptions with Defines = fsiOptions.Defines @ [ "HAS_FSI_ADDHTMLPRINTER" ] }
+            { fsiOptions with
+                Defines = fsiOptions.Defines @ [ "HAS_FSI_ADDHTMLPRINTER" ] }
         else
             fsiOptions
 
@@ -482,7 +483,7 @@ module __FsiSettings =
 
                 let output = outputText.Trim()
                 [ OutputBlock(output, "text/plain", Some executionCount) ]
-            | { ItValue = Some (obj, ty) }, FsiEmbedKind.ItRaw ->
+            | { ItValue = Some(obj, ty) }, FsiEmbedKind.ItRaw ->
                 match
                     valueTransformations
                     |> Seq.pick (fun f -> lock lockObj (fun () -> f (obj, ty, executionCount)))
@@ -491,7 +492,7 @@ module __FsiSettings =
                 | blocks ->
                     blocks
                     |> List.map (function
-                        | OutputBlock (output, _, Some executionCount) ->
+                        | OutputBlock(output, _, Some executionCount) ->
                             let output =
                                 if ty.FullName = (typeof).FullName then
                                     let l = output.Length
@@ -501,8 +502,8 @@ module __FsiSettings =
 
                             OutputBlock(output, "text/html", Some executionCount)
                         | _ -> OutputBlock("Value could not be returned raw", "text/plain", Some executionCount))
-            | { ItValue = Some (obj, ty) }, FsiEmbedKind.ItValue
-            | { Result = Some (obj, ty) }, FsiEmbedKind.Value ->
+            | { ItValue = Some(obj, ty) }, FsiEmbedKind.ItValue
+            | { Result = Some(obj, ty) }, FsiEmbedKind.Value ->
                 match
                     valueTransformations
                     |> Seq.pick (fun f -> lock lockObj (fun () -> f (obj, ty, executionCount)))
diff --git a/src/FSharp.Formatting.Literate/Formatting.fs b/src/FSharp.Formatting.Literate/Formatting.fs
index 0e461d6cb..95233b037 100644
--- a/src/FSharp.Formatting.Literate/Formatting.fs
+++ b/src/FSharp.Formatting.Literate/Formatting.fs
@@ -61,7 +61,7 @@ module internal Formatting =
         paragraphs
         |> Seq.tryPick (fun para ->
             match para with
-            | Heading (1, text, r) ->
+            | Heading(1, text, r) ->
                 match outputKind with
                 | OutputKind.Html
                 | OutputKind.Latex ->
@@ -80,7 +80,7 @@ module internal Formatting =
             let mutable count = 0
 
             let paragraphs =
-                [ for Snippet (name, lines) in snippets do
+                [ for Snippet(name, lines) in snippets do
                       if snippets.Length > 1 then
                           yield Heading(3, [ Literal(name, None) ], None)
 
@@ -104,8 +104,8 @@ module internal Formatting =
         match doc.Source with
         | LiterateSource.Markdown text -> text
         | LiterateSource.Script snippets ->
-            [ for Snippet (_name, lines) in snippets do
-                  for (Line (line, _)) in lines do
+            [ for Snippet(_name, lines) in snippets do
+                  for (Line(line, _)) in lines do
                       yield line ]
             |> String.concat "\n"
 
@@ -113,7 +113,7 @@ module internal Formatting =
 
         let findInFrontMatter key =
             match doc.Paragraphs with
-            | YamlFrontmatter (lines, _) :: _ ->
+            | YamlFrontmatter(lines, _) :: _ ->
                 lines
                 |> List.tryPick (fun line ->
                     let line = line.Trim()
@@ -169,7 +169,8 @@ module internal Formatting =
 
         let substitutions0 =
             [ ParamKeys.``fsdocs-page-title``, pageTitle; ParamKeys.``fsdocs-page-source``, doc.SourceFile ]
-            @ ctx.Substitutions @ sourceSubstitutions
+            @ ctx.Substitutions
+            @ sourceSubstitutions
 
         let formattedDocument =
             format
diff --git a/src/FSharp.Formatting.Literate/Literate.fs b/src/FSharp.Formatting.Literate/Literate.fs
index f18f8c24b..33d008a4c 100644
--- a/src/FSharp.Formatting.Literate/Literate.fs
+++ b/src/FSharp.Formatting.Literate/Literate.fs
@@ -55,18 +55,18 @@ type Literate private () =
     /// When generating LaTeX, we need to save all files locally
     static let rec downloadSpanImages (saver, links) para =
         match para with
-        | IndirectImage (body, _, LookupKey links (link, title), range)
-        | DirectImage (body, link, title, range) -> DirectImage(body, saver link, title, range)
-        | MarkdownPatterns.SpanNode (s, spans) ->
+        | IndirectImage(body, _, LookupKey links (link, title), range)
+        | DirectImage(body, link, title, range) -> DirectImage(body, saver link, title, range)
+        | MarkdownPatterns.SpanNode(s, spans) ->
             MarkdownPatterns.SpanNode(s, List.map (downloadSpanImages (saver, links)) spans)
-        | MarkdownPatterns.SpanLeaf (l) -> MarkdownPatterns.SpanLeaf(l)
+        | MarkdownPatterns.SpanLeaf(l) -> MarkdownPatterns.SpanLeaf(l)
 
     static let rec downloadImages ctx (pars: MarkdownParagraphs) : MarkdownParagraphs =
         pars
         |> List.map (function
-            | MarkdownPatterns.ParagraphSpans (s, spans) ->
+            | MarkdownPatterns.ParagraphSpans(s, spans) ->
                 MarkdownPatterns.ParagraphSpans(s, List.map (downloadSpanImages ctx) spans)
-            | MarkdownPatterns.ParagraphNested (o, pars) ->
+            | MarkdownPatterns.ParagraphNested(o, pars) ->
                 MarkdownPatterns.ParagraphNested(o, List.map (downloadImages ctx) pars)
             | MarkdownPatterns.ParagraphLeaf p -> MarkdownPatterns.ParagraphLeaf p)
 
diff --git a/src/FSharp.Formatting.Literate/ParseScript.fs b/src/FSharp.Formatting.Literate/ParseScript.fs
index 07e686100..f022663bf 100644
--- a/src/FSharp.Formatting.Literate/ParseScript.fs
+++ b/src/FSharp.Formatting.Literate/ParseScript.fs
@@ -20,12 +20,12 @@ module internal CodeBlockUtils =
     let private trimBlanksAndReverse lines =
         lines
         |> Seq.skipWhile (function
-            | Line (_, []) -> true
+            | Line(_, []) -> true
             | _ -> false)
         |> List.ofSeq
         |> List.rev
         |> Seq.skipWhile (function
-            | Line (_, []) -> true
+            | Line(_, []) -> true
             | _ -> false)
         |> List.ofSeq
 
@@ -35,12 +35,12 @@ module internal CodeBlockUtils =
     /// Succeeds when a line (list of tokens) contains only Comment
     /// tokens and returns the text from the comment as a string
     /// (Comment may also be followed by Whitespace that is skipped)
-    let private (|ConcatenatedComments|_|) (Line (_, tokens)) =
+    let private (|ConcatenatedComments|_|) (Line(_, tokens)) =
         let rec readComments inWhite acc =
             function
-            | TokenSpan.Token (TokenKind.Comment, text, _) :: tokens when not inWhite ->
+            | TokenSpan.Token(TokenKind.Comment, text, _) :: tokens when not inWhite ->
                 readComments false (text :: acc) tokens
-            | TokenSpan.Token (TokenKind.Default, String.WhiteSpace _, _) :: tokens -> readComments true acc tokens
+            | TokenSpan.Token(TokenKind.Default, String.WhiteSpace _, _) :: tokens -> readComments true acc tokens
             | [] -> Some(String.concat "" (List.rev acc))
             | _ -> None
 
@@ -63,7 +63,7 @@ module internal CodeBlockUtils =
                 cend
 
             match lines with
-            | (ConcatenatedComments (String.StartsAndEndsWith ("(***", "***)") (ParseCommands cmds))) :: lines ->
+            | (ConcatenatedComments(String.StartsAndEndsWith ("(***", "***)") (ParseCommands cmds))) :: lines ->
                 // Ended with a command, yield comment, command & parse the next as a snippet
                 let cend = findCommentEnd comment
                 yield BlockComment(comment.Substring(0, cend))
@@ -76,7 +76,7 @@ module internal CodeBlockUtils =
                 yield BlockComment(comment.Substring(0, cend))
                 yield! collectSnippet [] lines
 
-            | (Line (_, [ TokenSpan.Token (TokenKind.Comment, String.StartsWith "(**" text, _) ])) :: lines ->
+            | (Line(_, [ TokenSpan.Token(TokenKind.Comment, String.StartsWith "(**" text, _) ])) :: lines ->
                 // Another block of Markdown comment starting...
                 // Yield the previous snippet block and continue parsing more comments
                 let cend = findCommentEnd comment
@@ -106,7 +106,7 @@ module internal CodeBlockUtils =
 
         seq {
             match lines with
-            | (ConcatenatedComments (String.StartsAndEndsWith ("(***", "***)") (ParseCommands cmds))) :: lines ->
+            | (ConcatenatedComments(String.StartsAndEndsWith ("(***", "***)") (ParseCommands cmds))) :: lines ->
                 // Found a special command, yield snippet, command and parse another snippet
                 if acc <> [] then
                     yield blockSnippet acc
@@ -114,7 +114,7 @@ module internal CodeBlockUtils =
                 yield BlockCommand cmds
                 yield! collectSnippet [] lines
 
-            | (Line (_, [ TokenSpan.Token (TokenKind.Comment, String.StartsWith "(**" text, _) ])) :: lines ->
+            | (Line(_, [ TokenSpan.Token(TokenKind.Comment, String.StartsWith "(**" text, _) ])) :: lines ->
                 // Found a comment - yield snippet & switch to parsing comment state
                 // (Also trim leading spaces to support e.g.: `(** ## Hello **)`)
                 if acc <> [] then
@@ -158,10 +158,10 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
     let rec transformBlocks isFirst prevCodeId count noEval acc defs blocks =
         match blocks with
         // Disable evaluation for the rest of the file
-        | BlockCommand (Command "do-not-eval-file" _) :: blocks -> transformBlocks false None count true acc defs blocks
+        | BlockCommand(Command "do-not-eval-file" _) :: blocks -> transformBlocks false None count true acc defs blocks
 
         // Reference to code snippet defined later
-        | BlockCommand ((Command "include" ref) as cmds) :: blocks ->
+        | BlockCommand((Command "include" ref) as cmds) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(CodeReference(ref, popts), None)
@@ -169,7 +169,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false None count noEval (p :: acc) defs blocks
 
         // Include console output (stdout) of previous block
-        | BlockCommand (Command "include-output" "" as cmds) :: blocks when prevCodeId.IsSome ->
+        | BlockCommand(Command "include-output" "" as cmds) :: blocks when prevCodeId.IsSome ->
             let popts = getParaOptions cmds
 
             let p1 = EmbedParagraphs(OutputReference(prevCodeId.Value, popts), None)
@@ -177,7 +177,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p1 :: acc) defs blocks
 
         // Include console output (stdout) of a named block
-        | BlockCommand (Command "include-output" ref as cmds) :: blocks ->
+        | BlockCommand(Command "include-output" ref as cmds) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(OutputReference(ref, popts), None)
@@ -185,7 +185,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p :: acc) defs blocks
 
         // Include FSI output (stdout) of previous block
-        | BlockCommand (Command "include-fsi-output" "" as cmds) :: blocks when prevCodeId.IsSome ->
+        | BlockCommand(Command "include-fsi-output" "" as cmds) :: blocks when prevCodeId.IsSome ->
             let popts = getParaOptions cmds
 
             let p1 = EmbedParagraphs(FsiOutputReference(prevCodeId.Value, popts), None)
@@ -193,7 +193,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p1 :: acc) defs blocks
 
         // Include FSI output (stdout) of a named block
-        | BlockCommand (Command "include-fsi-output" ref as cmds) :: blocks ->
+        | BlockCommand(Command "include-fsi-output" ref as cmds) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(FsiOutputReference(ref, popts), None)
@@ -201,7 +201,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p :: acc) defs blocks
 
         // Include the merge of the console and FSI output (stdout) of previous block
-        | BlockCommand (Command "include-fsi-merged-output" "" as cmds) :: blocks when prevCodeId.IsSome ->
+        | BlockCommand(Command "include-fsi-merged-output" "" as cmds) :: blocks when prevCodeId.IsSome ->
             let popts = getParaOptions cmds
 
             let p1 = EmbedParagraphs(FsiMergedOutputReference(prevCodeId.Value, popts), None)
@@ -209,7 +209,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p1 :: acc) defs blocks
 
         // Include the merge of the console and FSI output (stdout) of a named block
-        | BlockCommand (Command "include-fsi-merged-output" ref as cmds) :: blocks ->
+        | BlockCommand(Command "include-fsi-merged-output" ref as cmds) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(FsiMergedOutputReference(ref, popts), None)
@@ -217,7 +217,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p :: acc) defs blocks
 
         // Include formatted 'it' of previous block
-        | BlockCommand ((Command "include-it" "") as cmds) :: blocks when prevCodeId.IsSome ->
+        | BlockCommand((Command "include-it" "") as cmds) :: blocks when prevCodeId.IsSome ->
             let popts = getParaOptions cmds
 
             let p1 = EmbedParagraphs(ItValueReference(prevCodeId.Value, popts), None)
@@ -225,7 +225,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p1 :: acc) defs blocks
 
         // Include formatted 'it' of a named block
-        | BlockCommand (Command "include-it" ref as cmds) :: blocks ->
+        | BlockCommand(Command "include-it" ref as cmds) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(ItValueReference(ref, popts), None)
@@ -233,7 +233,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false None count noEval (p :: acc) defs blocks
 
         // Include unformatted 'it' of previous block
-        | BlockCommand ((Command "include-it-raw" "") as cmds) :: blocks when prevCodeId.IsSome ->
+        | BlockCommand((Command "include-it-raw" "") as cmds) :: blocks when prevCodeId.IsSome ->
             let popts = getParaOptions cmds
 
             let p1 = EmbedParagraphs(ItRawReference(prevCodeId.Value, popts), None)
@@ -241,7 +241,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false prevCodeId count noEval (p1 :: acc) defs blocks
 
         // Include unformatted 'it' of a named block
-        | BlockCommand (Command "include-it-raw" ref as cmds) :: blocks ->
+        | BlockCommand(Command "include-it-raw" ref as cmds) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(ItRawReference(ref, popts), None)
@@ -249,7 +249,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false None count noEval (p :: acc) defs blocks
 
         // Include formatted named value
-        | BlockCommand (Command "include-value" ref as cmds) :: blocks ->
+        | BlockCommand(Command "include-value" ref as cmds) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(ValueReference(ref, popts), None)
@@ -257,7 +257,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false None count noEval (p :: acc) defs blocks
 
         // Include code without evaluation
-        | BlockCommand (Command "raw" _ as cmds) :: BlockSnippet (snip) :: blocks ->
+        | BlockCommand(Command "raw" _ as cmds) :: BlockSnippet(snip) :: blocks ->
             let popts = getParaOptions cmds
 
             let p = EmbedParagraphs(RawBlock(snip, popts), None)
@@ -269,7 +269,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
         //  * do-not-eval - the snippet will not be evaluated
         //  * define:foo - specifies the name of this snippet (for inclusion later)
         //  * define-output - defines the name for the snippet's output
-        | BlockCommand (cmds) :: BlockSnippet (snip) :: blocks ->
+        | BlockCommand(cmds) :: BlockSnippet(snip) :: blocks ->
             let outputName =
                 match cmds with
                 | Command "define-output" name -> name
@@ -290,14 +290,14 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false (Some outputName) count noEval (code :: acc) defs blocks
 
         // Unknown command
-        | BlockCommand (cmds) :: _ ->
-            failwithf "Unknown command: %A" [ for (KeyValue (k, v)) in cmds -> sprintf "%s:%s" k v ]
+        | BlockCommand(cmds) :: _ ->
+            failwithf "Unknown command: %A" [ for (KeyValue(k, v)) in cmds -> sprintf "%s:%s" k v ]
 
         // Skip snippets with no content
-        | BlockSnippet ([]) :: blocks -> transformBlocks isFirst prevCodeId count noEval acc defs blocks
+        | BlockSnippet([]) :: blocks -> transformBlocks isFirst prevCodeId count noEval acc defs blocks
 
         // Ordinary F# code snippet
-        | BlockSnippet (snip) :: blocks ->
+        | BlockSnippet(snip) :: blocks ->
             let id =
                 incr count
                 "cell" + string count.Value
@@ -315,7 +315,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             transformBlocks false (Some id) count noEval (p :: acc) defs blocks
 
         // Markdown documentation block
-        | BlockComment (text) :: blocks ->
+        | BlockComment(text) :: blocks ->
             // yaml frontmatter
             let parseOptions =
                 if isFirst then
@@ -335,7 +335,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             // Union all link definitions & return Markdown doc
             let allDefs =
                 [ for def in defs do
-                      for (KeyValue (k, v)) in def -> k, v ]
+                      for (KeyValue(k, v)) in def -> k, v ]
                 |> dict
 
             List.rev acc, allDefs
@@ -353,7 +353,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
 
         let mutable fail = false
 
-        for (SourceError ((l0, c0), (l1, c1), kind, msg)) in diagnostics do
+        for (SourceError((l0, c0), (l1, c1), kind, msg)) in diagnostics do
             printfn
                 "   %s: %s(%d,%d)-(%d,%d) %s"
                 filePath
@@ -372,7 +372,7 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
             ctx.OnError "errors parsing or checking script"
 
         let parsedBlocks =
-            [ for Snippet (name, lines) in sourceSnippets do
+            [ for Snippet(name, lines) in sourceSnippets do
                   if name <> null then
                       yield BlockComment("## " + name)
 
diff --git a/src/FSharp.Formatting.Literate/Transformations.fs b/src/FSharp.Formatting.Literate/Transformations.fs
index 225bd81f9..774f104de 100644
--- a/src/FSharp.Formatting.Literate/Transformations.fs
+++ b/src/FSharp.Formatting.Literate/Transformations.fs
@@ -22,7 +22,7 @@ module internal Transformations =
     let rec collectCodeSnippets par =
         seq {
             match par with
-            | CodeBlock (code, _executionCount, _fence, language, _, _) ->
+            | CodeBlock(code, _executionCount, _fence, language, _, _) ->
                 match code with
                 | String.StartsWithWrapped ("[", "]") (ParseCommands cmds, String.SkipSingleLine _code) when
                     (not (String.IsNullOrWhiteSpace(language)) && language <> "fsharp")
@@ -38,11 +38,11 @@ module internal Transformations =
 
                     yield modul, code
             | MarkdownPatterns.ParagraphLeaf _ -> ()
-            | MarkdownPatterns.ParagraphNested (_, pars) ->
+            | MarkdownPatterns.ParagraphNested(_, pars) ->
                 for ps in pars do
                     for p in ps do
                         yield! collectCodeSnippets p
-            | MarkdownPatterns.ParagraphSpans (_, _spans) -> ()
+            | MarkdownPatterns.ParagraphSpans(_, _spans) -> ()
         }
 
 
@@ -52,7 +52,7 @@ module internal Transformations =
     /// Note: this processes snipppets within markdown, not snippets coming from .fsx
     let rec replaceCodeSnippets (path: string) (codeLookup: IDictionary<_, _>) para =
         match para with
-        | CodeBlock (code, _executionCount, _fence, language, _, range) ->
+        | CodeBlock(code, _executionCount, _fence, language, _, range) ->
             match code with
             | String.StartsWithWrapped ("[", "]") (ParseCommands cmds, String.SkipSingleLine code)
             | Let (dict []) (cmds, code) ->
@@ -99,7 +99,7 @@ module internal Transformations =
             | _ -> Some para
 
         // Recursively process nested paragraphs, other nodes return without change
-        | MarkdownPatterns.ParagraphNested (pn, nested) ->
+        | MarkdownPatterns.ParagraphNested(pn, nested) ->
             let pars = List.map (List.choose (replaceCodeSnippets path codeLookup)) nested
 
             MarkdownPatterns.ParagraphNested(pn, pars) |> Some
@@ -159,7 +159,7 @@ module internal Transformations =
                     )
 
                 let results =
-                    [ for (_, id), (Snippet (_, code)) in Array.zip codes snippets -> id, code ]
+                    [ for (_, id), (Snippet(_, code)) in Array.zip codes snippets -> id, code ]
                     |> dict
 
                 results, diagnostics
@@ -180,9 +180,9 @@ module internal Transformations =
         let rec collectSpanReferences span =
             seq {
                 match span with
-                | IndirectLink (_, _, key, _) -> yield key
+                | IndirectLink(_, _, key, _) -> yield key
                 | MarkdownPatterns.SpanLeaf _ -> ()
-                | MarkdownPatterns.SpanNode (_, spans) ->
+                | MarkdownPatterns.SpanNode(_, spans) ->
                     for s in spans do
                         yield! collectSpanReferences s
             }
@@ -191,11 +191,11 @@ module internal Transformations =
             seq {
                 match par with
                 | MarkdownPatterns.ParagraphLeaf _ -> ()
-                | MarkdownPatterns.ParagraphNested (_, pars) ->
+                | MarkdownPatterns.ParagraphNested(_, pars) ->
                     for ps in pars do
                         for p in ps do
                             yield! loop p
-                | MarkdownPatterns.ParagraphSpans (_, spans) ->
+                | MarkdownPatterns.ParagraphSpans(_, spans) ->
                     for s in spans do
                         yield! collectSpanReferences s
             }
@@ -208,7 +208,7 @@ module internal Transformations =
         // Replace IndirectLinks with a nice link given a single span element
         let rec replaceSpans =
             function
-            | IndirectLink (body, original, key, r) ->
+            | IndirectLink(body, original, key, r) ->
                 [ yield IndirectLink(body, original, key, r)
                   match refIndex.TryGetValue(key) with
                   | true, i ->
@@ -216,17 +216,16 @@ module internal Transformations =
                       yield DirectLink([ Literal(string i, r) ], "#rf" + DateTime.Now.ToString("yyMMddhh"), None, r)
                       yield Literal("]", r)
                   | _ -> () ]
-            | MarkdownPatterns.SpanLeaf (sl) -> [ MarkdownPatterns.SpanLeaf(sl) ]
-            | MarkdownPatterns.SpanNode (nd, spans) ->
-                [ MarkdownPatterns.SpanNode(nd, List.collect replaceSpans spans) ]
+            | MarkdownPatterns.SpanLeaf(sl) -> [ MarkdownPatterns.SpanLeaf(sl) ]
+            | MarkdownPatterns.SpanNode(nd, spans) -> [ MarkdownPatterns.SpanNode(nd, List.collect replaceSpans spans) ]
         // Given a paragraph, process it recursively and transform all spans
         let rec loop =
             function
-            | MarkdownPatterns.ParagraphNested (pn, nested) ->
+            | MarkdownPatterns.ParagraphNested(pn, nested) ->
                 MarkdownPatterns.ParagraphNested(pn, List.map (List.choose loop) nested) |> Some
-            | MarkdownPatterns.ParagraphSpans (ps, spans) ->
+            | MarkdownPatterns.ParagraphSpans(ps, spans) ->
                 MarkdownPatterns.ParagraphSpans(ps, List.collect replaceSpans spans) |> Some
-            | MarkdownPatterns.ParagraphLeaf (pl) -> MarkdownPatterns.ParagraphLeaf(pl) |> Some
+            | MarkdownPatterns.ParagraphLeaf(pl) -> MarkdownPatterns.ParagraphLeaf(pl) |> Some
 
         loop
 
@@ -307,7 +306,7 @@ module internal Transformations =
 
     /// Unparse a Line list to a string - for evaluation by fsi.
     let unparse (lines: Line list) =
-        let joinLine (Line (originalLine, _spans)) = originalLine
+        let joinLine (Line(originalLine, _spans)) = originalLine
         //spans
         //|> Seq.map (fun span -> match span with TokenSpan.Token (_,s,_) -> s | TokenSpan.Omitted (s1,s2) -> s2 | _ -> "")
         //|> String.concat ""
@@ -327,7 +326,7 @@ module internal Transformations =
         (paras: MarkdownParagraphs)
         =
         match paras with
-        | MarkdownPatterns.LiterateParagraph (para) :: paras ->
+        | MarkdownPatterns.LiterateParagraph(para) :: paras ->
 
             // Do not evaluate blocks that don't match the conditional define, typically "condition: eval" or
             // "condition: formatting".
@@ -338,7 +337,7 @@ module internal Transformations =
                 evalBlocks ctx fsi executionCountRef file acc paras
             | _ ->
                 match para with
-                | LiterateCode (snip, opts, _popts) ->
+                | LiterateCode(snip, opts, _popts) ->
                     let acc =
                         if opts.Evaluate then
                             let text = unparse snip
@@ -352,7 +351,7 @@ module internal Transformations =
 
                     evalBlocks ctx fsi executionCountRef file acc paras
 
-                | ValueReference (ref, _popts) ->
+                | ValueReference(ref, _popts) ->
                     let result = fsi.Evaluate(ref, true, Some file)
                     incr executionCountRef
                     let executionCount = executionCountRef.Value
@@ -374,21 +373,21 @@ module internal Transformations =
     /// Replace evaluation references with the results
     let rec replaceEvaluations (ctx: CompilerContext) (results: Map<_, IFsiEvaluationResult * int>) para =
         match para with
-        | MarkdownPatterns.LiterateParagraph (special) ->
+        | MarkdownPatterns.LiterateParagraph(special) ->
             match special with
-            | FsiMergedOutputReference (ref, _popts)
-            | FsiOutputReference (ref, _popts)
-            | OutputReference (ref, _popts)
-            | ItValueReference (ref, _popts)
-            | ItRawReference (ref, _popts)
-            | ValueReference (ref, _popts) ->
+            | FsiMergedOutputReference(ref, _popts)
+            | FsiOutputReference(ref, _popts)
+            | OutputReference(ref, _popts)
+            | ItValueReference(ref, _popts)
+            | ItRawReference(ref, _popts)
+            | ValueReference(ref, _popts) ->
                 let key =
                     (match special with
                      | ValueReference _ -> ValueRef ref
                      | _ -> OutputRef ref)
 
                 match results.TryFind(key) with
-                | Some (result, executionCount) ->
+                | Some(result, executionCount) ->
                     let kind =
                         match special with
                         | FsiMergedOutputReference _ -> FsiEmbedKind.FsiMergedOutput
@@ -404,16 +403,18 @@ module internal Transformations =
                     let output = "Could not find reference '" + ref + "'"
                     [ OutputBlock(output, "text/plain", None) ]
 
-            | LiterateCode (lines, opts, popts) when results.ContainsKey(OutputRef opts.OutputName) ->
+            | LiterateCode(lines, opts, popts) when results.ContainsKey(OutputRef opts.OutputName) ->
                 let _, executionCount = results.[OutputRef opts.OutputName]
 
-                let opts = { opts with ExecutionCount = Some executionCount }
+                let opts =
+                    { opts with
+                        ExecutionCount = Some executionCount }
 
                 [ EmbedParagraphs(LiterateCode(lines, opts, popts), None) ]
             | _ -> [ EmbedParagraphs(special, None) ]
 
         // Traverse all other structrues recursively
-        | MarkdownPatterns.ParagraphNested (pn, nested) ->
+        | MarkdownPatterns.ParagraphNested(pn, nested) ->
             let nested = List.map (List.collect (replaceEvaluations ctx results)) nested
 
             [ MarkdownPatterns.ParagraphNested(pn, nested) ]
@@ -439,17 +440,17 @@ module internal Transformations =
     /// between moved snippets and ordinary snippets
     let rec collectLiterateCode par =
         [ match par with
-          | MarkdownPatterns.LiterateParagraph (para) ->
+          | MarkdownPatterns.LiterateParagraph(para) ->
               //// Remove "condition: ipynb" etc. from output unless the condition is satisfied
               //match para.ParagraphOptions with
               //| { Condition=Some define } when define <> "prepare" -> ()
               //| _ ->
               match para with
-              | LiterateCode (lines, ({ Visibility = LiterateCodeVisibility.NamedCode id } as opts), _popts) ->
+              | LiterateCode(lines, ({ Visibility = LiterateCodeVisibility.NamedCode id } as opts), _popts) ->
                   yield Choice2Of2(id), (lines, opts.ExecutionCount)
-              | LiterateCode (lines, opts, _popts) -> yield Choice1Of2(lines), (lines, opts.ExecutionCount)
+              | LiterateCode(lines, opts, _popts) -> yield Choice1Of2(lines), (lines, opts.ExecutionCount)
               | _ -> ()
-          | MarkdownPatterns.ParagraphNested (_pn, nested) ->
+          | MarkdownPatterns.ParagraphNested(_pn, nested) ->
               for ps in nested do
                   for p in ps do
                       yield! collectLiterateCode p
@@ -499,23 +500,23 @@ module internal Transformations =
     /// Replace all special 'LiterateParagraph' elements recursively using the given lookup dictionary
     let rec replaceLiterateParagraph (ctx: LiterateProcessingContext) (formatted: IDictionary<_, _>) para =
         match para with
-        | MarkdownPatterns.LiterateParagraph (special) ->
+        | MarkdownPatterns.LiterateParagraph(special) ->
             // Remove "condition: ipynb" etc. from output unless the condition is satisfied
             match special.ParagraphOptions with
             | { Condition = Some define } when not (ctx.ConditionalDefines |> List.contains define) -> None
             | _ ->
                 // Remove "(** hide ***)" from output unless the condition is satisfied
                 match special with
-                | LiterateCode (_, { Visibility = LiterateCodeVisibility.HiddenCode }, _) -> None
+                | LiterateCode(_, { Visibility = LiterateCodeVisibility.HiddenCode }, _) -> None
                 | _ ->
                     // Remove "(** define: name ***)" from output, they should be referenced elsewhere
                     match special with
-                    | LiterateCode (_, { Visibility = LiterateCodeVisibility.NamedCode _ }, _) -> None
+                    | LiterateCode(_, { Visibility = LiterateCodeVisibility.NamedCode _ }, _) -> None
                     | _ ->
                         match special with
-                        | RawBlock (lines, _) -> Some(InlineHtmlBlock(unparse lines, None, None))
-                        | LiterateCode (lines, _, _) -> Some(formatted.[Choice1Of2 lines])
-                        | CodeReference (ref, _) -> Some(formatted.[Choice2Of2 ref])
+                        | RawBlock(lines, _) -> Some(InlineHtmlBlock(unparse lines, None, None))
+                        | LiterateCode(lines, _, _) -> Some(formatted.[Choice1Of2 lines])
+                        | CodeReference(ref, _) -> Some(formatted.[Choice2Of2 ref])
                         | FsiMergedOutputReference _
                         | FsiOutputReference _
                         | OutputReference _
@@ -526,7 +527,7 @@ module internal Transformations =
 
                             printfn "%s" msg
                             Some(InlineHtmlBlock(msg, None, None))
-                        | LanguageTaggedCode (lang, code, _) ->
+                        | LanguageTaggedCode(lang, code, _) ->
                             let inlined =
                                 match ctx.OutputKind with
                                 | OutputKind.Html -> replaceHtmlTaggedCode ctx lang code
@@ -537,7 +538,7 @@ module internal Transformations =
 
                             Some(InlineHtmlBlock(inlined, None, None))
         // Traverse all other structures recursively
-        | MarkdownPatterns.ParagraphNested (pn, nested) ->
+        | MarkdownPatterns.ParagraphNested(pn, nested) ->
             let nested = List.map (List.choose (replaceLiterateParagraph ctx formatted)) nested
 
             Some(MarkdownPatterns.ParagraphNested(pn, nested))
diff --git a/src/FSharp.Formatting.Markdown/FsxFormatting.fs b/src/FSharp.Formatting.Markdown/FsxFormatting.fs
index 24eb14d94..5c4e243f0 100644
--- a/src/FSharp.Formatting.Markdown/FsxFormatting.fs
+++ b/src/FSharp.Formatting.Markdown/FsxFormatting.fs
@@ -15,7 +15,7 @@ let rec formatParagraphs ctx paragraphs =
 
         let cell =
             match k with
-            | Choice1Of2 (code, codeOutput, _executionCount) ->
+            | Choice1Of2(code, codeOutput, _executionCount) ->
                 let output = String.concat ctx.Newline (List.map fst (List.truncate 10 codeOutput))
 
                 let output =
diff --git a/src/FSharp.Formatting.Markdown/HtmlFormatting.fs b/src/FSharp.Formatting.Markdown/HtmlFormatting.fs
index 9f00c3f8c..32777b227 100644
--- a/src/FSharp.Formatting.Markdown/HtmlFormatting.fs
+++ b/src/FSharp.Formatting.Markdown/HtmlFormatting.fs
@@ -69,19 +69,19 @@ let internal noBreak (_ctx: FormattingContext) () = ()
 /// Write MarkdownSpan value to a TextWriter
 let rec internal formatSpan (ctx: FormattingContext) span =
     match span with
-    | LatexDisplayMath (body, _) ->
+    | LatexDisplayMath(body, _) ->
         // use mathjax grammar, for detail, check: http://www.mathjax.org/
         ctx.Writer.Write("\\[" + (htmlEncode body) + "\\]")
-    | LatexInlineMath (body, _) ->
+    | LatexInlineMath(body, _) ->
         // use mathjax grammar, for detail, check: http://www.mathjax.org/
         ctx.Writer.Write("\\(" + (htmlEncode body) + "\\)")
 
-    | AnchorLink (id, _) -> ctx.Writer.Write(" ")
-    | EmbedSpans (cmd, _) -> formatSpans ctx (cmd.Render())
-    | Literal (str, _) -> ctx.Writer.Write(str)
-    | HardLineBreak (_) -> ctx.Writer.Write("
" + ctx.Newline) - | IndirectLink (body, _, LookupKey ctx.Links (link, title), _) - | DirectLink (body, link, title, _) -> + | AnchorLink(id, _) -> ctx.Writer.Write(" ") + | EmbedSpans(cmd, _) -> formatSpans ctx (cmd.Render()) + | Literal(str, _) -> ctx.Writer.Write(str) + | HardLineBreak(_) -> ctx.Writer.Write("
" + ctx.Newline) + | IndirectLink(body, _, LookupKey ctx.Links (link, title), _) + | DirectLink(body, link, title, _) -> ctx.Writer.Write("") - | IndirectLink (body, original, _, _) -> + | IndirectLink(body, original, _, _) -> ctx.Writer.Write("[") formatSpans ctx body ctx.Writer.Write("]") ctx.Writer.Write(original) - | IndirectImage (body, _, LookupKey ctx.Links (link, title), _) - | DirectImage (body, link, title, _) -> + | IndirectImage(body, _, LookupKey ctx.Links (link, title), _) + | DirectImage(body, link, title, _) -> ctx.Writer.Write("\"") () ctx.Writer.Write("\" />") - | IndirectImage (body, original, _, _) -> + | IndirectImage(body, original, _, _) -> ctx.Writer.Write("[") ctx.Writer.Write(body) ctx.Writer.Write("]") ctx.Writer.Write(original) - | Strong (body, _) -> + | Strong(body, _) -> ctx.Writer.Write("") formatSpans ctx body ctx.Writer.Write("") - | InlineCode (body, _) -> + | InlineCode(body, _) -> ctx.Writer.Write("") ctx.Writer.Write(htmlEncode body) ctx.Writer.Write("") - | Emphasis (body, _) -> + | Emphasis(body, _) -> ctx.Writer.Write("") formatSpans ctx body ctx.Writer.Write("") @@ -145,10 +145,10 @@ let internal formatAnchor (ctx: FormattingContext) (spans: MarkdownSpans) = let rec gather (span: MarkdownSpan) : seq = seq { match span with - | Literal (str, _) -> yield! extractWords str - | Strong (body, _) -> yield! gathers body - | Emphasis (body, _) -> yield! gathers body - | DirectLink (body, _, _, _) -> yield! gathers body + | Literal(str, _) -> yield! extractWords str + | Strong(body, _) -> yield! gathers body + | Emphasis(body, _) -> yield! gathers body + | DirectLink(body, _, _, _) -> yield! gathers body | _ -> () } @@ -169,14 +169,14 @@ let internal withInner ctx f = /// Write a MarkdownParagraph value to a TextWriter as HTML let rec internal formatParagraph (ctx: FormattingContext) paragraph = match paragraph with - | LatexBlock (_env, lines, _) -> + | LatexBlock(_env, lines, _) -> // use mathjax grammar, for detail, check: http://www.mathjax.org/ let body = String.concat ctx.Newline lines ctx.Writer.Write("

\\[" + (htmlEncode body) + "\\]

") - | EmbedParagraphs (cmd, _) -> formatParagraphs ctx (cmd.Render()) - | Heading (n, spans, _) -> + | EmbedParagraphs(cmd, _) -> formatParagraphs ctx (cmd.Render()) + | Heading(n, spans, _) -> ctx.Writer.Write("") if ctx.GenerateHeaderAnchors then @@ -188,7 +188,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = formatSpans ctx spans ctx.Writer.Write("") - | Paragraph (spans, _) -> + | Paragraph(spans, _) -> ctx.ParagraphIndent() ctx.Writer.Write("

") @@ -196,8 +196,8 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = formatSpan ctx span ctx.Writer.Write("

") - | HorizontalRule (_, _) -> ctx.Writer.Write("
") - | CodeBlock (code, _, _fence, language, _, _) -> + | HorizontalRule(_, _) -> ctx.Writer.Write("
") + | CodeBlock(code, _, _fence, language, _, _) -> let code = if language = "fsharp" then adjustFsxCodeForConditionalDefines (ctx.DefineSymbol, ctx.Newline) code @@ -218,8 +218,8 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = if ctx.WrapCodeSnippets then ctx.Writer.Write("") - | OutputBlock (code, "text/html", _) -> ctx.Writer.Write(code) - | OutputBlock (code, _, _) -> + | OutputBlock(code, "text/html", _) -> ctx.Writer.Write(code) + | OutputBlock(code, _, _) -> if ctx.WrapCodeSnippets then ctx.Writer.Write("
") @@ -229,7 +229,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = if ctx.WrapCodeSnippets then ctx.Writer.Write("
") - | TableBlock (headers, alignments, rows, _) -> + | TableBlock(headers, alignments, rows, _) -> let aligns = alignments |> List.map (function @@ -273,7 +273,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = ctx.Writer.Write("") ctx.Writer.Write(ctx.Newline) - | ListBlock (kind, items, _) -> + | ListBlock(kind, items, _) -> let tag = if kind = Ordered then "ol" else "ul" ctx.Writer.Write("<" + tag + ">" + ctx.Newline) @@ -282,8 +282,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = match body with // Simple Paragraph - | [ Paragraph ([ MarkdownSpan.Literal (s, _) ], _) ] when not (s.Contains(ctx.Newline)) -> - ctx.Writer.Write s + | [ Paragraph([ MarkdownSpan.Literal(s, _) ], _) ] when not (s.Contains(ctx.Newline)) -> ctx.Writer.Write s | _ -> let inner = withInner ctx (fun ctx -> @@ -302,19 +301,20 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = ctx.Writer.Write("" + ctx.Newline) ctx.Writer.Write("") - | QuotedBlock (body, _) -> + | QuotedBlock(body, _) -> ctx.ParagraphIndent() ctx.Writer.Write("
" + ctx.Newline) formatParagraphs - { ctx with ParagraphIndent = fun () -> ctx.ParagraphIndent() (*; ctx.Writer.Write(" ")*) } + { ctx with + ParagraphIndent = fun () -> ctx.ParagraphIndent() (*; ctx.Writer.Write(" ")*) } body ctx.ParagraphIndent() ctx.Writer.Write("
") - | Span (spans, _) -> formatSpans ctx spans - | InlineHtmlBlock (code, _, _) -> ctx.Writer.Write(code) - | OtherBlock (lines, _) -> + | Span(spans, _) -> formatSpans ctx spans + | InlineHtmlBlock(code, _, _) -> ctx.Writer.Write(code) + | OtherBlock(lines, _) -> if ctx.WrapCodeSnippets then ctx.Writer.Write("
") @@ -324,7 +324,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph = ctx.Writer.Write(htmlEncode code) ctx.Writer.Write("") - | YamlFrontmatter (_lines, _) -> () + | YamlFrontmatter(_lines, _) -> () ctx.LineBreak() diff --git a/src/FSharp.Formatting.Markdown/LatexFormatting.fs b/src/FSharp.Formatting.Markdown/LatexFormatting.fs index 2d0332329..a6fd89194 100644 --- a/src/FSharp.Formatting.Markdown/LatexFormatting.fs +++ b/src/FSharp.Formatting.Markdown/LatexFormatting.fs @@ -57,27 +57,27 @@ let noBreak (_ctx: FormattingContext) () = () /// Write MarkdownSpan value to a TextWriter let rec formatSpanAsLatex (ctx: FormattingContext) = function - | LatexInlineMath (body, _) -> ctx.Writer.Write(sprintf "$%s$" body) - | LatexDisplayMath (body, _) -> ctx.Writer.Write(sprintf "$$%s$$" body) - | EmbedSpans (cmd, _) -> formatSpansAsLatex ctx (cmd.Render()) - | Literal (str, _) -> ctx.Writer.Write(latexEncode str) - | HardLineBreak (_) -> + | LatexInlineMath(body, _) -> ctx.Writer.Write(sprintf "$%s$" body) + | LatexDisplayMath(body, _) -> ctx.Writer.Write(sprintf "$$%s$$" body) + | EmbedSpans(cmd, _) -> formatSpansAsLatex ctx (cmd.Render()) + | Literal(str, _) -> ctx.Writer.Write(latexEncode str) + | HardLineBreak(_) -> ctx.LineBreak() ctx.LineBreak() | AnchorLink _ -> () - | IndirectLink (body, _, LookupKey ctx.Links (link, _), _) - | DirectLink (body, link, _, _) - | IndirectLink (body, link, _, _) -> + | IndirectLink(body, _, LookupKey ctx.Links (link, _), _) + | DirectLink(body, link, _, _) + | IndirectLink(body, link, _, _) -> ctx.Writer.Write(@"\href{") ctx.Writer.Write(latexEncode link) ctx.Writer.Write("}{") formatSpansAsLatex ctx body ctx.Writer.Write("}") - | IndirectImage (body, _, LookupKey ctx.Links (link, _), _) - | DirectImage (body, link, _, _) - | IndirectImage (body, link, _, _) -> + | IndirectImage(body, _, LookupKey ctx.Links (link, _), _) + | DirectImage(body, link, _, _) + | IndirectImage(body, link, _, _) -> // Use the technique introduced at // http://stackoverflow.com/q/14014827 if not (System.String.IsNullOrWhiteSpace(body)) then @@ -97,15 +97,15 @@ let rec formatSpanAsLatex (ctx: FormattingContext) = ctx.Writer.Write(@"\end{figure}") ctx.LineBreak() - | Strong (body, _) -> + | Strong(body, _) -> ctx.Writer.Write(@"\textbf{") formatSpansAsLatex ctx body ctx.Writer.Write("}") - | InlineCode (body, _) -> + | InlineCode(body, _) -> ctx.Writer.Write(@"\texttt{") ctx.Writer.Write(latexEncode body) ctx.Writer.Write("}") - | Emphasis (body, _) -> + | Emphasis(body, _) -> ctx.Writer.Write(@"\emph{") formatSpansAsLatex ctx body ctx.Writer.Write("}") @@ -116,7 +116,7 @@ and formatSpansAsLatex ctx = List.iter (formatSpanAsLatex ctx) /// Write a MarkdownParagraph value to a TextWriter let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = match paragraph with - | LatexBlock (env, lines, _) -> + | LatexBlock(env, lines, _) -> ctx.LineBreak() ctx.LineBreak() ctx.Writer.Write(sprintf @"\begin{%s}" env) @@ -130,8 +130,8 @@ let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = ctx.LineBreak() ctx.LineBreak() - | EmbedParagraphs (cmd, _) -> formatParagraphsAsLatex ctx (cmd.Render()) - | Heading (n, spans, _) -> + | EmbedParagraphs(cmd, _) -> formatParagraphsAsLatex ctx (cmd.Render()) + | Heading(n, spans, _) -> let level = match n with | 1 -> @"\section*" @@ -145,19 +145,19 @@ let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = formatSpansAsLatex ctx spans ctx.Writer.Write("}") ctx.LineBreak() - | Paragraph (spans, _) -> + | Paragraph(spans, _) -> ctx.LineBreak() ctx.LineBreak() for span in spans do formatSpanAsLatex ctx span - | HorizontalRule (_) -> + | HorizontalRule(_) -> // Reference from http://tex.stackexchange.com/q/19579/9623 ctx.Writer.Write(@"\noindent\makebox[\linewidth]{\rule{\linewidth}{0.4pt}}\medskip") ctx.LineBreak() - | CodeBlock (code = code; language = language) -> // TODO: could format output better using language + | CodeBlock(code = code; language = language) -> // TODO: could format output better using language ctx.Writer.Write(@"\begin{lstlisting}") let code = @@ -175,7 +175,7 @@ let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = ctx.Writer.Write(@"\end{lstlisting}") ctx.LineBreak() - | OutputBlock (code, _kind, _executionCount) -> // TODO: could format output better using kind + | OutputBlock(code, _kind, _executionCount) -> // TODO: could format output better using kind ctx.Writer.Write(@"\begin{lstlisting}") if ctx.GenerateLineNumbers then @@ -187,7 +187,7 @@ let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = ctx.Writer.Write(@"\end{lstlisting}") ctx.LineBreak() - | TableBlock (headers, alignments, rows, _) -> + | TableBlock(headers, alignments, rows, _) -> let aligns = alignments |> List.map (function @@ -225,7 +225,7 @@ let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = ctx.Writer.Write(@"\end{tabular}") ctx.LineBreak() - | ListBlock (kind, items, _) -> + | ListBlock(kind, items, _) -> let tag = if kind = Ordered then "enumerate" else "itemize" ctx.Writer.Write(@"\begin{" + tag + "}") @@ -239,16 +239,16 @@ let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = ctx.Writer.Write(@"\end{" + tag + "}") ctx.LineBreak() - | QuotedBlock (body, _) -> + | QuotedBlock(body, _) -> ctx.Writer.Write(@"\begin{quote}") ctx.LineBreak() formatParagraphsAsLatex ctx body ctx.Writer.Write(@"\end{quote}") ctx.LineBreak() - | Span (spans, _) -> formatSpansAsLatex ctx spans - | InlineHtmlBlock (code, _executionCount, _) -> ctx.Writer.Write(code) - | OtherBlock (code, _) -> + | Span(spans, _) -> formatSpansAsLatex ctx spans + | InlineHtmlBlock(code, _executionCount, _) -> ctx.Writer.Write(code) + | OtherBlock(code, _) -> ctx.Writer.Write(@"\begin{lstlisting}") if ctx.GenerateLineNumbers then @@ -262,7 +262,7 @@ let rec formatParagraphAsLatex (ctx: FormattingContext) paragraph = ctx.LineBreak() ctx.Writer.Write(@"\end{lstlisting}") ctx.LineBreak() - | YamlFrontmatter (_lines, _) -> () + | YamlFrontmatter(_lines, _) -> () ctx.LineBreak() diff --git a/src/FSharp.Formatting.Markdown/MarkdownModel.fs b/src/FSharp.Formatting.Markdown/MarkdownModel.fs index 690f0c8f4..dceaa90dc 100644 --- a/src/FSharp.Formatting.Markdown/MarkdownModel.fs +++ b/src/FSharp.Formatting.Markdown/MarkdownModel.fs @@ -158,19 +158,19 @@ module MarkdownPatterns = | LatexDisplayMath _ | EmbedSpans _ | HardLineBreak _ -> SpanLeaf(SL span) - | Strong (spans, _) - | Emphasis (spans, _) - | DirectLink (spans, _, _, _) - | IndirectLink (spans, _, _, _) -> SpanNode(SN span, spans) + | Strong(spans, _) + | Emphasis(spans, _) + | DirectLink(spans, _, _, _) + | IndirectLink(spans, _, _, _) -> SpanNode(SN span, spans) - let SpanLeaf (SL (span)) = span + let SpanLeaf (SL(span)) = span - let SpanNode (SN (span), spans) = + let SpanNode (SN(span), spans) = match span with - | Strong (_, r) -> Strong(spans, r) - | Emphasis (_, r) -> Emphasis(spans, r) - | DirectLink (_, l, t, r) -> DirectLink(spans, l, t, r) - | IndirectLink (_, a, b, r) -> IndirectLink(spans, a, b, r) + | Strong(_, r) -> Strong(spans, r) + | Emphasis(_, r) -> Emphasis(spans, r) + | DirectLink(_, l, t, r) -> DirectLink(spans, l, t, r) + | IndirectLink(_, a, b, r) -> IndirectLink(spans, a, b, r) | _ -> invalidArg "" "Incorrect SpanNodeInfo" type ParagraphSpansInfo = private PS of MarkdownParagraph @@ -179,9 +179,9 @@ module MarkdownPatterns = let (|ParagraphLeaf|ParagraphNested|ParagraphSpans|) par = match par with - | Heading (_, spans, _) - | Paragraph (spans, _) - | Span (spans, _) -> ParagraphSpans(PS par, spans) + | Heading(_, spans, _) + | Paragraph(spans, _) + | Span(spans, _) -> ParagraphSpans(PS par, spans) | OtherBlock _ | OutputBlock _ | CodeBlock _ @@ -190,23 +190,23 @@ module MarkdownPatterns = | LatexBlock _ | YamlFrontmatter _ | HorizontalRule _ -> ParagraphLeaf(PL par) - | ListBlock (_, pars, _) -> ParagraphNested(PN par, pars) - | QuotedBlock (nested, _) -> ParagraphNested(PN par, [ nested ]) - | TableBlock (headers, _alignments, rows, _) -> + | ListBlock(_, pars, _) -> ParagraphNested(PN par, pars) + | QuotedBlock(nested, _) -> ParagraphNested(PN par, [ nested ]) + | TableBlock(headers, _alignments, rows, _) -> match headers with | None -> ParagraphNested(PN par, rows |> List.concat) | Some columns -> ParagraphNested(PN par, columns :: rows |> List.concat) - let ParagraphSpans (PS (par), spans) = + let ParagraphSpans (PS(par), spans) = match par with - | Heading (a, _, r) -> Heading(a, spans, r) - | Paragraph (_, r) -> Paragraph(spans, r) - | Span (_, r) -> Span(spans, r) + | Heading(a, _, r) -> Heading(a, spans, r) + | Paragraph(_, r) -> Paragraph(spans, r) + | Span(_, r) -> Span(spans, r) | _ -> invalidArg "" "Incorrect ParagraphSpansInfo." - let ParagraphLeaf (PL (par)) = par + let ParagraphLeaf (PL(par)) = par - let ParagraphNested (PN (par), pars) = + let ParagraphNested (PN(par), pars) = let splitEach n list = let rec loop n left ansList curList items = if List.isEmpty items && List.isEmpty curList then @@ -219,9 +219,9 @@ module MarkdownPatterns = loop n n [] [] list match par with - | ListBlock (a, _, r) -> ListBlock(a, pars, r) - | QuotedBlock (_, r) -> QuotedBlock(List.concat pars, r) - | TableBlock (headers, alignments, _, r) -> + | ListBlock(a, _, r) -> ListBlock(a, pars, r) + | QuotedBlock(_, r) -> QuotedBlock(List.concat pars, r) + | TableBlock(headers, alignments, _, r) -> let rows = splitEach (alignments.Length) pars if List.isEmpty rows || headers.IsNone then diff --git a/src/FSharp.Formatting.Markdown/MarkdownParser.fs b/src/FSharp.Formatting.Markdown/MarkdownParser.fs index e92878a71..9acf9b195 100644 --- a/src/FSharp.Formatting.Markdown/MarkdownParser.fs +++ b/src/FSharp.Formatting.Markdown/MarkdownParser.fs @@ -19,7 +19,7 @@ open FSharp.Formatting.Common /// Splits a link formatted as `http://link "title"` into a link part /// and an optional title part (may be wrapped using quote or double-quotes) -let getLinkAndTitle (StringPosition.TrimBoth (input, _n)) = +let getLinkAndTitle (StringPosition.TrimBoth(input, _n)) = let url, title = if input.Length = 0 then "", None @@ -105,10 +105,10 @@ let (|LeftDelimiterRun|_|) input = // preceded by [Unicode whitespace] or a [Unicode punctuation character]. // // Passes 1 and 2a. - | DelimiterRun (_, Char.NotWhiteSpace _) & DelimiterRun (run, NotPunctuation xs) -> Some([], run, xs) - | _ :: DelimiterRun (_, Char.NotWhiteSpace _) & h :: DelimiterRun (run, NotPunctuation xs) -> Some([ h ], run, xs) + | DelimiterRun(_, Char.NotWhiteSpace _) & DelimiterRun(run, NotPunctuation xs) -> Some([], run, xs) + | _ :: DelimiterRun(_, Char.NotWhiteSpace _) & h :: DelimiterRun(run, NotPunctuation xs) -> Some([ h ], run, xs) // Passes 1 and 2b - | h :: DelimiterRun (run, Punctuation (x, xs)) -> + | h :: DelimiterRun(run, Punctuation(x, xs)) -> match [ h ] with | Char.WhiteSpace _ | Punctuation _ -> Some([ h ], run, x :: xs) @@ -116,7 +116,7 @@ let (|LeftDelimiterRun|_|) input = // Passes 1 and 2b when the run is at the start of the line. // |CannotStartEmphasis| ensures that we don't match this // when we've previously discarded a leading character. - | DelimiterRun (run, Punctuation (x, xs)) -> Some([], run, x :: xs) + | DelimiterRun(run, Punctuation(x, xs)) -> Some([], run, x :: xs) | _ -> None /// Succeeds when there's a match to a string of * or _ that could @@ -131,16 +131,16 @@ let (|RightDelimiterRun|_|) input = // followed by [Unicode whitespace] or a [Unicode punctuation character] // // An escaped character followed by delimiter run matches 1 and 2a. - | EscapedChar (x, DelimiterRun (run, xs)) -> Some([ '\\'; x ], run, xs) + | EscapedChar(x, DelimiterRun(run, xs)) -> Some([ '\\'; x ], run, xs) | EscapedChar _ -> None - | Char.NotWhiteSpace _ & x :: DelimiterRun (run, xs) -> + | Char.NotWhiteSpace _ & x :: DelimiterRun(run, xs) -> match input with // 1 and 2a | NotPunctuation _ -> Some([ x ], run, xs) // 1 and 2b - | Punctuation (x, DelimiterRun (run, Char.WhiteSpace ys)) -> Some([ x ], run, ys) + | Punctuation(x, DelimiterRun(run, Char.WhiteSpace ys)) -> Some([ x ], run, ys) // 1 and 2b - | Punctuation (x, DelimiterRun (run, Punctuation (y, ys))) -> Some([ x ], run, y :: ys) + | Punctuation(x, DelimiterRun(run, Punctuation(y, ys))) -> Some([ x ], run, y :: ys) | _ -> None | _ -> None @@ -157,13 +157,13 @@ let (|CannotOpenEmphasis|_|) input = // and either (a) not part of a [right-flanking delimiter run] // or (b) part of a [right-flanking delimiter run] // preceded by a [Unicode punctuation character]. - | LeftDelimiterRun _ & RightDelimiterRun (pre, [ '_' ], post) -> + | LeftDelimiterRun _ & RightDelimiterRun(pre, [ '_' ], post) -> match List.rev pre with | Punctuation _ -> None | revPre -> Some('_' :: revPre, post) // We cannot pass 1 and 2b of the left flanking rule // when h is neither white space nor punctuation. - | h :: DelimiterRun (run, Punctuation (x, xs)) -> + | h :: DelimiterRun(run, Punctuation(x, xs)) -> match [ h ] with | Char.WhiteSpace _ | Punctuation _ -> None @@ -179,28 +179,28 @@ let (|DelimitedMarkdown|_|) bracket input = // Like List.partitionUntilEquals, but skip over escaped characters let rec loop acc count = function - | (RightDelimiterRun (pre, [ '_' ], post) as input) when endl = [ '_' ] -> + | (RightDelimiterRun(pre, [ '_' ], post) as input) when endl = [ '_' ] -> match input with - | LeftDelimiterRun (pre, run, (Punctuation _ as post)) -> + | LeftDelimiterRun(pre, run, (Punctuation _ as post)) -> if count = 0 then Some((List.rev acc) @ pre, run @ post) else loop ((List.rev (pre @ run)) @ acc) (count - 1) post - | LeftDelimiterRun (pre, run, post) -> loop ((List.rev (pre @ run)) @ acc) (count + 1) post + | LeftDelimiterRun(pre, run, post) -> loop ((List.rev (pre @ run)) @ acc) (count + 1) post | _ -> Some((List.rev acc) @ pre, [ '_' ] @ post) - | RightDelimiterRun (pre, run, post) when endl = run -> + | RightDelimiterRun(pre, run, post) when endl = run -> if count = 0 then Some((List.rev acc) @ pre, run @ post) else loop ((List.rev (pre @ run)) @ acc) (count - 1) post - | EscapedChar (x, xs) -> loop (x :: '\\' :: acc) count xs - | LeftDelimiterRun (pre, run, post) when run = endl -> loop ((List.rev (pre @ run)) @ acc) (count + 1) post + | EscapedChar(x, xs) -> loop (x :: '\\' :: acc) count xs + | LeftDelimiterRun(pre, run, post) when run = endl -> loop ((List.rev (pre @ run)) @ acc) (count + 1) post | x :: xs -> loop (x :: acc) count xs | [] -> None // If it starts with 'startl', let's search for 'endl' if List.startsWith bracket input then match loop [] 0 (List.skip bracket.Length input) with - | Some (pre, post) -> Some(pre, List.skip bracket.Length post) + | Some(pre, post) -> Some(pre, List.skip bracket.Length post) | None -> None else None @@ -211,14 +211,14 @@ let (|DelimitedLatexDisplayMath|_|) bracket input = // Like List.partitionUntilEquals, but skip over escaped characters let rec loop acc = function - | EscapedLatexInlineMathChar (x, xs) -> loop (x :: '\\' :: acc) xs + | EscapedLatexInlineMathChar(x, xs) -> loop (x :: '\\' :: acc) xs | input when List.startsWith endl input -> Some(List.rev acc, input) | x :: xs -> loop (x :: acc) xs | [] -> None // If it starts with 'startl', let's search for 'endl' if List.startsWith bracket input then match loop [] (List.skip bracket.Length input) with - | Some (pre, post) -> Some(pre, List.skip bracket.Length post) + | Some(pre, post) -> Some(pre, List.skip bracket.Length post) | None -> None else None @@ -229,14 +229,14 @@ let (|DelimitedLatexInlineMath|_|) bracket input = // Like List.partitionUntilEquals, but skip over escaped characters let rec loop acc = function - | EscapedLatexInlineMathChar (x, xs) -> loop (x :: '\\' :: acc) xs + | EscapedLatexInlineMathChar(x, xs) -> loop (x :: '\\' :: acc) xs | input when List.startsWith endl input -> Some(List.rev acc, input) | x :: xs -> loop (x :: acc) xs | [] -> None // If it starts with 'startl', let's search for 'endl' if List.startsWith bracket input then match loop [] (List.skip bracket.Length input) with - | Some (pre, post) -> Some(pre, List.skip bracket.Length post) + | Some(pre, post) -> Some(pre, List.skip bracket.Length post) | None -> None else None @@ -247,9 +247,8 @@ let (|IndirectLink|_|) = function | List.BracketDelimited '[' ']' (body, '\r' :: '\n' :: (List.BracketDelimited '[' ']' (List.AsString link, rest))) -> Some(body, link, "\r\n[" + link + "]", rest) - | List.BracketDelimited '[' - ']' - (body, ((' ' | '\n') as c) :: (List.BracketDelimited '[' ']' (List.AsString link, rest))) -> + | List.BracketDelimited '[' ']' (body, + ((' ' | '\n') as c) :: (List.BracketDelimited '[' ']' (List.AsString link, rest))) -> Some(body, link, c.ToString() + "[" + link + "]", rest) | List.BracketDelimited '[' ']' (body, List.BracketDelimited '[' ']' (List.AsString link, rest)) -> Some(body, link, "[" + link + "]", rest) @@ -279,7 +278,7 @@ let (|AutoLink|_|) input = /// TODO: This does not handle nested emphasis well. let (|Emphasised|_|) = function - | LeftDelimiterRun (pre, run, post) -> + | LeftDelimiterRun(pre, run, post) -> match run @ post with | DelimitedMarkdown [ '_'; '_'; '_' ] (body, rest) | DelimitedMarkdown [ '*'; '*'; '*' ] (body, rest) -> @@ -335,25 +334,32 @@ let rec parseChars acc input (ctx: ParsingContext) = // Zero or one literals, depending whether there is some accumulated input and update the ctx let accLiterals = - Lazy<_>.Create - (fun () -> - if List.isEmpty acc then - ([], ctx) - else - let range = - match ctx.CurrentRange with - | Some (n) -> Some({ n with EndColumn = n.StartColumn + acc.Length }) - | None -> None - - let ctx = - { ctx with - CurrentRange = - match ctx.CurrentRange with - | Some (n) -> Some({ n with StartColumn = n.StartColumn + acc.Length }) - | None -> None } - - let text = String(List.rev acc |> Array.ofList) - ([ Literal(text, range) ], ctx)) + Lazy<_>.Create(fun () -> + if List.isEmpty acc then + ([], ctx) + else + let range = + match ctx.CurrentRange with + | Some(n) -> + Some( + { n with + EndColumn = n.StartColumn + acc.Length } + ) + | None -> None + + let ctx = + { ctx with + CurrentRange = + match ctx.CurrentRange with + | Some(n) -> + Some( + { n with + StartColumn = n.StartColumn + acc.Length } + ) + | None -> None } + + let text = String(List.rev acc |> Array.ofList) + ([ Literal(text, range) ], ctx)) match input with // Recognizes explicit line-break at the end of line @@ -364,7 +370,7 @@ let rec parseChars acc input (ctx: ParsingContext) = yield HardLineBreak(ctx.CurrentRange) yield! parseChars [] rest ctx - | HtmlEntity (entity, rest) -> + | HtmlEntity(entity, rest) -> let (value, ctx) = accLiterals.Value yield! value yield Literal(entity, ctx.CurrentRange) @@ -373,7 +379,7 @@ let rec parseChars acc input (ctx: ParsingContext) = | '&' :: rest -> yield! parseChars (';' :: 'p' :: 'm' :: 'a' :: '&' :: acc) rest ctx // Ignore escaped characters that might mean something else - | EscapedChar (c, rest) -> yield! parseChars (c :: acc) rest ctx + | EscapedChar(c, rest) -> yield! parseChars (c :: acc) rest ctx // Inline code delimited either using double `` or single ` // (if there are spaces around, then body can contain more backticks) @@ -384,7 +390,7 @@ let rec parseChars acc input (ctx: ParsingContext) = let rng = match ctx.CurrentRange with - | Some (n) -> + | Some(n) -> Some { n with StartColumn = n.StartColumn + s @@ -409,7 +415,11 @@ let rec parseChars acc input (ctx: ParsingContext) = { ctx with CurrentRange = match ctx.CurrentRange with - | Some (n) -> Some({ n with StartColumn = n.StartColumn + 1 }) + | Some(n) -> + Some( + { n with + StartColumn = n.StartColumn + 1 } + ) | None -> None } yield! value @@ -419,7 +429,11 @@ let rec parseChars acc input (ctx: ParsingContext) = LatexInlineMath( code, match ctx.CurrentRange with - | Some (n) -> Some({ n with EndColumn = n.StartColumn + code.Length }) + | Some(n) -> + Some( + { n with + EndColumn = n.StartColumn + code.Length } + ) | None -> None ) @@ -439,7 +453,7 @@ let rec parseChars acc input (ctx: ParsingContext) = yield! parseChars ('>' :: (List.rev tag) @ '<' :: acc) rest ctx // Recognize direct link [foo](http://bar) or indirect link [foo][bar] or auto link http://bar - | DirectLink (body, link, rest) -> + | DirectLink(body, link, rest) -> let (value, ctx) = accLiterals.Value yield! value @@ -447,7 +461,7 @@ let rec parseChars acc input (ctx: ParsingContext) = yield DirectLink(parseChars [] body ctx |> List.ofSeq, link, title, ctx.CurrentRange) yield! parseChars [] rest ctx - | IndirectLink (body, link, original, rest) -> + | IndirectLink(body, link, original, rest) -> let (value, ctx) = accLiterals.Value yield! value @@ -459,14 +473,14 @@ let rec parseChars acc input (ctx: ParsingContext) = yield IndirectLink(parseChars [] body ctx |> List.ofSeq, original, key, ctx.CurrentRange) yield! parseChars [] rest ctx - | AutoLink (link, rest) -> + | AutoLink(link, rest) -> let (value, ctx) = accLiterals.Value yield! value yield DirectLink([ Literal(link, ctx.CurrentRange) ], link, None, ctx.CurrentRange) yield! parseChars [] rest ctx // Recognize image - this is a link prefixed with the '!' symbol - | '!' :: DirectLink (body, link, rest) -> + | '!' :: DirectLink(body, link, rest) -> let (value, ctx) = accLiterals.Value yield! value @@ -474,7 +488,7 @@ let rec parseChars acc input (ctx: ParsingContext) = yield DirectImage(String(Array.ofList body), link, title, ctx.CurrentRange) yield! parseChars [] rest ctx - | '!' :: IndirectLink (body, link, original, rest) -> + | '!' :: IndirectLink(body, link, original, rest) -> let (value, ctx) = accLiterals.Value yield! value @@ -488,8 +502,8 @@ let rec parseChars acc input (ctx: ParsingContext) = yield! parseChars [] rest ctx // Handle Emphasis - | CannotOpenEmphasis (revPre, post) -> yield! parseChars (revPre @ acc) post ctx - | Emphasised (pre, body, f, rest) -> + | CannotOpenEmphasis(revPre, post) -> yield! parseChars (revPre @ acc) post ctx + | Emphasised(pre, body, f, rest) -> let (value, ctx) = accLiterals.Value yield! value yield! parseChars [] pre ctx @@ -507,7 +521,7 @@ let rec parseChars acc input (ctx: ParsingContext) = } /// Parse body of a paragraph into a list of Markdown inline spans -let parseSpans (StringPosition.TrimBoth (s, n)) ctx = +let parseSpans (StringPosition.TrimBoth(s, n)) ctx = let ctx = { ctx with CurrentRange = Some(n) } parseChars [] (s.ToCharArray() |> List.ofArray) ctx |> List.ofSeq @@ -529,13 +543,13 @@ let rec trimSpaces numSpaces (s: string) = /// Recognizes heading, either prefixed with #s or followed by === or --- line let (|Heading|_|) lines = match lines with - | ((StringPosition.TrimBoth header) as line1) :: ((StringPosition.TrimEnd (StringPosition.EqualsRepeated ("=", - MarkdownRange.zero))) as line2) :: rest -> + | ((StringPosition.TrimBoth header) as line1) :: ((StringPosition.TrimEnd(StringPosition.EqualsRepeated("=", + MarkdownRange.zero))) as line2) :: rest -> Some(1, header, [ line1; line2 ], rest) - | ((StringPosition.TrimBoth header) as line1) :: ((StringPosition.TrimEnd (StringPosition.EqualsRepeated ("-", - MarkdownRange.zero))) as line2) :: rest -> + | ((StringPosition.TrimBoth header) as line1) :: ((StringPosition.TrimEnd(StringPosition.EqualsRepeated("-", + MarkdownRange.zero))) as line2) :: rest -> Some(2, header, [ line1; line2 ], rest) - | (StringPosition.StartsWithRepeated "#" (n, StringPosition.TrimBoth (header, ln)) as line1) :: rest -> + | (StringPosition.StartsWithRepeated "#" (n, StringPosition.TrimBoth(header, ln)) as line1) :: rest -> let header = // Drop "##" at the end, but only when it is preceded by some whitespace // (For example "## Hello F#" should be "Hello F#") @@ -592,7 +606,7 @@ let (|HorizontalRule|_|) (line: string, _n: MarkdownRange) = /// Recognizes a code block - lines starting with four spaces (including blank) let (|NestedCodeBlock|_|) lines = match lines with - | Lines.TakeCodeBlock (_numspaces, (Lines.TrimBlank lines as takenLines), rest) when lines <> [] -> + | Lines.TakeCodeBlock(_numspaces, (Lines.TrimBlank lines as takenLines), rest) when lines <> [] -> let code = [ for (l, _n) in lines -> if String.IsNullOrEmpty l then "" else trimSpaces 4 l ] Some(code @ [ "" ], takenLines, rest, None, "", "") @@ -699,16 +713,19 @@ let (|SkipSomeNumbers|_|) (input: string, _n: MarkdownRange) = /// Returns the rest of the line, together with the indent. let (|ListStart|_|) = function - | StringPosition.TrimStartAndCount (startIndent, - _spaces, - // NOTE: a tab character after +, * or - isn't supported by the reference implementation - // (it will be parsed as paragraph for 0.22) - (StringPosition.StartsWithAny [ "+ "; "* "; "- " (*; "+\t"; "*\t"; "-\t"*) ] as item)) -> + | StringPosition.TrimStartAndCount(startIndent, + _spaces, + // NOTE: a tab character after +, * or - isn't supported by the reference implementation + // (it will be parsed as paragraph for 0.22) + (StringPosition.StartsWithAny [ "+ "; "* "; "- " (*; "+\t"; "*\t"; "-\t"*) ] as item)) -> let range = snd item - let li = ((fst item).Substring(2), { range with StartColumn = range.StartColumn + 2 }) + let li = + ((fst item).Substring(2), + { range with + StartColumn = range.StartColumn + 2 }) - let (StringPosition.TrimStartAndCount (startIndent2, _spaces2, _)) = li + let (StringPosition.TrimStartAndCount(startIndent2, _spaces2, _)) = li let endIndent = startIndent @@ -718,10 +735,10 @@ let (|ListStart|_|) = if startIndent2 >= 5 then 1 else startIndent2 Some(Unordered, startIndent, endIndent, li) - | StringPosition.TrimStartAndCount (startIndent, - _spaces, - (SkipSomeNumbers (skipNumCount, '.' :: ' ' :: List.AsString item))) -> - let (StringPosition.TrimStartAndCount (startIndent2, _spaces2, _)) = (item, MarkdownRange.zero) + | StringPosition.TrimStartAndCount(startIndent, + _spaces, + (SkipSomeNumbers(skipNumCount, '.' :: ' ' :: List.AsString item))) -> + let (StringPosition.TrimStartAndCount(startIndent2, _spaces2, _)) = (item, MarkdownRange.zero) let endIndent = startIndent @@ -760,12 +777,12 @@ let (|ListItem|_|) prevSimple lines = // // Then take more things that belong to the item - // the value 'more' will contain indented paragraphs - | (ListStart (kind, startIndent, endIndent, item) as takenLine) :: LinesUntilListOrWhite (continued, - (LinesUntilListOrUnindented (more, - rest) as next)) -> + | (ListStart(kind, startIndent, endIndent, item) as takenLine) :: LinesUntilListOrWhite(continued, + (LinesUntilListOrUnindented(more, + rest) as next)) -> let simple = match item with - | StringPosition.TrimStartAndCount (_, spaces, _) when spaces >= 4 -> + | StringPosition.TrimStartAndCount(_, spaces, _) when spaces >= 4 -> // Code Block false | _ -> @@ -784,7 +801,11 @@ let (|ListItem|_|) prevSimple lines = yield (line.Trim(), n) for (line, n) in more do let trimmed = trimSpaces endIndent line - yield (trimmed, { n with StartColumn = n.StartColumn + line.Length - trimmed.Length }) ] + + yield + (trimmed, + { n with + StartColumn = n.StartColumn + line.Length - trimmed.Length }) ] //let trimmed = line.TrimStart() //if trimmed.Length >= line.Length - endIndent then yield trimmed //else yield line.Substring(endIndent) ] @@ -839,12 +860,12 @@ let rec pipeTableFindSplits (delim: char array) (line: char list) = /// Recognizes alignment specified in the passed separator line. let (|TableCellSeparator|_|) = function - | StringPosition.StartsAndEndsWith (":", ":") (StringPosition.EqualsRepeated ("-", MarkdownRange.zero)) -> + | StringPosition.StartsAndEndsWith (":", ":") (StringPosition.EqualsRepeated("-", MarkdownRange.zero)) -> Some(AlignCenter) - | StringPosition.StartsWith ":" (StringPosition.EqualsRepeated ("-", MarkdownRange.zero)) -> Some(AlignLeft) - | StringPosition.StartsAndEndsWith ("", ":") (StringPosition.EqualsRepeated ("-", MarkdownRange.zero)) -> + | StringPosition.StartsWith ":" (StringPosition.EqualsRepeated("-", MarkdownRange.zero)) -> Some(AlignLeft) + | StringPosition.StartsAndEndsWith ("", ":") (StringPosition.EqualsRepeated("-", MarkdownRange.zero)) -> Some(AlignRight) - | StringPosition.EqualsRepeated ("-", MarkdownRange.zero) -> Some(AlignDefault) + | StringPosition.EqualsRepeated("-", MarkdownRange.zero) -> Some(AlignDefault) | _ -> None /// Recognizes row of pipe table. @@ -1048,7 +1069,7 @@ let (|HtmlBlock|_|) (lines: (string * MarkdownRange) list) = match lines with | (first, _n) :: _ when first.StartsWith("<") -> match lines with - | TakeParagraphLines (html, rest) -> Some(html, html, rest) + | TakeParagraphLines(html, rest) -> Some(html, html, rest) | _ -> None | _ -> None @@ -1067,13 +1088,13 @@ let (|LinesUntilBlockquoteEnds|) input = /// starting with '>' until there is something else let rec (|Blockquote|_|) lines = match lines with - | EmptyBlockquote (takenLines, Lines.TrimBlankStart (takenLines2, rest)) -> + | EmptyBlockquote(takenLines, Lines.TrimBlankStart(takenLines2, rest)) -> Some([ ("", MarkdownRange.zero) ], takenLines @ takenLines2, rest) - | (BlockquoteStart (quoteLine) as takenLine) :: LinesUntilBlockquoteEnds (continued, - Lines.TrimBlankStart (takenLines2, rest)) -> + | (BlockquoteStart(quoteLine) as takenLine) :: LinesUntilBlockquoteEnds(continued, + Lines.TrimBlankStart(takenLines2, rest)) -> let moreQuoteLines, moreTakenLines, rest = match rest with - | Blockquote (lines, takenLines, rest) -> lines, takenLines, rest + | Blockquote(lines, takenLines, rest) -> lines, takenLines, rest | _ -> [], [], rest Some(quoteLine :: continued @ moreQuoteLines, takenLine :: continued @ takenLines2 @ moreTakenLines, rest) @@ -1083,8 +1104,8 @@ let rec (|Blockquote|_|) lines = /// the blockquote if the next line is not a blockquote and (|EmptyBlockquote|_|) lines = match lines with - | BlockquoteStart (StringPosition.WhiteSpace) :: Blockquote (_) -> None - | (BlockquoteStart (StringPosition.WhiteSpace) as takenLine) :: rest -> Some([ takenLine ], rest) + | BlockquoteStart(StringPosition.WhiteSpace) :: Blockquote(_) -> None + | (BlockquoteStart(StringPosition.WhiteSpace) as takenLine) :: rest -> Some([ takenLine ], rest) | _ -> None /// Recognizes Latex block @@ -1103,7 +1124,7 @@ let (|LatexBlock|_|) (lines: (string * MarkdownRange) list) = match lines with | (first, n) as _takenLine1 :: rest when (first.TrimEnd()) = "$$$" -> match rest with - | TakeParagraphLines (body, rest) -> + | TakeParagraphLines(body, rest) -> Some("equation", body, ((@"\begin{equation}", n) :: body @ [ (@"\end{equation}", n) ]), rest) | _ -> None | ((first, n) as takenLine) :: rest when @@ -1135,15 +1156,12 @@ let (|LatexBlock|_|) (lines: (string * MarkdownRange) list) = let (|LinkDefinition|_|) s = match s with | ((StringPosition.StartsWithWrapped ("[", "]:") (wrapped, StringPosition.TrimBoth link) | StringPosition.StartsWithWrapped (" [", - "]:") - (wrapped, - StringPosition.TrimBoth link) | StringPosition.StartsWithWrapped (" [", - "]:") - (wrapped, - StringPosition.TrimBoth link) | StringPosition.StartsWithWrapped (" [", - "]:") - (wrapped, - StringPosition.TrimBoth link)) as line) :: rest -> + "]:") (wrapped, + StringPosition.TrimBoth link) | StringPosition.StartsWithWrapped (" [", + "]:") (wrapped, + StringPosition.TrimBoth link) | StringPosition.StartsWithWrapped (" [", + "]:") (wrapped, + StringPosition.TrimBoth link)) as line) :: rest -> Some((wrapped, link), [ line ], rest) | _ -> None @@ -1155,12 +1173,14 @@ let updateCurrentRange lines = /// Parse a list of lines into a sequence of markdown paragraphs let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) list) = seq { - let ctx = { ctx with CurrentRange = updateCurrentRange lines } + let ctx = + { ctx with + CurrentRange = updateCurrentRange lines } - let frontMatter, (Lines.TrimBlankStart (_, moreLines)) = + let frontMatter, (Lines.TrimBlankStart(_, moreLines)) = if ctx.IsFirst && ctx.AllowYamlFrontMatter then match lines with - | YamlFrontmatter (yaml, loc, rest) -> Some(YamlFrontmatter(yaml, Some loc)), rest + | YamlFrontmatter(yaml, loc, rest) -> Some(YamlFrontmatter(yaml, Some loc)), rest | _ -> None, lines else None, lines @@ -1169,13 +1189,15 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l | None -> () | Some p -> yield p - let ctx = { ctx with CurrentRange = updateCurrentRange moreLines } + let ctx = + { ctx with + CurrentRange = updateCurrentRange moreLines } let ctx = { ctx with IsFirst = false } match moreLines with // Recognize various kinds of standard paragraphs - | LinkDefinition ((key, link), takenLines, Lines.TrimBlankStart (takenLines2, lines)) -> + | LinkDefinition((key, link), takenLines, Lines.TrimBlankStart(takenLines2, lines)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1186,18 +1208,18 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx lines - | NestedCodeBlock (code, - takenLines, - Lines.TrimBlankStart (takenLines2, lines), - fenceString, - langString, - ignoredLine) - | FencedCodeBlock (code, - takenLines, - Lines.TrimBlankStart (takenLines2, lines), - fenceString, - langString, - ignoredLine) -> + | NestedCodeBlock(code, + takenLines, + Lines.TrimBlankStart(takenLines2, lines), + fenceString, + langString, + ignoredLine) + | FencedCodeBlock(code, + takenLines, + Lines.TrimBlankStart(takenLines2, lines), + fenceString, + langString, + ignoredLine) -> if ctx.ParseCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1206,7 +1228,7 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx lines - | Blockquote (body, takenLines, Lines.TrimBlankStart (takenLines2, rest)) -> + | Blockquote(body, takenLines, Lines.TrimBlankStart(takenLines2, rest)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1218,8 +1240,8 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx rest - | EmacsTableBlock ((headers, alignments, rows), takenLines, Lines.TrimBlankStart (takenLines2, rest)) - | PipeTableBlock ((headers, alignments, rows), takenLines, Lines.TrimBlankStart (takenLines2, rest)) -> + | EmacsTableBlock((headers, alignments, rows), takenLines, Lines.TrimBlankStart(takenLines2, rest)) + | PipeTableBlock((headers, alignments, rows), takenLines, Lines.TrimBlankStart(takenLines2, rest)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1235,7 +1257,7 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx rest - | HorizontalRule (c) as takenLine :: (Lines.TrimBlankStart (takenLines2, lines)) -> + | HorizontalRule(c) as takenLine :: (Lines.TrimBlankStart(takenLines2, lines)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLine :: takenLines2, ctx.CurrentRange) else @@ -1243,7 +1265,7 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx lines - | LatexBlock (env, body, takenLines, Lines.TrimBlankStart (takenLines2, rest)) -> + | LatexBlock(env, body, takenLines, Lines.TrimBlankStart(takenLines2, rest)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1253,7 +1275,7 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l // Recognize list of list items and turn it into nested lists - | ListItems true (items, takenLines, Lines.TrimBlankStart (takenLines2, rest)) -> + | ListItems true (items, takenLines, Lines.TrimBlankStart(takenLines2, rest)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1262,10 +1284,10 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l // Nest all items that have another kind (i.e. UL vs. OL) let rec nestUnmatchingItems items = match items with - | Node ((_, baseKind, _), _) :: _ -> + | Node((_, baseKind, _), _) :: _ -> items - |> List.nestUnderLastMatching (fun (Node ((_, kind, _), _)) -> kind = baseKind) - |> List.map (fun (Node (info, children), nested) -> + |> List.nestUnderLastMatching (fun (Node((_, kind, _), _)) -> kind = baseKind) + |> List.map (fun (Node(info, children), nested) -> let children = nestUnmatchingItems children Node(info, children @ nested)) | [] -> [] @@ -1274,11 +1296,11 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l let rec formatTree (nodes: Tree list) = let kind = match nodes with - | Node ((_, kind, _), _) :: _ -> kind + | Node((_, kind, _), _) :: _ -> kind | _ -> Unordered let items = - [ for (Node ((simple, _, body), nested)) in nodes -> + [ for (Node((simple, _, body), nested)) in nodes -> [ let rng = body |> List.map snd |> MarkdownRange.mergeRanges if not simple then @@ -1302,13 +1324,13 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l let containsNonSimple = tree |> Seq.exists (function - | Node ((false, _, _), _) -> true + | Node((false, _, _), _) -> true | _ -> false) if containsNonSimple then nodes |> List.map (function - | Node ((_, kind, content), nested) -> + | Node((_, kind, content), nested) -> Node((false, kind, content), unifySimpleProperty nested)) else nodes @@ -1318,7 +1340,7 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx rest // Recognize remaining types of paragraphs - | Heading (n, body, takenLines, Lines.TrimBlankStart (takenLines2, lines)) -> + | Heading(n, body, takenLines, Lines.TrimBlankStart(takenLines2, lines)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1326,7 +1348,7 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx lines - | HtmlBlock (code, takenLines, Lines.TrimBlankStart (takenLines2, lines)) when + | HtmlBlock(code, takenLines, Lines.TrimBlankStart(takenLines2, lines)) when (let all = String.concat ctx.Newline (code |> List.map fst) not (all.StartsWith(" + | TakeParagraphLines((Lines.TrimParagraphLines lines as takenLines), Lines.TrimBlankStart(takenLines2, rest)) -> if ctx.ParseNonCodeAsOther then yield OtherBlock(takenLines @ takenLines2, ctx.CurrentRange) else @@ -1357,7 +1379,7 @@ let rec parseParagraphs (ctx: ParsingContext) (lines: (string * MarkdownRange) l yield! parseParagraphs ctx rest - | Lines.TrimBlankStart (_takenLines2, []) -> () + | Lines.TrimBlankStart(_takenLines2, []) -> () | _ -> failwithf "Unexpectedly stopped!\n%A" moreLines } diff --git a/src/FSharp.Formatting.Markdown/MarkdownUtils.fs b/src/FSharp.Formatting.Markdown/MarkdownUtils.fs index a6c5f529a..1d9b9b87b 100644 --- a/src/FSharp.Formatting.Markdown/MarkdownUtils.fs +++ b/src/FSharp.Formatting.Markdown/MarkdownUtils.fs @@ -23,19 +23,19 @@ module internal MarkdownUtils = let getExecutionCount = (function - | CodeBlock (executionCount = executionCount) - | InlineHtmlBlock (executionCount = executionCount) -> executionCount + | CodeBlock(executionCount = executionCount) + | InlineHtmlBlock(executionCount = executionCount) -> executionCount | _ -> None) let getCode = (function - | CodeBlock (code = code) -> code - | InlineHtmlBlock (code = code) -> code + | CodeBlock(code = code) -> code + | InlineHtmlBlock(code = code) -> code | _ -> failwith "unreachable") let getCodeOutput = (function - | OutputBlock (code, kind, _) -> code, kind + | OutputBlock(code, kind, _) -> code, kind | _ -> failwith "unreachable") let splitParagraphs paragraphs = @@ -88,23 +88,23 @@ module internal MarkdownUtils = /// Format a MarkdownSpan let rec formatSpan (ctx: FormattingContext) span = match span with - | LatexInlineMath (body, _) -> sprintf "$%s$" body - | LatexDisplayMath (body, _) -> sprintf "$$%s$$" body - | EmbedSpans (cmd, _) -> formatSpans ctx (cmd.Render()) - | Literal (str, _) -> str - | HardLineBreak (_) -> "\n" + | LatexInlineMath(body, _) -> sprintf "$%s$" body + | LatexDisplayMath(body, _) -> sprintf "$$%s$$" body + | EmbedSpans(cmd, _) -> formatSpans ctx (cmd.Render()) + | Literal(str, _) -> str + | HardLineBreak(_) -> "\n" | AnchorLink _ -> "" - | IndirectLink (body, _, LookupKey ctx.Links (link, _), _) - | DirectLink (body, link, _, _) - | IndirectLink (body, link, _, _) -> "[" + formatSpans ctx body + "](" + link + ")" + | IndirectLink(body, _, LookupKey ctx.Links (link, _), _) + | DirectLink(body, link, _, _) + | IndirectLink(body, link, _, _) -> "[" + formatSpans ctx body + "](" + link + ")" - | IndirectImage (_body, _, LookupKey ctx.Links (_link, _), _) - | IndirectImage (_body, _link, _, _) -> failwith "tbd - IndirectImage" - | DirectImage (_body, _link, _, _) -> sprintf "![%s](%s)" _body _link - | Strong (body, _) -> "**" + formatSpans ctx body + "**" - | InlineCode (body, _) -> "`" + body + "`" - | Emphasis (body, _) -> "**" + formatSpans ctx body + "**" + | IndirectImage(_body, _, LookupKey ctx.Links (_link, _), _) + | IndirectImage(_body, _link, _, _) -> failwith "tbd - IndirectImage" + | DirectImage(_body, _link, _, _) -> sprintf "![%s](%s)" _body _link + | Strong(body, _) -> "**" + formatSpans ctx body + "**" + | InlineCode(body, _) -> "`" + body + "`" + | Emphasis(body, _) -> "**" + formatSpans ctx body + "**" /// Format a list of MarkdownSpan and formatSpans ctx spans = @@ -113,7 +113,7 @@ module internal MarkdownUtils = /// Format a MarkdownParagraph let rec formatParagraph (ctx: FormattingContext) paragraph = [ match paragraph with - | LatexBlock (env, lines, _) -> + | LatexBlock(env, lines, _) -> yield sprintf "\\begin{%s}" env for line in lines do @@ -122,18 +122,18 @@ module internal MarkdownUtils = yield sprintf "\\end{%s}" env yield "" - | Heading (n, spans, _) -> + | Heading(n, spans, _) -> yield String.replicate n "#" + " " + formatSpans ctx spans yield "" - | Paragraph (spans, _) -> + | Paragraph(spans, _) -> yield String.concat "" [ for span in spans -> formatSpan ctx span ] yield "" - | HorizontalRule (_) -> + | HorizontalRule(_) -> yield "-----------------------" yield "" - | CodeBlock (code = code; fence = fence; language = language) -> + | CodeBlock(code = code; fence = fence; language = language) -> match fence with | None -> () | Some f -> yield f + language @@ -145,7 +145,7 @@ module internal MarkdownUtils = | Some f -> yield f yield "" - | ListBlock (Unordered, paragraphsl, _) -> + | ListBlock(Unordered, paragraphsl, _) -> for paragraphs in paragraphsl do for (i, paragraph) in List.indexed paragraphs do let lines = formatParagraph ctx paragraph @@ -158,7 +158,7 @@ module internal MarkdownUtils = yield " " + line yield "" - | ListBlock (Ordered, paragraphsl, _) -> + | ListBlock(Ordered, paragraphsl, _) -> for (n, paragraphs) in List.indexed paragraphsl do for (i, paragraph) in List.indexed paragraphs do let lines = formatParagraph ctx paragraph @@ -171,7 +171,7 @@ module internal MarkdownUtils = yield " " + line yield "" - | TableBlock (headers, alignments, rows, _) -> + | TableBlock(headers, alignments, rows, _) -> match headers with | Some headers -> @@ -214,22 +214,22 @@ module internal MarkdownUtils = yield "\n" - | OutputBlock (output, "text/html", _executionCount) -> + | OutputBlock(output, "text/html", _executionCount) -> yield (output.Trim()) yield "" - | OutputBlock (output, _, _executionCount) -> + | OutputBlock(output, _, _executionCount) -> yield "```" yield output yield "```" yield "" - | OtherBlock (lines, _) -> yield! List.map fst lines - | InlineHtmlBlock (code, _, _) -> + | OtherBlock(lines, _) -> yield! List.map fst lines + | InlineHtmlBlock(code, _, _) -> let lines = code.Replace("\r\n", "\n").Split('\n') |> Array.toList yield! lines //yield "" | YamlFrontmatter _ -> () - | Span (body = body) -> yield formatSpans ctx body - | QuotedBlock (paragraphs = paragraphs) -> + | Span(body = body) -> yield formatSpans ctx body + | QuotedBlock(paragraphs = paragraphs) -> for paragraph in paragraphs do let lines = formatParagraph ctx paragraph @@ -262,7 +262,7 @@ module internal MarkdownUtils = let applyCodeReferenceResolver ctx (code, range) = match ctx.CodeReferenceResolver code with | None -> InlineCode(code, range) - | Some (niceName, link) -> DirectLink([ Literal(niceName, range) ], link, None, range) + | Some(niceName, link) -> DirectLink([ Literal(niceName, range) ], link, None, range) let applyDirectLinkResolver ctx link = match ctx.MarkdownDirectLinkResolver link with @@ -276,48 +276,48 @@ module internal MarkdownUtils = let rec mapSpans fs (md: MarkdownSpans) = md |> List.map (function - | Literal (text, range) -> Literal(mapText fs text, range) - | Strong (spans, range) -> Strong(mapSpans fs spans, range) - | Emphasis (spans, range) -> Emphasis(mapSpans fs spans, range) - | AnchorLink (link, range) -> AnchorLink(mapText fs link, range) - | DirectLink (spans, link, title, range) -> + | Literal(text, range) -> Literal(mapText fs text, range) + | Strong(spans, range) -> Strong(mapSpans fs spans, range) + | Emphasis(spans, range) -> Emphasis(mapSpans fs spans, range) + | AnchorLink(link, range) -> AnchorLink(mapText fs link, range) + | DirectLink(spans, link, title, range) -> DirectLink(mapSpans fs spans, mapDirectLink fs link, Option.map (mapText fs) title, range) - | IndirectLink (spans, original, key, range) -> IndirectLink(mapSpans fs spans, original, key, range) - | DirectImage (body, link, title, range) -> + | IndirectLink(spans, original, key, range) -> IndirectLink(mapSpans fs spans, original, key, range) + | DirectImage(body, link, title, range) -> DirectImage(mapText fs body, mapText fs link, Option.map (mapText fs) title, range) - | IndirectImage (body, original, key, range) -> IndirectImage(mapText fs body, original, key, range) - | HardLineBreak (range) -> HardLineBreak(range) - | InlineCode (code, range) -> mapInlineCode fs (code, range) + | IndirectImage(body, original, key, range) -> IndirectImage(mapText fs body, original, key, range) + | HardLineBreak(range) -> HardLineBreak(range) + | InlineCode(code, range) -> mapInlineCode fs (code, range) // NOTE: substitutions not applied to Latex math, embedded spans or inline code - | LatexInlineMath (code, range) -> LatexInlineMath(code, range) - | LatexDisplayMath (code, range) -> LatexDisplayMath(code, range) - | EmbedSpans (customSpans, range) -> EmbedSpans(customSpans, range)) + | LatexInlineMath(code, range) -> LatexInlineMath(code, range) + | LatexDisplayMath(code, range) -> LatexDisplayMath(code, range) + | EmbedSpans(customSpans, range) -> EmbedSpans(customSpans, range)) let rec mapParagraphs f (md: MarkdownParagraphs) = md |> List.map (function - | Heading (size, body, range) -> Heading(size, mapSpans f body, range) - | Paragraph (body, range) -> Paragraph(mapSpans f body, range) - | CodeBlock (code, count, fence, language, ignoredLine, range) -> + | Heading(size, body, range) -> Heading(size, mapSpans f body, range) + | Paragraph(body, range) -> Paragraph(mapSpans f body, range) + | CodeBlock(code, count, fence, language, ignoredLine, range) -> CodeBlock(mapText f code, count, fence, language, ignoredLine, range) - | OutputBlock (output, kind, count) -> OutputBlock(output, kind, count) - | ListBlock (kind, items, range) -> ListBlock(kind, List.map (mapParagraphs f) items, range) - | QuotedBlock (paragraphs, range) -> QuotedBlock(mapParagraphs f paragraphs, range) - | Span (spans, range) -> Span(mapSpans f spans, range) - | LatexBlock (env, body, range) -> LatexBlock(env, List.map (mapText f) body, range) - | HorizontalRule (character, range) -> HorizontalRule(character, range) - | YamlFrontmatter (lines, range) -> YamlFrontmatter(List.map (mapText f) lines, range) - | TableBlock (headers, alignments, rows, range) -> + | OutputBlock(output, kind, count) -> OutputBlock(output, kind, count) + | ListBlock(kind, items, range) -> ListBlock(kind, List.map (mapParagraphs f) items, range) + | QuotedBlock(paragraphs, range) -> QuotedBlock(mapParagraphs f paragraphs, range) + | Span(spans, range) -> Span(mapSpans f spans, range) + | LatexBlock(env, body, range) -> LatexBlock(env, List.map (mapText f) body, range) + | HorizontalRule(character, range) -> HorizontalRule(character, range) + | YamlFrontmatter(lines, range) -> YamlFrontmatter(List.map (mapText f) lines, range) + | TableBlock(headers, alignments, rows, range) -> TableBlock( Option.map (List.map (mapParagraphs f)) headers, alignments, List.map (List.map (mapParagraphs f)) rows, range ) - | OtherBlock (lines: (string * MarkdownRange) list, range) -> + | OtherBlock(lines: (string * MarkdownRange) list, range) -> OtherBlock(lines |> List.map (fun (line, range) -> (mapText f line, range)), range) - | InlineHtmlBlock (code, count, range) -> + | InlineHtmlBlock(code, count, range) -> try let fText, _, fLink = f @@ -350,7 +350,7 @@ module internal MarkdownUtils = // NOTE: substitutions are not currently applied to embedded LiterateParagraph which are in any case eliminated // before substitutions are applied. - | EmbedParagraphs (customParagraphs, range) -> + | EmbedParagraphs(customParagraphs, range) -> //let customParagraphsR = { new MarkdownEmbedParagraphs with member _.Render() = customParagraphs.Render() |> mapParagraphs f } EmbedParagraphs(customParagraphs, range)) diff --git a/src/FSharp.Formatting.Markdown/PynbFormatting.fs b/src/FSharp.Formatting.Markdown/PynbFormatting.fs index 84ae805d6..d09286159 100644 --- a/src/FSharp.Formatting.Markdown/PynbFormatting.fs +++ b/src/FSharp.Formatting.Markdown/PynbFormatting.fs @@ -24,7 +24,7 @@ let rec formatParagraphs ctx paragraphs = let cell = match k with - | Choice1Of2 (code, codeOutput, executionCount) -> + | Choice1Of2(code, codeOutput, executionCount) -> codeCell [| adjustFsxCodeForConditionalDefines (ctx.DefineSymbol, ctx.Newline) code |] executionCount @@ -48,6 +48,8 @@ let formatAsPynb links replacements newline crefResolver mdlinkResolver paragrap let cells = formatParagraphs ctx paragraphs - let notebook = { Notebook.Default with cells = Array.ofList cells } + let notebook = + { Notebook.Default with + cells = Array.ofList cells } notebook.ToString() diff --git a/src/fsdocs-tool/BuildCommand.fs b/src/fsdocs-tool/BuildCommand.fs index 930b34a38..3f56d45d7 100644 --- a/src/fsdocs-tool/BuildCommand.fs +++ b/src/fsdocs-tool/BuildCommand.fs @@ -1060,11 +1060,15 @@ module Serve = let defaultBinding = defaultConfig.bindings.[0] - let withPort = { defaultBinding.socketBinding with port = uint16 localPort } + let withPort = + { defaultBinding.socketBinding with + port = uint16 localPort } let serverConfig = { defaultConfig with - bindings = [ { defaultBinding with socketBinding = withPort } ] + bindings = + [ { defaultBinding with + socketBinding = withPort } ] homeFolder = Some rootOutputFolderAsGiven mimeTypesMap = mimeTypesMap } @@ -1247,31 +1251,28 @@ type CoreBuildOptions(watch) = getTime (typeof.Assembly.Location), (projects |> List.map getTime |> List.toArray)) - Utils.cacheBinary - cacheFile - (fun (_, key2) -> key1 = key2) - (fun () -> - let props = - this.extraMsbuildProperties - |> Seq.toList - |> List.map (fun s -> - let arr = s.Split("=") - - if arr.Length > 1 then - arr.[0], String.concat "=" arr.[1..] - else - failwith "properties must be of the form 'PropName=PropValue'") - - Crack.crackProjects ( - onError, - props, - userRoot, - userCollectionName, - userParameters, - projects, - this.ignoreprojects - ), - key1) + Utils.cacheBinary cacheFile (fun (_, key2) -> key1 = key2) (fun () -> + let props = + this.extraMsbuildProperties + |> Seq.toList + |> List.map (fun s -> + let arr = s.Split("=") + + if arr.Length > 1 then + arr.[0], String.concat "=" arr.[1..] + else + failwith "properties must be of the form 'PropName=PropValue'") + + Crack.crackProjects ( + onError, + props, + userRoot, + userCollectionName, + userParameters, + projects, + this.ignoreprojects + ), + key1) // See https://github.com/ionide/proj-info/issues/123 System.Environment.SetEnvironmentVariable("DOTNET_HOST_PATH", prevDotnetHostPath) @@ -1488,7 +1489,7 @@ type CoreBuildOptions(watch) = OutputKind.Markdown, Path.Combine(this.input, "_template.md") ] match templates |> Seq.tryFind (fun (_, path) -> path |> File.Exists) with - | Some (kind, path) -> kind, Some path + | Some(kind, path) -> kind, Some path | None -> let templateFiles = templates |> Seq.map snd |> String.concat "', '" @@ -1611,7 +1612,7 @@ type CoreBuildOptions(watch) = Map.ofList [ for (thing, _action) in docModels do match thing with - | Some (file, _isOtherLang, model) -> (file, model) + | Some(file, _isOtherLang, model) -> (file, model) | None -> () ] latestDocContentResults <- results @@ -1627,7 +1628,7 @@ type CoreBuildOptions(watch) = for (_thing, action) in docModels do action globals - )) + )) let runDocContentPhase2 () = protect "Content generation (phase 2)" (fun () -> diff --git a/src/fsdocs-tool/Program.fs b/src/fsdocs-tool/Program.fs index 4656e2978..be5df76fb 100644 --- a/src/fsdocs-tool/Program.fs +++ b/src/fsdocs-tool/Program.fs @@ -7,9 +7,7 @@ do () [] let main argv = - CommandLine - .Parser - .Default + CommandLine.Parser.Default .ParseArguments(argv) .MapResult( (fun (opts: BuildCommand) -> opts.Execute()), diff --git a/src/fsdocs-tool/ProjectCracker.fs b/src/fsdocs-tool/ProjectCracker.fs index 90bed8fb7..d179f3184 100644 --- a/src/fsdocs-tool/ProjectCracker.fs +++ b/src/fsdocs-tool/ProjectCracker.fs @@ -287,7 +287,7 @@ module Crack = let splitTargetFrameworks = function - | Some (s: string) -> + | Some(s: string) -> s.Split(";", StringSplitOptions.RemoveEmptyEntries) |> Array.map (fun s' -> s'.Trim()) |> Some @@ -348,7 +348,7 @@ module Crack = let result = crackProjectFileAndIncludeTargetFrameworks slnDir extraMsbuildProperties file //printfn "msgs = %A" msgs match result with - | Ok (Some targetFrameworks, crackedProjectInfo) when + | Ok(Some targetFrameworks, crackedProjectInfo) when crackedProjectInfo.TargetPath.IsNone && targetFrameworks.Length > 1 -> // no targetpath and there are multiple target frameworks @@ -360,16 +360,16 @@ module Crack = crackProjectFileAndIncludeTargetFrameworks slnDir extraMsbuildPropertiesAndFirstTargetFramework file match result2 with - | Ok (_, crackedProjectInfo) -> crackedProjectInfo - | Error (GetProjectOptionsErrors (err, msgs)) -> + | Ok(_, crackedProjectInfo) -> crackedProjectInfo + | Error(GetProjectOptionsErrors(err, msgs)) -> failwithf "error - %s\nlog - %s" (err.ToString()) (String.concat "\n" msgs) - | Ok (_, crackedProjectInfo) -> crackedProjectInfo - | Error (GetProjectOptionsErrors (err, msgs)) -> + | Ok(_, crackedProjectInfo) -> crackedProjectInfo + | Error(GetProjectOptionsErrors(err, msgs)) -> failwithf "error - %s\nlog - %s" (err.ToString()) (String.concat "\n" msgs) let getProjectsFromSlnFile (slnPath: string) = match InspectSln.tryParseSln slnPath with - | Ok (_, slnData) -> InspectSln.loadingBuildOrder slnData + | Ok(_, slnData) -> InspectSln.loadingBuildOrder slnData //this.LoadProjects(projs, crosstargetingStrategy, useBinaryLogger, numberOfThreads) | Error e -> raise (exn ("cannot load the sln", e)) diff --git a/tests/Common/MarkdownUnit.fs b/tests/Common/MarkdownUnit.fs index ed98a75a4..42401e54d 100644 --- a/tests/Common/MarkdownUnit.fs +++ b/tests/Common/MarkdownUnit.fs @@ -9,7 +9,7 @@ let shouldMatchPar f pars = true else match par with - | MarkdownPatterns.ParagraphNested (_, pars) -> List.exists (List.exists loop) pars + | MarkdownPatterns.ParagraphNested(_, pars) -> List.exists (List.exists loop) pars | _ -> false Assert.IsTrue(Seq.exists loop pars, "Should match the specified paragraph") @@ -21,12 +21,12 @@ let shouldMatchSpan f pars = else match sp with | MarkdownPatterns.SpanLeaf _ -> false - | MarkdownPatterns.SpanNode (_, sps) -> List.exists loopSpan sps + | MarkdownPatterns.SpanNode(_, sps) -> List.exists loopSpan sps let rec loopPar par = match par with - | MarkdownPatterns.ParagraphSpans (_, sps) -> List.exists loopSpan sps + | MarkdownPatterns.ParagraphSpans(_, sps) -> List.exists loopSpan sps | MarkdownPatterns.ParagraphLeaf _ -> false - | MarkdownPatterns.ParagraphNested (_, pars) -> List.exists (List.exists loopPar) pars + | MarkdownPatterns.ParagraphNested(_, pars) -> List.exists (List.exists loopPar) pars Assert.IsTrue(Seq.exists loopPar pars, "Should match the specified span") diff --git a/tests/FSharp.ApiDocs.Tests/AttributeTests.fs b/tests/FSharp.ApiDocs.Tests/AttributeTests.fs index 15313530f..02bf41d15 100644 --- a/tests/FSharp.ApiDocs.Tests/AttributeTests.fs +++ b/tests/FSharp.ApiDocs.Tests/AttributeTests.fs @@ -65,12 +65,7 @@ let info = let ``ApiDocs extracts Attribute on Module`` () = let modules = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let modul = modules |> findModule "SingleAttributeModule" @@ -88,12 +83,7 @@ let ``ApiDocs extracts Attribute on Module`` () = let ``ApiDocs extracts multiple Attributes on Module`` () = let modules = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let modul = modules |> findModule "MultipleAttributesModule" @@ -105,12 +95,7 @@ let ``ApiDocs extracts multiple Attributes on Module`` () = let ``ApiDocs extracts Attribute with argument`` () = let modules = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let modul = modules |> findModule "SingleAttributeWithArgumentModule" @@ -129,12 +114,7 @@ let ``ApiDocs extracts Attribute with argument`` () = let ``ApiDocs extracts Attribute with named arguments`` () = let modules = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let modul = modules |> findModule "SingleAttributeWithNamedArgumentsModule" @@ -160,12 +140,7 @@ let ``ApiDocs extracts Attribute with named arguments`` () = let ``ApiDocs extracts Attribute on interface`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let interface' = typeInfos |> findType "AttributeInterface" @@ -179,12 +154,7 @@ let ``ApiDocs extracts Attribute on interface`` () = let ``ApiDocs extracts Attribute on class`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let class' = typeInfos |> findType "AttributeClass" @@ -197,12 +167,7 @@ let ``ApiDocs extracts Attribute on class`` () = let ``ApiDocs extracts Attribute on value in module`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = typeInfos |> findModule "ContentTestModule" @@ -218,12 +183,7 @@ let ``ApiDocs extracts Attribute on value in module`` () = let ``ApiDocs extracts Attribute on function in module`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = typeInfos |> findModule "ContentTestModule" @@ -239,12 +199,7 @@ let ``ApiDocs extracts Attribute on function in module`` () = let ``ApiDocs extracts Attribute on instance member in class`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let class' = typeInfos |> findType "AttributeClass" @@ -260,12 +215,7 @@ let ``ApiDocs extracts Attribute on instance member in class`` () = let ``ApiDocs extracts Attribute on static member in class`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let class' = typeInfos |> findType "AttributeClass" @@ -281,12 +231,7 @@ let ``ApiDocs extracts Attribute on static member in class`` () = let ``ApiDocs extracts Attribute on union case`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let union = typeInfos |> findType "AttributeUnion" @@ -304,12 +249,7 @@ let ``ApiDocs extracts Attribute on union case`` () = let ``ApiDocs extracts Attribute on record field`` () = let typeInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let union = typeInfos |> findType "AttributeRecord" @@ -327,12 +267,7 @@ let ``ApiDocs extracts Attribute on record field`` () = let ``ApiDocs formats attribute without arguments`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -350,12 +285,7 @@ let ``ApiDocs formats attribute without arguments`` () = let ``ApiDocs formats attribute with single int argument`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -373,12 +303,7 @@ let ``ApiDocs formats attribute with single int argument`` () = let ``ApiDocs formats attribute with single string argument`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -397,12 +322,7 @@ let ``ApiDocs formats attribute with single string argument`` () = let ``ApiDocs formats attribute with single bool argument`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -421,12 +341,7 @@ let ``ApiDocs formats attribute with single bool argument`` () = let ``ApiDocs formats attribute with single array argument`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -444,12 +359,7 @@ let ``ApiDocs formats attribute with single array argument`` () = let ``ApiDocs formats attribute with multiple arguments`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -468,12 +378,7 @@ let ``ApiDocs formats attribute with multiple arguments`` () = let ``ApiDocs formats attribute with multiple named arguments`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -492,12 +397,7 @@ let ``ApiDocs formats attribute with multiple named arguments`` () = let ``ApiDocs formats attribute with name and suffix`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -515,12 +415,7 @@ let ``ApiDocs formats attribute with name and suffix`` () = let ``ApiDocs formats attribute with fullName`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -539,12 +434,7 @@ let ``ApiDocs formats attribute with fullName`` () = let ``ApiDocs formats attribute with fullName and suffix`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "FormatTestModule" @@ -563,12 +453,7 @@ let ``ApiDocs formats attribute with fullName and suffix`` () = let ``ApiDocs IsObsolete returns true on obsolete attribute`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "ObsoleteTestModule" @@ -582,12 +467,7 @@ let ``ApiDocs IsObsolete returns true on obsolete attribute`` () = let ``ApiDocs IsObsolete returns true on obsolete attribute and finds obsolete message`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "ObsoleteTestModule" @@ -602,12 +482,7 @@ let ``ApiDocs IsObsolete returns true on obsolete attribute and finds obsolete m let ``ApiDocs IsObsolete returns false on not obsolete attribute and finds no obsolete message`` () = let moduleInfos = ApiDocs - .GenerateModel( - [ inputs ], - collectionName = "AttributeTestLib", - substitutions = info, - libDirs = [ testBin ] - ) + .GenerateModel([ inputs ], collectionName = "AttributeTestLib", substitutions = info, libDirs = [ testBin ]) .EntityInfos let module' = moduleInfos |> findModule "ObsoleteTestModule" diff --git a/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs b/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs index c319d1b70..ffc0df941 100644 --- a/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs +++ b/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs @@ -20,14 +20,14 @@ open FsUnitTyped // Check that snippet constains a specific span let containsSpan f snips = snips - |> Seq.exists (fun (Snippet (_, lines)) -> lines |> Seq.exists (fun (Line (_, spans)) -> spans |> Seq.exists f)) + |> Seq.exists (fun (Snippet(_, lines)) -> lines |> Seq.exists (fun (Line(_, spans)) -> spans |> Seq.exists f)) // Check that tool tips contains a specified token let (|ToolTipWithLiteral|_|) text tips = if Seq.exists (function - | Literal (tip) -> tip.Contains(text: string) + | Literal(tip) -> tip.Contains(text: string) | _ -> false) tips then @@ -49,7 +49,7 @@ let ``Simple code snippet is formatted with tool tips`` () = snips |> containsSpan (function - | TokenSpan.Token (_, "hello", Some (ToolTipWithLiteral "val hello: int")) -> true + | TokenSpan.Token(_, "hello", Some(ToolTipWithLiteral "val hello: int")) -> true | _ -> false) |> shouldEqual true @@ -68,7 +68,7 @@ nameof x snips |> containsSpan (function - | TokenSpan.Token (_, "nameof", Some (ToolTipWithLiteral "val nameof: 'T -> string")) -> true + | TokenSpan.Token(_, "nameof", Some(ToolTipWithLiteral "val nameof: 'T -> string")) -> true | _ -> false) |> shouldEqual true @@ -155,7 +155,7 @@ let ``Non-unicode characters do not cause exception`` () = let _snips, errors = CodeFormatter.ParseAndCheckSource("/somewhere/test.fsx", source.Trim(), None, None, ignore) errors.Length |> shouldBeGreaterThan 0 - let (SourceError (_, _, _, msg)) = errors.[0] + let (SourceError(_, _, _, msg)) = errors.[0] msg |> shouldContainText "✘" [] diff --git a/tests/FSharp.Literate.Tests/EvalTests.fs b/tests/FSharp.Literate.Tests/EvalTests.fs index a376b60c5..4b52f3871 100644 --- a/tests/FSharp.Literate.Tests/EvalTests.fs +++ b/tests/FSharp.Literate.Tests/EvalTests.fs @@ -46,28 +46,28 @@ printf ">>%d<<" 12343 // Contains formatted code and markdown doc.Paragraphs |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | Paragraph ([ Strong ([ Literal ("hello", _) ], _) ], _) -> true + | Paragraph([ Strong([ Literal("hello", _) ], _) ], _) -> true | _ -> false) // Contains transformed output - not using 'include-value' and 'include-output' gives odd execution sequence numbers doc.Paragraphs |> shouldMatchPar (function - | OutputBlock ("42", "text/plain", Some 4) -> true + | OutputBlock("42", "text/plain", Some 4) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | OutputBlock ("85", "text/plain", Some 5) -> true + | OutputBlock("85", "text/plain", Some 5) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | OutputBlock (">>12343<<", "text/plain", Some 3) -> true + | OutputBlock(">>12343<<", "text/plain", Some 3) -> true | _ -> false) [] @@ -102,27 +102,27 @@ test2 + 16 // Contains transformed output doc.Paragraphs |> shouldMatchPar (function - | OutputBlock ("42", "text/plain", Some 2) -> true + | OutputBlock("42", "text/plain", Some 2) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | OutputBlock ("100", "text/plain", Some 3) -> true + | OutputBlock("100", "text/plain", Some 3) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | OutputBlock (">>12343<<", "text/plain", Some 4) -> true + | OutputBlock(">>12343<<", "text/plain", Some 4) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | OutputBlock (">>12345<<", "text/plain", Some 5) -> true + | OutputBlock(">>12345<<", "text/plain", Some 5) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | OutputBlock ("101", "text/plain", Some 5) -> true + | OutputBlock("101", "text/plain", Some 5) -> true | _ -> false) [] @@ -162,7 +162,7 @@ let test = [1;2;3] doc.Paragraphs |> shouldMatchPar (function - | ListBlock (Ordered, items, None) -> + | ListBlock(Ordered, items, None) -> items = [ [ Paragraph([ Literal("1", None) ], None) ] [ Paragraph([ Literal("2", None) ], None) ] [ Paragraph([ Literal("3", None) ], None) ] ] diff --git a/tests/FSharp.Literate.Tests/LiterateTests.fs b/tests/FSharp.Literate.Tests/LiterateTests.fs index fa488391f..10b88cf65 100644 --- a/tests/FSharp.Literate.Tests/LiterateTests.fs +++ b/tests/FSharp.Literate.Tests/LiterateTests.fs @@ -51,19 +51,19 @@ b""", //[/test] doc.Paragraphs |> shouldMatchPar (function - | Paragraph ([ Literal ("a", Some ({ StartLine = 2 })) ], Some ({ StartLine = 2 })) -> true + | Paragraph([ Literal("a", Some({ StartLine = 2 })) ], Some({ StartLine = 2 })) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | Paragraph ([ Literal ("b", Some ({ StartLine = 6 })) ], Some ({ StartLine = 6 })) -> true + | Paragraph([ Literal("b", Some({ StartLine = 6 })) ], Some({ StartLine = 6 })) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | EmbedParagraphs (:? LiterateParagraph as cd, Some ({ StartLine = 4 })) -> + | EmbedParagraphs(:? LiterateParagraph as cd, Some({ StartLine = 4 })) -> match cd with - | LanguageTaggedCode ("csharp", text, _popts) -> text.Contains "magic" + | LanguageTaggedCode("csharp", text, _popts) -> text.Contains "magic" | _ -> false | _ -> false) @@ -84,13 +84,13 @@ let test = 42""" doc.Paragraphs |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | Paragraph ([ Strong ([ Literal ("hello", Some ({ StartLine = 1 })) ], Some ({ StartLine = 1 })) ], - Some ({ StartLine = 1 })) -> true + | Paragraph([ Strong([ Literal("hello", Some({ StartLine = 1 })) ], Some({ StartLine = 1 })) ], + Some({ StartLine = 1 })) -> true | _ -> false) [] @@ -112,12 +112,12 @@ let test = 42""" doc.Paragraphs.[0..0] |> shouldMatchPar (function - | YamlFrontmatter ([ _; _ ], _) -> true + | YamlFrontmatter([ _; _ ], _) -> true | _ -> false) doc.Paragraphs.[1..1] |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) [] @@ -141,7 +141,7 @@ let test = 42""" doc.Paragraphs.[0..0] |> shouldMatchPar (function - | YamlFrontmatter ([ _; _ ], _) -> true + | YamlFrontmatter([ _; _ ], _) -> true | _ -> false) doc.Paragraphs.[1..1] @@ -151,7 +151,7 @@ let test = 42""" doc.Paragraphs.[2..2] |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) @@ -172,12 +172,12 @@ let test = 42""" doc.Paragraphs.[0..0] |> shouldMatchPar (function - | YamlFrontmatter ([], _) -> true + | YamlFrontmatter([], _) -> true | _ -> false) doc.Paragraphs.[1..1] |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) [] @@ -201,7 +201,7 @@ let test = 42 doc.Paragraphs.[0..0] |> shouldMatchPar (function - | YamlFrontmatter ([ _; _ ], _) -> true + | YamlFrontmatter([ _; _ ], _) -> true | _ -> false) doc.Paragraphs.[1..1] @@ -221,7 +221,7 @@ let test = 42""" doc.Paragraphs |> shouldMatchPar (function - | Heading (2, [ Literal ("Heading", Some ({ StartLine = 1 })) ], Some ({ StartLine = 1 })) -> true + | Heading(2, [ Literal("Heading", Some({ StartLine = 1 })) ], Some({ StartLine = 1 })) -> true | _ -> false) [] @@ -238,13 +238,13 @@ let ``Can parse markdown with F# snippet`` () = doc.Paragraphs |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | Paragraph ([ Strong ([ Literal ("hello", Some ({ StartLine = 2 })) ], Some ({ StartLine = 2 })) ], - Some ({ StartLine = 2 })) -> true + | Paragraph([ Strong([ Literal("hello", Some({ StartLine = 2 })) ], Some({ StartLine = 2 })) ], + Some({ StartLine = 2 })) -> true | _ -> false) [] @@ -263,13 +263,13 @@ let test = 42 doc.Paragraphs |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | Paragraph ([ Strong ([ Literal ("hello", Some ({ StartLine = 2 })) ], Some ({ StartLine = 2 })) ], - Some ({ StartLine = 2 })) -> true + | Paragraph([ Strong([ Literal("hello", Some({ StartLine = 2 })) ], Some({ StartLine = 2 })) ], + Some({ StartLine = 2 })) -> true | _ -> false) [] @@ -288,7 +288,7 @@ let test = 42 doc.Paragraphs |> shouldMatchPar (function - | MarkdownPatterns.LiterateParagraph (LiterateCode _) -> true + | MarkdownPatterns.LiterateParagraph(LiterateCode _) -> true | _ -> false) [] @@ -305,17 +305,17 @@ some [link][ref] to doc.Paragraphs |> shouldMatchPar (function - | ListBlock (_, _, _) -> true + | ListBlock(_, _, _) -> true | _ -> false) doc.Paragraphs |> shouldMatchSpan (function - | Literal ("Article", None) -> true + | Literal("Article", None) -> true | _ -> false) doc.Paragraphs |> shouldMatchSpan (function - | Literal (" - Author", None) -> true + | Literal(" - Author", None) -> true | _ -> false) [] @@ -961,7 +961,7 @@ let add a b = a + b doc.Paragraphs |> shouldMatchPar (function - | Heading (_, [ Literal ("demo", Some ({ StartLine = 1 })) ], Some ({ StartLine = 1 })) -> true + | Heading(_, [ Literal("demo", Some({ StartLine = 1 })) ], Some({ StartLine = 1 })) -> true | _ -> false) @@ -980,12 +980,12 @@ let mul a b = a * b doc.Paragraphs |> shouldMatchPar (function - | Heading (_, [ Literal ("demo1", Some ({ StartLine = 1 })) ], Some ({ StartLine = 1 })) -> true + | Heading(_, [ Literal("demo1", Some({ StartLine = 1 })) ], Some({ StartLine = 1 })) -> true | _ -> false) doc.Paragraphs |> shouldMatchPar (function - | Heading (_, [ Literal ("demo2", Some ({ StartLine = 1 })) ], Some ({ StartLine = 1 })) -> true + | Heading(_, [ Literal("demo2", Some({ StartLine = 1 })) ], Some({ StartLine = 1 })) -> true | _ -> false) [] diff --git a/tests/FSharp.Markdown.Tests/Externals.fs b/tests/FSharp.Markdown.Tests/Externals.fs index 284ec47e2..d0833adc4 100644 --- a/tests/FSharp.Markdown.Tests/Externals.fs +++ b/tests/FSharp.Markdown.Tests/Externals.fs @@ -93,7 +93,7 @@ let executeTest (dir: string) (source: string) (target: string) (verify: string) [] let ``Run external test`` (actualName: string) (expectedName: string) (actual: string) (expected: string) = match executeTest actualName expectedName actual expected with - | Some (actualName, expectedName, actual, expected) -> + | Some(actualName, expectedName, actual, expected) -> if actual = expected then File.Delete(expectedName) diff --git a/tests/FSharp.Markdown.Tests/Markdown.fs b/tests/FSharp.Markdown.Tests/Markdown.fs index 7899d29b9..c38eedf34 100644 --- a/tests/FSharp.Markdown.Tests/Markdown.fs +++ b/tests/FSharp.Markdown.Tests/Markdown.fs @@ -200,15 +200,15 @@ let ``Should be able to create nested list item with two paragraphs`` () = ) ] match doc.Paragraphs.Head with - | ListBlock (Unordered, - [ [ Span ([ Literal ("a", - Some ({ StartLine = 2 - StartColumn = 2 - EndLine = 2 - EndColumn = 3 })) ], - _) - ListBlock (Unordered, [ body ], _) ] ], - _) -> body |> shouldEqual expectedBody + | ListBlock(Unordered, + [ [ Span([ Literal("a", + Some({ StartLine = 2 + StartColumn = 2 + EndLine = 2 + EndColumn = 3 })) ], + _) + ListBlock(Unordered, [ body ], _) ] ], + _) -> body |> shouldEqual expectedBody | _ -> Assert.Fail "Expected list block with a nested list block" []