diff --git a/render/html/html.go b/render/html/html.go index 9b83eb9..fa598c3 100644 --- a/render/html/html.go +++ b/render/html/html.go @@ -77,8 +77,8 @@ func (r *Renderer) renderCode(w io.Writer, cell schema.Cell) error { return nil } - div.Open(w, attributes{"class": {"cm-editor", "cm-s-jupyter"}}) - div.Open(w, attributes{"class": {"highlight", "hl-ipython3"}}) + div.Open(w, attributes{"class": {"cm-editor", "cm-s-jupyter"}}, true) + div.Open(w, attributes{"class": {"highlight", "hl-ipython3"}}, true) io.WriteString(w, "
and collapsing functionality
// Pure CSS Collapsible: https://www.digitalocean.com/community/tutorials/css-collapsible
- div.Open(w, attributes{"class": {"jp-InputArea", "jp-Cell-inputArea"}})
+ div.Open(w, attributes{"class": {"jp-InputArea", "jp-Cell-inputArea"}}, true)
// Prompt In:[1]
- div.Open(w, attributes{"class": {"jp-InputPrompt", "jp-InputArea-prompt"}})
+ div.Open(w, attributes{"class": {"jp-InputPrompt", "jp-InputArea-prompt"}}, false)
if ex, ok := cell.(interface{ ExecutionCount() int }); ok {
fmt.Fprintf(w, "In\u00a0[%d]:", ex.ExecutionCount())
}
@@ -78,7 +78,7 @@ func (wr *Wrapper) WrapInput(w io.Writer, cell schema.Cell, render render.Render
"jp-InputArea-editor",
},
"data-type": {"inline"},
- })
+ }, true)
} else if isMd {
div.Open(w, attributes{
"class": {
@@ -87,7 +87,7 @@ func (wr *Wrapper) WrapInput(w io.Writer, cell schema.Cell, render render.Render
"jp-RenderedHTMLCommon",
},
"data-mime-type": {common.MarkdownText},
- })
+ }, true)
}
// Cell itself
@@ -103,9 +103,9 @@ func (wr *Wrapper) WrapInput(w io.Writer, cell schema.Cell, render render.Render
}
func (wr *Wrapper) WrapOutput(w io.Writer, cell schema.Outputter, render render.RenderCellFunc) error {
- div.Open(w, attributes{"class": {"jp-Cell-outputWrapper"}})
+ div.Open(w, attributes{"class": {"jp-Cell-outputWrapper"}}, true)
div.OpenClose(w, attributes{"class": {"jp-Collapser", "jp-OutputCollapser", "jp-Cell-outputCollapser"}})
- div.Open(w, attributes{"class": {"jp-OutputArea jp-Cell-outputArea"}})
+ div.Open(w, attributes{"class": {"jp-OutputArea jp-Cell-outputArea"}}, true)
// 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)
@@ -147,10 +147,10 @@ func (wr *Wrapper) WrapOutput(w io.Writer, cell schema.Outputter, render render.
// Looks like this will always wrap the whole output area!
if child {
- div.Open(w, attributes{"class": {childClass}})
+ div.Open(w, attributes{"class": {childClass}}, true)
}
- div.Open(w, attributes{"class": {"jp-OutputPrompt", "jp-OutputArea-prompt"}})
+ div.Open(w, attributes{"class": {"jp-OutputPrompt", "jp-OutputArea-prompt"}}, false)
for _, out := range cell.Outputs() {
if ex, ok := out.(interface{ ExecutionCount() int }); ok {
fmt.Fprintf(w, "Out\u00a0[%d]:", ex.ExecutionCount())
@@ -162,7 +162,7 @@ func (wr *Wrapper) WrapOutput(w io.Writer, cell schema.Outputter, render render.
div.Open(w, attributes{
"class": {renderedClass, "jp-OutputArea-output", outputtypeclass},
"data-mime-type": {datamimetype},
- })
+ }, true)
for _, out := range cell.Outputs() {
_ = render(w, out)
}
@@ -184,8 +184,8 @@ const (
type tag string
// Open the tag with the attributes, e.g. .
-func (t tag) Open(w io.Writer, attrs attributes) {
- t._open(w, attrs, true)
+func (t tag) Open(w io.Writer, attrs attributes, newline bool) {
+ t._open(w, attrs, newline)
}
func (t tag) _open(w io.Writer, attrs attributes, newline bool) {
@@ -221,7 +221,7 @@ type tagger struct {
// Open opens the tag with the attributes.
func (t *tagger) Open(tag tag, w io.Writer, attr attributes) {
- tag.Open(w, attr)
+ tag.Open(w, attr, true) // TODO: redo
t.opened = append(t.opened, tag)
}
diff --git a/testdata/notebook.golden b/testdata/notebook.golden
index 31b5547..df796b5 100644
--- a/testdata/notebook.golden
+++ b/testdata/notebook.golden
@@ -3,8 +3,7 @@
-
-
+
# Introduction to the JupyterLab and Jupyter Notebooks
@@ -33,8 +32,7 @@ Note how the code and the results of running the code are bundled together.
-
-In [5]:
+In [5]:
@@ -57,8 +55,7 @@ plt.show()
-
-
+
@@ -71,8 +68,7 @@ plt.show()
-
-
+
@@ -81,8 +77,7 @@ plt.show()
-
-
+
# Markdown Cell
## LaTeX Equation
@@ -99,8 +94,7 @@ $$
-
-In [7]:
+In [7]:
@@ -117,8 +111,7 @@ print(d["unknown key"])
-
-
+
[0;31m---------------------------------------------------------------------------[0m
[0;31mKeyError[0m Traceback (most recent call last)
@@ -138,8 +131,7 @@ Cell [0;32mIn[7], line 5[0m
-
-
+
Hello, HTML!
This is a short example of raw HTML.
- Item 1
- Item 2
- Item 3
@@ -148,8 +140,7 @@ Cell [0;32mIn[7], line 5[0m
-
-
+
## Cell attachements
Following are [4 ways to embed images in your Jupyter notebook](https://medium.com/@yogeshkd/four-ways-to-embed-images-in-your-jupyter-notebook-powered-blog-2d28f6d1b6e6):
@@ -161,8 +152,7 @@ Following are [4 ways to embed images in your Jupyter notebook](https://medium.c
-
-In [12]:
+In [12]:
@@ -177,8 +167,7 @@ Image(url="https://images.unsplash.com/photo-1612815292258-f4354f7f5c76?ixid=MXw
-
-Out [12]:
+Out [12]:
@@ -190,8 +179,7 @@ Out [12]:
-
-
+
Using Markdown syntax:
![Waterfall](https://images.unsplash.com/photo-1593322962878-a4b73deb1e39?ixid=MXwxMjA3fDB8MHx0b3BpYy1mZWVkfDc3NHw2c01WalRMU2tlUXx8ZW58MHx8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60)
@@ -203,8 +191,7 @@ Out [12]:
-
-
+
With an HTML tag:
@@ -216,8 +203,7 @@ Out [12]:
-
-In [13]:
+In [13]:
@@ -251,8 +237,7 @@ In [13]:
-
-Out [13]:
+Out [13]:
{'glossary': {'title': 'example glossary',
'GlossDiv': {'title': 'S',
@@ -273,8 +258,7 @@ Out [13]:
-
-In [1]:
+In [1]:
@@ -289,8 +273,7 @@ JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}})
-
-Out [1]:
+Out [1]:
{"a":[1,2,3,4],"b":{"inner1":"helloworld","inner2":"foobar"}}
@@ -302,8 +285,7 @@ Out [1]:
-
-In [15]:
+In [15]:
@@ -316,8 +298,7 @@ In [15]:
-
-
+
Do you approve of the following input? Anything except 'Y'/'Yes' (case-insensitive) will be treated as a no.
@@ -343,8 +324,7 @@ yes
-
-
+
Collapsible HTML
hi, mom!