Fix default HighlightCodeBlock fn: Write tags on separate lines

This commit is contained in:
Niklas Fasching 2018-12-11 17:29:26 +01:00
parent 486720c1b1
commit a859264420
5 changed files with 17 additions and 7 deletions

View file

@ -34,7 +34,7 @@ var listTags = map[string][]string{
func NewHTMLWriter() *HTMLWriter {
return &HTMLWriter{
HighlightCodeBlock: func(source, lang string) string {
return fmt.Sprintf(`<div class="highlight">%s<pre>%s</pre>%s</div>`, "\n", html.EscapeString(source), "\n")
return fmt.Sprintf("%s\n<pre>\n%s\n</pre>\n</div>", `<div class="highlight">`, html.EscapeString(source))
},
}
}

View file

@ -1,19 +1,23 @@
<div class="captioned">
<div class="highlight">
<pre>echo &#34;a bash source block&#34;
<pre>
echo &#34;a bash source block&#34;
function hello {
echo Hello World!
}
hello</pre>
hello
</pre>
</div>
<p class="caption">
block caption
</p>
</div>
<div class="highlight">
<pre>a source block without a language</pre>
<pre>
a source block without a language
</pre>
</div>
<pre class="example">
an example block with

View file

@ -3,7 +3,9 @@ Anything can be captioned. Also captions are not real, correct captions but just
</p>
<div class="captioned">
<div class="highlight">
<pre>echo &#34;i have a caption!&#34;</pre>
<pre>
echo &#34;i have a caption!&#34;
</pre>
</div>
<p class="caption">
captioned soure block

View file

@ -41,7 +41,9 @@ and other elements
like blocks
</p>
<div class="highlight">
<pre>other non-plain</pre>
<pre>
other non-plain
</pre>
</div>
</li>
<li>

View file

@ -49,7 +49,9 @@ and some lines of text
and another subitem
</p>
<div class="highlight">
<pre>echo with a block</pre>
<pre>
echo with a block
</pre>
</div>
</li>
<li>