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 @@ + + + +/StandaloneTextFile.txt + + + + + + + +
+

+/ +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 @@

Exported files:

  • +StandaloneTextFile.txt +
  • +
  • TwoAnnotations.dhall : diff --git a/dhall-docs/tasty/data/package/StandaloneTextFile.txt b/dhall-docs/tasty/data/package/StandaloneTextFile.txt new file mode 100644 index 000000000..a3e6eac66 --- /dev/null +++ b/dhall-docs/tasty/data/package/StandaloneTextFile.txt @@ -0,0 +1,7 @@ +This is a text file that is not referenced by any dhall file. + ++---------------------------------------------------+ +| It should be displayed as
    preformatted
    | +| text, with horizontal and vertical whitespace | +| preserved, to keep it readable. | ++---------------------------------------------------+ From ef9ce3023e7a0dcfe23b0de1f7d48d0d88fd2b47 Mon Sep 17 00:00:00 2001 From: kukimik <53443372+kukimik@users.noreply.github.com> Date: Wed, 10 Jan 2024 08:56:38 +0100 Subject: [PATCH 2/2] prevent git converting dos/unix newlines in a test file --- .gitattributes | 1 + 1 file changed, 1 insertion(+) 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