Skip to content

Commit

Permalink
feat: Trim whitespace from title
Browse files Browse the repository at this point in the history
  • Loading branch information
13rac1 committed Dec 14, 2020
1 parent e5fc6bc commit 0fe690c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wikilink.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wikilink
import (
"fmt"
"net/url"
"strings"

"github.com/yuin/goldmark"
"github.com/yuin/goldmark/ast"
Expand Down Expand Up @@ -80,12 +81,13 @@ func (p *wikilinksParser) Parse(parent ast.Node, block text.Reader, pc parser.Co

// extract the text of the wikilink and normalize it to figure out the destination
destination := block.Value(text.NewSegment(segment.Start+2, segment.Start+pos-1))
destFilename := p.normalizer.Normalize(string(destination))
destString := strings.TrimSpace(string(destination))
destFilename := p.normalizer.Normalize(destString)

block.Advance(pos + 1)

link := ast.NewLink()
link.Title = destination
link.Title = []byte(destString)
link.Destination = []byte(destFilename)
wl := NewWikilink(link)
return wl
Expand Down
6 changes: 6 additions & 0 deletions wikilinks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ get the _full set_ of text in my tracker.
also has a <a href="Wiki%20Link.html">Wiki Link</a> in the middle of it, but I should
get the <em>full set</em> of text in my tracker.</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
8
//- - - - - - - - -//
[[ Extra Spaces ]]
//- - - - - - - - -//
<p><a href="Extra%20Spaces.html">Extra Spaces</a></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

0 comments on commit 0fe690c

Please sign in to comment.