Skip to content

Commit 479e16d

Browse files
committed
hand-crafted anchor links are now properly handled
Before, a link that was intended to refer to an existing anchor in the document, such as: [see the above section](#docker-vs-local) was translated into: [see the above section](#see-the-above-section) I added a goldmark parsing of the page so that we can retrieve the headings and do a proper mapping between the Hugo anchors and the Devto anchors. The above example should now look like this: [see the above section](#docker-vs-local) Also, if an anchor isn't found in the document, you will be warned.
1 parent 8c008e9 commit 479e16d

File tree

5 files changed

+117
-636
lines changed

5 files changed

+117
-636
lines changed

diff.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ func buildDiffLines(lString, rString string) []lineRecord {
138138
results = append(results, lineRecord{Type: diffmatchpatch.DiffEqual, Line: lines[0]})
139139
}
140140
if len(lines) > 1 {
141-
if r != "" {
142-
results = append(results, lineRecord{Type: diffmatchpatch.DiffInsert, Line: r})
143-
r = ""
144-
}
145-
146141
if l != "" {
147142
results = append(results, lineRecord{Type: diffmatchpatch.DiffDelete, Line: l})
148143
l = ""
149144
}
145+
146+
if r != "" {
147+
results = append(results, lineRecord{Type: diffmatchpatch.DiffInsert, Line: r})
148+
r = ""
149+
}
150150
}
151151
}
152152
for i := 1; i < len(lines)-1; i++ {

go.mod

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ go 1.17
55
require (
66
github.com/MakeNowJust/heredoc v1.0.0
77
github.com/VictorAvelar/devto-api-go v1.0.0
8+
github.com/davecgh/go-spew v1.1.1
89
github.com/gohugoio/hugo v0.110.0
910
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
1011
github.com/sergi/go-diff v1.3.1
1112
github.com/sethgrid/gencurl v0.0.0-20161025011400-a3af93c1aba4
1213
github.com/spf13/jwalterweatherman v1.1.0
13-
github.com/spf13/viper v1.15.0
1414
github.com/stretchr/testify v1.8.1
1515
golang.org/x/crypto v0.6.0
1616
)
@@ -32,7 +32,6 @@ require (
3232
github.com/bep/tmc v0.5.1 // indirect
3333
github.com/clbanning/mxj/v2 v2.5.7 // indirect
3434
github.com/cli/safeexec v1.0.1 // indirect
35-
github.com/davecgh/go-spew v1.1.1 // indirect
3635
github.com/disintegration/gift v1.2.1 // indirect
3736
github.com/dlclark/regexp2 v1.8.0 // indirect
3837
github.com/evanw/esbuild v0.17.8 // indirect
@@ -50,14 +49,12 @@ require (
5049
github.com/google/go-cmp v0.5.9 // indirect
5150
github.com/google/go-querystring v1.1.0 // indirect
5251
github.com/hairyhenderson/go-codeowners v0.3.0 // indirect
53-
github.com/hashicorp/hcl v1.0.0 // indirect
5452
github.com/invopop/yaml v0.2.0 // indirect
5553
github.com/jdkato/prose v1.2.1 // indirect
5654
github.com/josharian/intern v1.0.0 // indirect
5755
github.com/kr/pretty v0.3.1 // indirect
5856
github.com/kr/text v0.2.0 // indirect
5957
github.com/kyokomi/emoji/v2 v2.2.12 // indirect
60-
github.com/magiconair/properties v1.8.7 // indirect
6158
github.com/mailru/easyjson v0.7.7 // indirect
6259
github.com/marekm4/color-extractor v1.2.0 // indirect
6360
github.com/mattn/go-colorable v0.1.13 // indirect
@@ -76,10 +73,10 @@ require (
7673
github.com/rogpeppe/go-internal v1.9.0 // indirect
7774
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd // indirect
7875
github.com/sanity-io/litter v1.5.5 // indirect
76+
github.com/schollz/closestmatch v2.1.0+incompatible
7977
github.com/spf13/afero v1.9.3 // indirect
8078
github.com/spf13/cast v1.5.0 // indirect
8179
github.com/spf13/pflag v1.0.5 // indirect
82-
github.com/subosito/gotenv v1.4.2 // indirect
8380
github.com/tdewolff/minify/v2 v2.12.4 // indirect
8481
github.com/tdewolff/parse/v2 v2.6.5 // indirect
8582
github.com/yuin/goldmark v1.5.4 // indirect
@@ -92,7 +89,6 @@ require (
9289
golang.org/x/text v0.7.0 // indirect
9390
golang.org/x/tools v0.6.0 // indirect
9491
google.golang.org/protobuf v1.28.1 // indirect
95-
gopkg.in/ini.v1 v1.67.0 // indirect
9692
gopkg.in/yaml.v2 v2.4.0 // indirect
9793
gopkg.in/yaml.v3 v3.0.1 // indirect
9894
)

0 commit comments

Comments
 (0)