diff --git a/.gitattributes b/.gitattributes
index ebff33b13..f63d43b42 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -5,4 +5,5 @@
*.golden binary
dhall-csv/tasty/data/* binary
dhall-docs/tasty/data/golden/**/*.html binary
+dhall-docs/tasty/data/package/StandaloneTextFile.txt binary
dhall-yaml/tasty/data/* binary
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 @@