From cddec57102772a6b774a0467a2947e2316f4e44a Mon Sep 17 00:00:00 2001 From: joseph Date: Mon, 6 Sep 2021 11:43:20 -0700 Subject: [PATCH] Allow whitespace inside bare idents. Web of Science exported bibtex does this. --- scanner.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scanner.go b/scanner.go index 435372b..78f47bd 100644 --- a/scanner.go +++ b/scanner.go @@ -108,16 +108,23 @@ func (s *scanner) scanIdent() (tok token, lit string) { func (s *scanner) scanBare() (token, string) { var buf bytes.Buffer + var trailingWhitespace int for { if ch := s.read(); ch == eof { break - } else if !isAlphanum(ch) && !isBareSymbol(ch) || isWhitespace(ch) { + } else if !isAlphanum(ch) && !isBareSymbol(ch) && !isWhitespace(ch) { s.unread() break } else { + if isWhitespace(ch) { + trailingWhitespace += 1 + } else { + trailingWhitespace = 0 + } _, _ = buf.WriteRune(ch) } } + buf.Truncate(buf.Len() - trailingWhitespace) str := buf.String() if strings.ToLower(str) == "comment" { return tCOMMENT, str