forked from dotnet/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguage.fsx
39 lines (34 loc) · 1.08 KB
/
Language.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(** ---
category: Release Notes
categoryindex: 600
index: 2
title: F# Language
---
# F\# Language
*)
(*** hide ***)
#load "./.aux/Common.fsx"
open System.IO
open Markdig
open Common
let path = Path.Combine(__SOURCE_DIRECTORY__, ".Language")
Directory.EnumerateFiles(path, "*.md")
|> Seq.sortWith (fun a b ->
let a = Path.GetFileNameWithoutExtension a
let b = Path.GetFileNameWithoutExtension b
match a, b with
| "preview", "preview" -> 0
| "preview", _ -> -1
| _, "preview" -> 1
| _, _ ->
match System.Decimal.TryParse(b), System.Decimal.TryParse(b) with
| (true, a) , ( true, b) -> compare (int b) (int a)
| _ -> failwithf "Cannot compare %s with %s" b a
)
|> Seq.map (fun file ->
let version = Path.GetFileNameWithoutExtension(file)
let version = if version = "preview" then "Preview" else version
let content = File.ReadAllText file |> Markdown.ToHtml |> transformH3 version
$"""<h2><a name="%s{version}" class="anchor" href="#%s{version}">%s{version}</a></h2>%s{content}""")
|> String.concat "\n"
(*** include-it-raw ***)