Skip to content

Commit 5fc55c9

Browse files
committed
fix: code block style in Description field
1 parent 937c399 commit 5fc55c9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

frontend/elm.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"hecrj/html-parser": "2.3.4",
1818
"krisajenkins/remotedata": "6.0.1",
1919
"leojpod/elm-keyboard-shortcut": "1.0.1",
20+
"pablohirafuji/elm-syntax-highlight": "3.6.0",
2021
"truqu/elm-base64": "2.0.4"
2122
},
2223
"indirect": {

frontend/src/Page/Options.elm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import Search
5050
, decodeResolvedFlake
5151
)
5252
import Utils
53+
import SyntaxHighlight exposing (useTheme, oneDark, elm, toBlockHtml)
5354

5455

5556

@@ -189,6 +190,15 @@ viewResultItem nixosChannels channel _ show item =
189190

190191
asPreCode value =
191192
div [] [ pre [] [ code [ class "code-block" ] [ text value ] ] ]
193+
194+
asHighlightPreCode value =
195+
div []
196+
[ useTheme oneDark
197+
, elm value
198+
|> Result.map (toBlockHtml (Just 1))
199+
|> Result.withDefault
200+
(pre [] [ code [ class "code-block" ] [ text value ]])
201+
]
192202

193203
showDetails =
194204
if Just item.source.name == show then
@@ -229,7 +239,7 @@ viewResultItem nixosChannels channel _ show item =
229239
|> Maybe.map
230240
(\example ->
231241
[ div [] [ text "Example" ]
232-
, div [] <| Maybe.withDefault [ asPreCode example ] (Utils.showHtml example)
242+
, div [] <| Maybe.withDefault [ asHighlightPreCode example ] (Utils.showHtml example)
233243
]
234244
)
235245
|> Maybe.withDefault []

frontend/src/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ body {
414414
}
415415
}
416416

417-
.code-block {
417+
.code-block,.sourceCode,.elmsh > code {
418418
display: block;
419419
cursor: text;
420420
}

0 commit comments

Comments
 (0)