From 9bfc5ad4beb0eda7bfb03c8ddd5efdddc6917cf9 Mon Sep 17 00:00:00 2001
From: kukimik <53443372+kukimik@users.noreply.github.com>
Date: Wed, 3 Jan 2024 22:24:10 +0100
Subject: [PATCH 1/2] dhall-docs: render standalone text files as preformatted
text
---
dhall-docs/src/Dhall/Docs/Html.hs | 4 +-
.../data/golden/StandaloneTextFile.txt.html | 45 +++++++++++++++++++
dhall-docs/tasty/data/golden/index.html | 3 ++
.../tasty/data/package/StandaloneTextFile.txt | 7 +++
4 files changed, 57 insertions(+), 2 deletions(-)
create mode 100644 dhall-docs/tasty/data/golden/StandaloneTextFile.txt.html
create mode 100644 dhall-docs/tasty/data/package/StandaloneTextFile.txt
diff --git a/dhall-docs/src/Dhall/Docs/Html.hs b/dhall-docs/src/Dhall/Docs/Html.hs
index d88608614..cdbd7b785 100644
--- a/dhall-docs/src/Dhall/Docs/Html.hs
+++ b/dhall-docs/src/Dhall/Docs/Html.hs
@@ -77,7 +77,7 @@ dhallFileToHtml filePath contents expr examples header params@DocParams{..} =
htmlTitle = breadCrumbsToText breadcrumb
clipboardText = fold baseImportUrl <> htmlTitle
--- | Generates an @`Html` ()@ with all the information about a dhall file
+-- | Generates an @`Html` ()@ with all the information about a non-dhall text file
textFileToHtml
:: Path Rel File -- ^ Source file name, used to extract the title
-> Text -- ^ Contents of the file
@@ -93,7 +93,7 @@ textFileToHtml filePath contents params@DocParams{..} =
copyToClipboardButton clipboardText
br_ []
h3_ "Source"
- div_ [class_ "source-code"] (toHtml contents)
+ div_ [class_ "source-code"] $ pre_ (toHtml contents)
where
breadcrumb = relPathToBreadcrumb filePath
htmlTitle = breadCrumbsToText breadcrumb
diff --git a/dhall-docs/tasty/data/golden/StandaloneTextFile.txt.html b/dhall-docs/tasty/data/golden/StandaloneTextFile.txt.html
new file mode 100644
index 000000000..f44968416
--- /dev/null
+++ b/dhall-docs/tasty/data/golden/StandaloneTextFile.txt.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+/
+test-package
+/
+StandaloneTextFile.txt
+
+
+
+Copy path to clipboard
+
+
+
+
Source
+
+
This is a text file that is not referenced by any dhall file.
+
++---------------------------------------------------+
+| It should be displayed as <pre>preformatted</pre> |
+| text, with horizontal and vertical whitespace |
+| preserved, to keep it readable. |
++---------------------------------------------------+
+
+
+
+
+
\ No newline at end of file
diff --git a/dhall-docs/tasty/data/golden/index.html b/dhall-docs/tasty/data/golden/index.html
index a976fc0d6..a8b31c437 100644
--- a/dhall-docs/tasty/data/golden/index.html
+++ b/dhall-docs/tasty/data/golden/index.html
@@ -171,6 +171,9 @@