Skip to content

Commit de1330a

Browse files
committed
Add unit for previous and next substitutions.
1 parent 9af5810 commit de1330a

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ tests/FSharp.Literate.Tests/output1/
4747
.vscode/
4848
.DS_Store
4949
tests/FSharp.Literate.Tests/output2/
50+
tests/FSharp.Literate.Tests/previous-next-output/

tests/FSharp.Literate.Tests/DocContentTests.fs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,42 @@ let ``Can build doc content using relative input path`` () =
186186
let f2md2 = File.ReadAllText(rootOutputFolderAsGiven </> "folder2" </> "in-folder2.md")
187187
f1md1 |> shouldContainText """../folder2/in-folder2.md"""
188188
f2md2 |> shouldContainText """../folder1/in-folder1.md"""
189+
190+
[<Test>]
191+
let ``Parses frontmatter correctly `` () =
192+
let rootOutputFolderAsGiven = __SOURCE_DIRECTORY__ </> "previous-next-output"
193+
194+
let relativeInputFolderAsGiven =
195+
Path.GetRelativePath(System.Environment.CurrentDirectory, __SOURCE_DIRECTORY__ </> "previous-next")
196+
197+
if Directory.Exists(rootOutputFolderAsGiven) then
198+
Directory.Delete(rootOutputFolderAsGiven, true)
199+
200+
let content =
201+
DocContent(
202+
rootOutputFolderAsGiven,
203+
Map.empty,
204+
lineNumbers = None,
205+
evaluate = false,
206+
substitutions = [],
207+
saveImages = None,
208+
watch = false,
209+
root = "https://en.wikipedia.org",
210+
crefResolver = (fun _ -> None),
211+
onError = failwith
212+
)
213+
214+
let docModels = content.Convert(relativeInputFolderAsGiven, None, [])
215+
let globals = []
216+
217+
for _thing, action in docModels do
218+
action globals
219+
220+
let fellowshipHtml = rootOutputFolderAsGiven </> "fellowship.html" |> File.ReadAllText
221+
let twoTowersHtml = rootOutputFolderAsGiven </> "two-tower.html" |> File.ReadAllText
222+
let returnHtml = rootOutputFolderAsGiven </> "return.html" |> File.ReadAllText
223+
224+
fellowshipHtml |> shouldContainText "<a href=\"two-tower.html\">Next</a>"
225+
twoTowersHtml |> shouldContainText "<a href=\"fellowship.html\">Previous</a>"
226+
twoTowersHtml |> shouldContainText "<a href=\"return.html\">Next</a>"
227+
returnHtml |> shouldContainText "<a href=\"two-tower.html\">Previous</a>"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
index: 1
3+
categoryindex: 1
4+
category: fiction
5+
---
6+
7+
# The Fellowship of the ring
8+
9+
[Next]({{fsdocs-next-page-link}})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
categoryindex: 1
3+
category: fiction
4+
index: 3
5+
---
6+
7+
# The Return of the King
8+
9+
[Previous]({{fsdocs-previous-page-link}})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(**
2+
---
3+
category: fiction
4+
index: 2
5+
6+
categoryindex: 1
7+
---
8+
9+
# The Two Towers
10+
11+
[Previous]({{fsdocs-previous-page-link}})
12+
[Next]({{fsdocs-next-page-link}})
13+
*)

0 commit comments

Comments
 (0)