diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-12-05 02:16:56 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-12-05 02:16:56 +0700 |
| commit | e9fd480321f2d49d07b872e8371cbc5d3be68cea (patch) | |
| tree | 59d97b5bf46e511a2355e59eedb282ff387f8b88 | |
| parent | 83ff35e591f0e7c23b6315fb8b6b836e1bcfb803 (diff) | |
| download | asciidoctor-go-e9fd480321f2d49d07b872e8371cbc5d3be68cea.tar.xz | |
html_backend: parse cell contents by paragraphs
If the cell contents contains multiple paragraphs, parse and render
each of them as separated block paragraph.
| -rw-r--r-- | html_backend.go | 14 | ||||
| -rw-r--r-- | testdata/got.test.html | 10 | ||||
| -rw-r--r-- | testdata/test.html | 2 |
3 files changed, 15 insertions, 11 deletions
diff --git a/html_backend.go b/html_backend.go index af8f05c..08d2775 100644 --- a/html_backend.go +++ b/html_backend.go @@ -635,10 +635,16 @@ func htmlWriteTableRow(doc *Document, table *adocTable, row *tableRow, out io.Wr _ = subdoc.ToEmbeddedHTML(out) case colStyleDefault: - fmt.Fprintf(out, "<p class=%q>", classNameTableBlock) - container := parseInlineMarkup(doc, contentTrimmed) - container.toHTML(doc, out, false) - fmt.Fprint(out, "</p>") + rawParagraphs := bytes.Split(contentTrimmed, []byte("\n\n")) + for x, p := range rawParagraphs { + if x > 0 { + fmt.Fprint(out, "\n") + } + fmt.Fprintf(out, "<p class=%q>", classNameTableBlock) + container := parseInlineMarkup(doc, p) + container.toHTML(doc, out, false) + fmt.Fprint(out, "</p>") + } case colStyleHeader, colStyleVerse: fmt.Fprintf(out, "<p class=%q>%s</p>", diff --git a/testdata/got.test.html b/testdata/got.test.html index dc122f9..9936f23 100644 --- a/testdata/got.test.html +++ b/testdata/got.test.html @@ -1349,11 +1349,9 @@ D</p></td> </thead> <tbody> <tr> -<td class="tableblock halign-left valign-top"><p class="tableblock">C - -D - -E</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">C</p> +<p class="tableblock">D</p> +<p class="tableblock">E</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">F</p></td> </tr> </tbody> @@ -2409,7 +2407,7 @@ this sidebar.</p> <div id="footer"> <div id="footer-text"> 1.1.1<br> -Last updated 2020-12-04 03:18:39 +0700 +Last updated 2020-12-04 03:43:33 +0700 </div> </div> </body> diff --git a/testdata/test.html b/testdata/test.html index 815b178..2e3fa31 100644 --- a/testdata/test.html +++ b/testdata/test.html @@ -2404,7 +2404,7 @@ this sidebar.</p> <div id="footer"> <div id="footer-text"> 1.1.1<br> -Last updated 2020-12-04 03:18:34 +0700 +Last updated 2020-12-04 03:43:33 +0700 </div> </div> </body> |
