Skip to content

Commit 7924082

Browse files
authored
dhall-docs: render standalone text files as preformatted text (#2565)
1 parent 1b5e02e commit 7924082

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
*.golden binary
66
dhall-csv/tasty/data/* binary
77
dhall-docs/tasty/data/golden/**/*.html binary
8+
dhall-docs/tasty/data/package/StandaloneTextFile.txt binary
89
dhall-yaml/tasty/data/* binary

dhall-docs/src/Dhall/Docs/Html.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dhallFileToHtml filePath contents expr examples header params@DocParams{..} =
7777
htmlTitle = breadCrumbsToText breadcrumb
7878
clipboardText = fold baseImportUrl <> htmlTitle
7979

80-
-- | Generates an @`Html` ()@ with all the information about a dhall file
80+
-- | Generates an @`Html` ()@ with all the information about a non-dhall text file
8181
textFileToHtml
8282
:: Path Rel File -- ^ Source file name, used to extract the title
8383
-> Text -- ^ Contents of the file
@@ -93,7 +93,7 @@ textFileToHtml filePath contents params@DocParams{..} =
9393
copyToClipboardButton clipboardText
9494
br_ []
9595
h3_ "Source"
96-
div_ [class_ "source-code"] (toHtml contents)
96+
div_ [class_ "source-code"] $ pre_ (toHtml contents)
9797
where
9898
breadcrumb = relPathToBreadcrumb filePath
9999
htmlTitle = breadCrumbsToText breadcrumb
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<title>/StandaloneTextFile.txt</title>
5+
<link rel="stylesheet" type="text/css" href="index.css">
6+
<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">
7+
<script type="text/javascript" src="index.js">
8+
</script>
9+
<meta charset="UTF-8">
10+
</head>
11+
<body>
12+
<div class="nav-bar">
13+
<img class="dhall-icon" src="dhall-icon.svg">
14+
<p class="package-title">test-package</p>
15+
<div class="nav-bar-content-divider">
16+
</div>
17+
<a id="switch-light-dark-mode" class="nav-option">Switch Light/Dark Mode</a>
18+
</div>
19+
<div class="main-container">
20+
<h2 class="doc-title">
21+
<span class="crumb-divider">/</span>
22+
<a href="index.html">test-package</a>
23+
<span class="crumb-divider">/</span>
24+
<span class="title-crumb" href="index.html">StandaloneTextFile.txt</span>
25+
</h2>
26+
<a class="copy-to-clipboard" data-path="/StandaloneTextFile.txt">
27+
<i>
28+
<small>Copy path to clipboard</small>
29+
</i>
30+
</a>
31+
<br>
32+
<h3>Source</h3>
33+
<div class="source-code">
34+
<pre>This is a text file that is not referenced by any dhall file.
35+
36+
+---------------------------------------------------+
37+
| It should be displayed as &lt;pre&gt;preformatted&lt;/pre&gt; |
38+
| text, with horizontal and vertical whitespace |
39+
| preserved, to keep it readable. |
40+
+---------------------------------------------------+
41+
</pre>
42+
</div>
43+
</div>
44+
</body>
45+
</html>

dhall-docs/tasty/data/golden/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ <h3>Exported files: </h3>
171171
</span>
172172
</li>
173173
<li>
174+
<a href="StandaloneTextFile.txt.html">StandaloneTextFile.txt</a>
175+
</li>
176+
<li>
174177
<a href="TwoAnnotations.dhall.html">TwoAnnotations.dhall</a>
175178
<span class="of-type-token">:</span>
176179
<span class="dhall-type source-code">
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This is a text file that is not referenced by any dhall file.
2+
3+
+---------------------------------------------------+
4+
| It should be displayed as <pre>preformatted</pre> |
5+
| text, with horizontal and vertical whitespace |
6+
| preserved, to keep it readable. |
7+
+---------------------------------------------------+

0 commit comments

Comments
 (0)