summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2017-08-24 17:10:26 +0200
committerclsr <clsr@clsr.net>2017-08-24 17:10:26 +0200
commited64d2fb11b4833a8dcbe29225f90bf6462dc8ad (patch)
tree437d66567ebb4fdaee6ccc5b67f64d5c00323d91
parent28398c213bc6a798108421f79659e7d97ca9dbc2 (diff)
downloadcn-http-0.1.4.tar.gz
cn-http-0.1.4.zip
Update to cnm-go 0.2.0v0.1.4
-rw-r--r--cnhttp.go24
-rw-r--r--templates/content.html20
2 files changed, 10 insertions, 34 deletions
diff --git a/cnhttp.go b/cnhttp.go
index 8305de3..24b3bb5 100644
--- a/cnhttp.go
+++ b/cnhttp.go
@@ -301,8 +301,7 @@ type site struct {
func genToc(b cnm.Block) []tocSection {
var res []tocSection
- switch v := b.(type) {
- case *cnm.SectionBlock:
+ if v, ok := b.(*cnm.SectionBlock); ok && v != nil {
if t := v.Title(); t != "" {
var ch []tocSection
for _, c := range v.Children() {
@@ -317,26 +316,7 @@ func genToc(b cnm.Block) []tocSection {
res = append(res, genToc(bl)...)
}
}
- case *cnm.TableBlock:
- for _, bl := range v.Rows() {
- res = append(res, genToc(bl)...)
- }
- case *cnm.HeaderBlock:
- for _, bl := range v.Children() {
- res = append(res, genToc(bl)...)
- }
- case *cnm.RowBlock:
- for _, bl := range v.Children() {
- res = append(res, genToc(bl)...)
- }
- case *cnm.ContentBlock:
- if v == nil {
- break
- }
- for _, bl := range v.Children() {
- res = append(res, genToc(bl)...)
- }
- case *cnm.ListBlock:
+ } else if v, ok := b.(cnm.ContainerBlock); ok && v != nil {
for _, bl := range v.Children() {
res = append(res, genToc(bl)...)
}
diff --git a/templates/content.html b/templates/content.html
index 73f18c7..4616a10 100644
--- a/templates/content.html
+++ b/templates/content.html
@@ -37,7 +37,7 @@
{{- if eq .Name "table" -}}
<table class="cnm-table">
- {{- range .Rows -}}
+ {{- range .Children -}}
{{- template "content.html" . -}}
{{- end -}}
</table>
@@ -79,19 +79,15 @@
{{- end -}}
{{- if eq .Name "text" -}}
- {{- if eq .Format "" "plain"}}{{range .Contents.Paragraphs -}}
-<p class="cnm-text">{{.}}</p>
- {{- end}}{{end -}}
- {{- if eq .Format "fmt" -}}
- {{- range .Contents.Paragraphs -}}
- {{- cnmfmt . -}}
- {{- end -}}
- {{- end -}}
- {{- if not (eq .Format "" "plain" "fmt") -}}
-<pre class="cnm-text cnm-text-pre">{{.Contents.Text}}</pre>
+ {{- if eq .Format "" "plain" "pre" "fmt" -}}
+ {{- if eq .Format "" "plain"}}{{range .Contents.Paragraphs}}<p class="cnm-text">{{.}}</p>{{end}}{{end -}}
+ {{- if eq .Format "pre"}}<pre class="cnm-text cnm-text-pre">{{.Contents.Text}}</pre>{{end -}}
+ {{- if eq .Format "fmt"}}{{range .Contents.Paragraphs}}{{cnmfmt .}}{{end}}{{end -}}
+ {{- else -}}
+ <pre class="cnm-text cnm-text-raw">{{.Contents.Text}}</pre>
{{- end -}}
{{- end -}}
{{- if eq .Name "raw" -}}
-<pre class="cnm-raw"><code class="cnm-raw-{{lang .Syntax}}">{{.Contents}}</code></pre>
+<pre class="cnm-raw"><code class="cnm-raw-{{lang .Syntax}}">{{.Contents.Text}}</code></pre>
{{- end -}}