Merge pull request #102 from FikriRNurhidayat/master
trim leading newline char on blocks for html
This commit is contained in:
commit
6eb20dbda9
5 changed files with 34 additions and 1 deletions
|
@ -622,7 +622,8 @@ func (w *HTMLWriter) blockContent(name string, children []Node) string {
|
|||
WriteNodes(w, children...)
|
||||
out := w.String()
|
||||
w.Builder, w.htmlEscape = builder, htmlEscape
|
||||
return strings.TrimRightFunc(out, unicode.IsSpace)
|
||||
|
||||
return strings.TrimRightFunc(strings.TrimLeftFunc(out, IsNewLineChar), unicode.IsSpace)
|
||||
} else {
|
||||
return w.WriteNodesAsString(children...)
|
||||
}
|
||||
|
|
10
org/testdata/blocks.html
vendored
10
org/testdata/blocks.html
vendored
|
@ -22,6 +22,16 @@ block caption
|
|||
<div class="src src-text">
|
||||
<div class="highlight">
|
||||
<pre>
|
||||
a source block with leading newline, trailing newline characters
|
||||
and a line started
|
||||
with leading space
|
||||
and line leading tab.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="src src-text">
|
||||
<div class="highlight">
|
||||
<pre>
|
||||
a source block without a language
|
||||
</pre>
|
||||
</div>
|
||||
|
|
9
org/testdata/blocks.org
vendored
9
org/testdata/blocks.org
vendored
|
@ -12,6 +12,15 @@ function hello {
|
|||
hello
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC
|
||||
|
||||
a source block with leading newline, trailing newline characters
|
||||
and a line started
|
||||
with leading space
|
||||
and line leading tab.
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC
|
||||
a source block without a language
|
||||
#+END_SRC
|
||||
|
|
9
org/testdata/blocks.pretty_org
vendored
9
org/testdata/blocks.pretty_org
vendored
|
@ -12,6 +12,15 @@ function hello {
|
|||
hello
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC
|
||||
|
||||
a source block with leading newline, trailing newline characters
|
||||
and a line started
|
||||
with leading space
|
||||
and line leading tab.
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC
|
||||
a source block without a language
|
||||
#+END_SRC
|
||||
|
|
|
@ -68,3 +68,7 @@ func ParseRanges(s string) [][2]int {
|
|||
}
|
||||
return ranges
|
||||
}
|
||||
|
||||
func IsNewLineChar(r rune) bool {
|
||||
return r == '\n' || r == '\r'
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue