Skip to content

Commit

Permalink
Allow whitespace inside bare idents. Web of Science exported bibtex d…
Browse files Browse the repository at this point in the history
…oes this.
  • Loading branch information
josephaltmaier committed Sep 6, 2021
1 parent b8612ca commit cddec57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cddec57

Please sign in to comment.