Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Improve output class names
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed Mar 21, 2020
1 parent 061c5c7 commit 21e5e1c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,19 @@ func ConvertString(writer io.Writer, notebookString string) error {
"convertPrompt": convertPrompt,
"convertInput": convertInput,
"convertOutput": convertOutput,
"getCellClasses": func(cell cell) string {
return "cell cell-" + cell.CellType
},
"getOutputClasses": func(output output) string {
outputTypeClass := strings.ReplaceAll(output.OutputType, "_", "-")
return "output output-" + outputTypeClass
},
})
t, err = t.Parse(`
<div class="notebook">
{{ $fileExtension := .fileExtension }}
{{ range .notebook.Cells }}
<div class="cell cell-{{ .CellType }}">
<div class="{{ . | getCellClasses }}">
<div class="input-wrapper">
<div class="input-prompt">
{{ .ExecutionCount | convertPrompt }}
Expand All @@ -204,7 +211,7 @@ func ConvertString(writer io.Writer, notebookString string) error {
<div class="output-prompt">
{{ .ExecutionCount | convertPrompt }}
</div>
<div class="output output-{{ .OutputType }}">
<div class="{{ . | getOutputClasses }}">
{{ . | convertOutput }}
</div>
</div>
Expand Down

0 comments on commit 21e5e1c

Please sign in to comment.