From 4bc6d7cedac3c9b49973f20fbf0a71bbf1116a4e Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Sun, 25 Jun 2023 09:26:04 -0400 Subject: [PATCH] Not much better --- lexer.go | 5 +++-- states.go | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lexer.go b/lexer.go index 327c354..012259a 100644 --- a/lexer.go +++ b/lexer.go @@ -152,7 +152,8 @@ func (i Item) String() string { } if len(i.Val) > 10 { - return fmt.Sprintf("%s:%.10q...", i.Typ, i.Val) + // return fmt.Sprintf("%s:%.10q...", i.Typ, i.Val) + return fmt.Sprintf("%s:%q", i.Typ, i.Val) } - return fmt.Sprintf("%s:%q...", i.Typ, i.Val) + return fmt.Sprintf("%s:%q", i.Typ, i.Val) } diff --git a/states.go b/states.go index 4f5584f..c8938b5 100644 --- a/states.go +++ b/states.go @@ -3,6 +3,7 @@ package wikilink import ( "log" "strings" + "unicode" ) func lexFragment(l *Lexer) stateFn { @@ -27,14 +28,28 @@ func lexFragment(l *Lexer) stateFn { func lexAlias(l *Lexer) stateFn { // l.accept log.Println("entering lexAlias") - if strings.HasPrefix(l.input[l.pos:], CloseLink) { - return lexCloseLink + for { + if strings.HasPrefix(l.input[l.pos:], CloseLink) { + return lexCloseLink + } + r := l.next() + } l.emit(ItemAlias) return lexInsideLink } +func lexIdent(l *Lexer) stateFn { + for { + if strings.HasPrefix(l.input[l.pos:], CloseLink) { + return lexCloseLink + } + // r := l.next() + } + return lexInsideLink +} + func lexInsideLink(l *Lexer) stateFn { log.Println("entering lexInsideLink")