diff options
| author | Shulhan <ms@kilabit.info> | 2022-12-19 22:21:08 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-12-19 22:21:08 +0700 |
| commit | 56de5ca1d10d422ad33a550bdb4e358130a7ff3c (patch) | |
| tree | 4a6deacea408619a772f3f00a48bd997ee2ba4a1 | |
| parent | 2dd794265dfda767e12a009b26296acc121ca458 (diff) | |
| download | asciidoctor-go-56de5ca1d10d422ad33a550bdb4e358130a7ff3c.tar.xz | |
all: trim right spaces on each lines before parsing
This is to minimize checking for space when parsing later.
| -rw-r--r-- | document_parser.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/document_parser.go b/document_parser.go index 45b7597..e00dd81 100644 --- a/document_parser.go +++ b/document_parser.go @@ -26,6 +26,16 @@ func newDocumentParser(doc *Document, content []byte) (docp *documentParser) { content = bytes.ReplaceAll(content, []byte("\r\n"), []byte("\n")) docp.lines = bytes.Split(content, []byte("\n")) + var ( + wspaces = "\t\n\v\f\r \x85\xA0" + + line []byte + x int + ) + for x, line = range docp.lines { + docp.lines[x] = bytes.TrimRight(line, wspaces) + } + return docp } |
