Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhall-docs: render standalone text files as preformatted text #2565

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions dhall-docs/src/Dhall/Docs/Html.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
45 changes: 45 additions & 0 deletions dhall-docs/tasty/data/golden/StandaloneTextFile.txt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<head>
<title>/StandaloneTextFile.txt</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&amp;family=Lato:ital,wght@0,400;0,700;1,400&amp;display=swap">
<script type="text/javascript" src="index.js">
</script>
<meta charset="UTF-8">
</head>
<body>
<div class="nav-bar">
<img class="dhall-icon" src="dhall-icon.svg">
<p class="package-title">test-package</p>
<div class="nav-bar-content-divider">
</div>
<a id="switch-light-dark-mode" class="nav-option">Switch Light/Dark Mode</a>
</div>
<div class="main-container">
<h2 class="doc-title">
<span class="crumb-divider">/</span>
<a href="index.html">test-package</a>
<span class="crumb-divider">/</span>
<span class="title-crumb" href="index.html">StandaloneTextFile.txt</span>
</h2>
<a class="copy-to-clipboard" data-path="/StandaloneTextFile.txt">
<i>
<small>Copy path to clipboard</small>
</i>
</a>
<br>
<h3>Source</h3>
<div class="source-code">
<pre>This is a text file that is not referenced by any dhall file.

+---------------------------------------------------+
| It should be displayed as &lt;pre&gt;preformatted&lt;/pre&gt; |
| text, with horizontal and vertical whitespace |
| preserved, to keep it readable. |
+---------------------------------------------------+
</pre>
</div>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions dhall-docs/tasty/data/golden/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ <h3>Exported files: </h3>
</span>
</li>
<li>
<a href="StandaloneTextFile.txt.html">StandaloneTextFile.txt</a>
</li>
<li>
<a href="TwoAnnotations.dhall.html">TwoAnnotations.dhall</a>
<span class="of-type-token">:</span>
<span class="dhall-type source-code">
Expand Down
7 changes: 7 additions & 0 deletions dhall-docs/tasty/data/package/StandaloneTextFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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. |
+---------------------------------------------------+
Loading