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

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed Mar 20, 2020
1 parent 9edbde8 commit c0af398
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"html/template"
"io"
"io/ioutil"
"path/filepath"
"strings"

"github.com/alecthomas/chroma"
Expand Down Expand Up @@ -94,7 +95,7 @@ func convertErrorOutput(output output) template.HTML {
}

// Convert ANSI colors to HTML
var linesHTML []string
linesHTML := []string{}
for _, tracebackLine := range output.Traceback {
lineHTML := terminal.Render([]byte(tracebackLine))
linesHTML = append(linesHTML, string(lineHTML))
Expand Down Expand Up @@ -196,7 +197,7 @@ func convertOutput(output output) template.HTML {
// err := nbtohtml.ConvertFile(notebookHTML, notebookPath)
func ConvertFile(writer io.Writer, notebookPath string) error {
// Read file
fileContent, err := ioutil.ReadFile(notebookPath)
fileContent, err := ioutil.ReadFile(filepath.Clean(notebookPath))
if err != nil {
return fmt.Errorf("could not read Jupyter Notebook file at %s", notebookPath)
}
Expand Down
6 changes: 3 additions & 3 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
)

// Documentation of the Jupyter Notebook JSON format: https://ipython.org/ipython-doc/3/notebook/nbformat.html
// (VCS: https://github.com/ipython/ipython-doc/blob/e9c83570cf3dea6d7a6b178ee59869b4f441220f/3/notebook/nbformat.html)
// (VCS: https://github.com/ipython/ipython-doc/blob/e9c83570cf3dea6d7a6b178ee59869b4f441220f/3/notebook/nbformat.html).

// outputData can contain the cell output in various data types.
// Source: https://github.com/jupyter/nbconvert/blob/c837a22d44d98f6a58d1934bd85af1506df48f21/nbconvert/utils/base.py#L16
// outputData can contain the cell output in various data types. Source:
// https://github.com/jupyter/nbconvert/blob/c837a22d44d98f6a58d1934bd85af1506df48f21/nbconvert/utils/base.py#L16.
type outputData struct {
TextHTML []string `json:"text/html,omitempty"`
ApplicationPDF *string `json:"application/pdf,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions test_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const testNotebookString = `{
"output_type": "display_data",
"data": {
"image/svg+xml": [
"<svg id=\"star\" xmlns=\"https://www.w3.org/2000/svg\" width=\"255\" height=\"240\" viewBox=\"0 0 51 48\">\n",
"<svg xmlns=\"https://www.w3.org/2000/svg\" width=\"255\" height=\"240\">\n",
"<path d=\"M25 1l6 17h18L35 29l5 17-15-10-15 10 5-17L1 18h18z\"/>\n",
"</svg>"
]
Expand Down Expand Up @@ -194,7 +194,7 @@ var testDisplayDataSVGOutput = output{
OutputType: "display_data",
Data: outputData{
ImageSVGXML: []string{
"<svg id=\"star\" xmlns=\"https://www.w3.org/2000/svg\" width=\"255\" height=\"240\" viewBox=\"0 0 51 48\">\n",
"<svg xmlns=\"https://www.w3.org/2000/svg\" width=\"255\" height=\"240\">\n",
"<path d=\"M25 1l6 17h18L35 29l5 17-15-10-15 10 5-17L1 18h18z\"/>\n",
"</svg>",
},
Expand Down

0 comments on commit c0af398

Please sign in to comment.