diff --git a/claat/cmd/export_test.go b/claat/cmd/export_test.go index 1bc614491..03fd3e076 100644 --- a/claat/cmd/export_test.go +++ b/claat/cmd/export_test.go @@ -63,7 +63,7 @@ func TestExportCodelabMemory(t *testing.T) { opts := cmd.CmdExportOptions{ Expenv: "web", Output: tmp, - Tmplout: "devsite", + Tmplout: "html", GlobalGA: "UA-99999999-99", } diff --git a/claat/render/html.go b/claat/render/html.go index 57f0039cc..447c2eb4a 100644 --- a/claat/render/html.go +++ b/claat/render/html.go @@ -229,13 +229,7 @@ func (hw *htmlWriter) code(n *nodes.CodeNode) { } hw.writeString(">") } - if hw.format == "devsite" { - hw.writeString("{% verbatim %}") - } hw.writeEscape(n.Value) - if hw.format == "devsite" { - hw.writeString("{% endverbatim %}") - } if !n.Term { hw.writeString("") } @@ -308,11 +302,7 @@ func (hw *htmlWriter) itemsList(n *nodes.ItemsListNode) { } func (hw *htmlWriter) grid(n *nodes.GridNode) { - if hw.format == "devsite" { - hw.writeString("\n") - } else { - hw.writeString("
\n") - } + hw.writeString("
\n") for _, r := range n.Rows { hw.writeString("") for _, c := range r { diff --git a/claat/render/html_test.go b/claat/render/html_test.go index 58b0f0ac3..365f578aa 100644 --- a/claat/render/html_test.go +++ b/claat/render/html_test.go @@ -676,10 +676,9 @@ bar`, func TestCode(t *testing.T) { tests := []struct { - name string - inNode *nodes.CodeNode - inFormat string - out string + name string + inNode *nodes.CodeNode + out string }{ { name: "NoLang", @@ -691,23 +690,11 @@ func TestCode(t *testing.T) { inNode: nodes.NewCodeNode("foobar", false, "c"), out: `
foobar
`, }, - { - name: "NoLangDevsite", - inNode: nodes.NewCodeNode("foobar", false, ""), - inFormat: "devsite", - out: `
{% verbatim %}foobar{% endverbatim %}
`, - }, - { - name: "LangDevsite", - inNode: nodes.NewCodeNode("foobar", false, "c"), - inFormat: "devsite", - out: `
{% verbatim %}foobar{% endverbatim %}
`, - }, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { outBuffer := &bytes.Buffer{} - hw := &htmlWriter{w: outBuffer, format: tc.inFormat} + hw := &htmlWriter{w: outBuffer} hw.code(tc.inNode) out := outBuffer.String() if diff := cmp.Diff(tc.out, out); diff != "" { @@ -873,7 +860,69 @@ func TestOnlyImages(t *testing.T) { } // TODO: test itemsList -// TODO: test grid + +func TestGrid(t *testing.T) { + tests := []struct { + name string + inNode *nodes.GridNode + out string + }{ + { + name: "No rows or cells ", + inNode: nodes.NewGridNode(), + out: "
\n
", + }, + { + name: "One row and no cells", + inNode: nodes.NewGridNode([][]*nodes.GridCell{ + []*nodes.GridCell{}, + }...), + out: "\n\n
", + }, + { + name: "One row and one cell", + inNode: nodes.NewGridNode([][]*nodes.GridCell{ + []*nodes.GridCell{ + &nodes.GridCell{ + Content: nodes.NewListNode([]nodes.Node{ + nodes.NewTextNode(nodes.NewTextNodeOptions{Value: "foo"}), + }...), + }, + }, + }...), + out: "\n\n
foo
", + }, + { + name: "One row and multiple cells", + inNode: nodes.NewGridNode([][]*nodes.GridCell{ + []*nodes.GridCell{ + &nodes.GridCell{ + Content: nodes.NewListNode([]nodes.Node{ + nodes.NewTextNode(nodes.NewTextNodeOptions{Value: "foo"}), + }...), + }, + &nodes.GridCell{ + Content: nodes.NewListNode([]nodes.Node{ + nodes.NewTextNode(nodes.NewTextNodeOptions{Value: "bar"}), + }...), + }, + }, + }...), + out: "\n\n
foobar
", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + outBuffer := &bytes.Buffer{} + hw := &htmlWriter{w: outBuffer} + hw.grid(tc.inNode) + out := outBuffer.String() + if diff := cmp.Diff(tc.out, out); diff != "" { + t.Errorf("hw.grid(%+v) got diff (-want +got):\n%s", tc.inNode, diff) + } + }) + } +} func TestInfobox(t *testing.T) { tests := []struct { diff --git a/claat/render/template-devsite.html b/claat/render/template-devsite.html deleted file mode 100644 index 18d2be08c..000000000 --- a/claat/render/template-devsite.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - {{.Meta.Title}} - {{if .Meta.Extra.project -}} - - {{end -}} - {{if .Meta.Extra.book -}} - - {{end -}} - - {{if .Meta.Summary -}} - - {{- end}} - {{if .Meta.Source -}} - - {{end -}} - - - - - {{if .Meta.Authors -}} - - {{end -}} - {{if .Meta.Extra.robots -}} - - {{end -}} - - - - - - {{range $i, $e := .Steps}}{{if matchEnv .Tags $.Env}} - - {{if eq $i 0}} - - - {{end}} -

- {{inc $i}}. {{.Title}} -

- {{.Content | renderHTML $.Context}} -
- {{end}}{{end}} -
- - diff --git a/claat/render/template.go b/claat/render/template.go index 8b1c1daba..ad73cbc78 100644 --- a/claat/render/template.go +++ b/claat/render/template.go @@ -152,9 +152,6 @@ type template struct { //go:embed template.html var newHTMLTemplate []byte -//go:embed template-devsite.html -var newHTMLDevsiteTemplate []byte - //go:embed template.md var newMDTemplate []byte @@ -174,11 +171,6 @@ func parseTemplate(name string, fmap map[string]interface{}) (executer, error) { bytes: newHTMLTemplate, html: true, } - case "devsite": - tmpl = &template{ - bytes: newHTMLDevsiteTemplate, - html: true, - } case "md": tmpl = &template{ bytes: newMDTemplate,