Skip to content

Commit 291bf49

Browse files
committed
fix warnings about newlines in keys
1 parent 5c0c9cd commit 291bf49

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

test/pages/infobox-test.page

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ infobox [United States of America] {
33
Capital: [! Washington, DC !];
44
Largest city: [! New York City !];
55

6-
[Goverment] {
6+
[Government] {
77
:[! Federal presidential constitutional republic | Republic !];
88
President: [! Donald Trump !];
99
Vice President: [! Mike Pence !];

wikifier/block-map.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (m *Map) parse(page *Page) {
143143

144144
}
145145

146-
func (m *Map) handleChar(page *Page, i int, p *mapParser, c rune) {
146+
func (m *Map) handleChar(_ *Page, i int, p *mapParser, c rune) {
147147
p.pos.Column = i
148148

149149
if c == ':' && !p.inValue && !p.escape {
@@ -288,7 +288,11 @@ func (m *Map) handleChar(page *Page, i int, p *mapParser, c rune) {
288288
// this is part of the key
289289

290290
// starting a new key
291-
if p.key == nil && add != "\n" {
291+
if p.key == nil {
292+
if strings.TrimSpace(add) == "" {
293+
// ignore whitespace at the start of keys
294+
return
295+
}
292296
p.startPos = p.pos
293297
p.key = add
294298
return

0 commit comments

Comments
 (0)