Skip to content

Commit

Permalink
chore: cleanup wrapper.go
Browse files Browse the repository at this point in the history
  • Loading branch information
bevzzz committed Mar 5, 2024
1 parent d807ef1 commit 1a26fa4
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions render/html/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ func (wr *Wrapper) WrapInput(w io.Writer, cell schema.Cell, render render.Render
}
tag.CloseLast()

isCode := cell.Type() == schema.Code
isMd := cell.Type() == schema.Markdown
if isCode {
switch cell.Type() {
case schema.Code:
tag.Open("div", attributes{
"class": {
"jp-CodeMirrorEditor",
Expand All @@ -94,7 +93,8 @@ func (wr *Wrapper) WrapInput(w io.Writer, cell schema.Cell, render render.Render

tag.Open("div", attributes{"class": {"cm-editor", "cm-s-jupyter"}})
tag.Open("div", attributes{"class": {"highlight", "hl-ipython3"}})
} else if isMd {

case schema.Markdown:
tag.Open("div", attributes{
"class": {
"jp-RenderedMarkdown",
Expand All @@ -105,7 +105,6 @@ func (wr *Wrapper) WrapInput(w io.Writer, cell schema.Cell, render render.Render
})
}

// Cell itself
_ = render(w, cell)
return nil
}
Expand All @@ -115,13 +114,10 @@ func (wr *Wrapper) WrapOutput(w io.Writer, cell schema.Outputter, render render.
defer tag.Close()

tag.Open("div", attributes{"class": {"jp-Cell-outputWrapper"}})

tag.OpenInline("div", attributes{"class": {"jp-Collapser", "jp-OutputCollapser", "jp-Cell-outputCollapser"}})
tag.CloseLast()

tag.Open("div", attributes{"class": {"jp-OutputArea jp-Cell-outputArea"}})

// TODO: see how application/json would be handled
// TODO: jp-RenderedJavaScript is a thing and so is jp-RenderedLatex (but I don't think we need to do anything about the latter)

var child bool
Expand Down Expand Up @@ -155,11 +151,10 @@ func (wr *Wrapper) WrapOutput(w io.Writer, cell schema.Outputter, render render.
} else if strings.HasPrefix(datamimetype, "image/") {
renderedClass = "jp-RenderedImage"
child = true
} else if datamimetype == "application/vnd.jupyter.stderr" {
} else if datamimetype == common.Stderr {
renderedClass = "jp-RenderedText"
}

// Looks like this will always wrap the whole output area!
if child {
tag.Open("div", attributes{"class": {childClass}})
}
Expand Down

0 comments on commit 1a26fa4

Please sign in to comment.