diff options
Diffstat (limited to 'parser_inline.go')
| -rw-r--r-- | parser_inline.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/parser_inline.go b/parser_inline.go index 293c176..b37d84f 100644 --- a/parser_inline.go +++ b/parser_inline.go @@ -34,7 +34,7 @@ func newParserInline(doc *Document, content []byte) (pi *parserInline) { container: &adocNode{ kind: nodeKindText, }, - content: bytes.TrimRight(content, "\n"), + content: content, doc: doc, state: &parserInlineState{}, } @@ -83,6 +83,13 @@ func (pi *parserInline) do() { continue } } + if pi.prev == ' ' && pi.nextc == '\n' { + pi.current.backTrimSpace() + pi.current.WriteString("<br>\n") + pi.x += 2 + pi.prev = 0 + continue + } if pi.parsePassthrough() { continue } @@ -361,6 +368,12 @@ func (pi *parserInline) do() { pi.prev = pi.c } + // Remove any trailing spaces only if the node is not passthrough. + if !(pi.current.kind == nodeKindPassthrough || + pi.current.kind == nodeKindPassthroughDouble || + pi.current.kind == nodeKindPassthroughTriple) { + pi.current.backTrimSpace() + } pi.container.removeLastIfEmpty() } @@ -465,6 +478,7 @@ func (pi *parserInline) parseInlineID() bool { ID: id, kind: nodeKindInlineID, } + pi.current.backTrimSpace() pi.current.addChild(node) node = &adocNode{ kind: nodeKindText, @@ -506,6 +520,7 @@ func (pi *parserInline) parseInlineIDShort() bool { kind: nodeKindInlineIDShort, } pi.state.push(nodeKindInlineIDShort) + pi.current.backTrimSpace() pi.current.addChild(node) pi.current = node pi.x += 2 + len(id) + 2 |
