@@ -46,6 +46,7 @@ type GHDoc struct {
46
46
httpGetter httpGetter
47
47
httpPoster httpPoster
48
48
ghURL string
49
+ reVersion string
49
50
}
50
51
51
52
// NewGHDoc create GHDoc
@@ -64,6 +65,7 @@ func NewGHDoc(Path string, AbsPaths bool, StartDepth int, Depth int, Escape bool
64
65
httpGetter : internal .HttpGet ,
65
66
httpPoster : internal .HttpPost ,
66
67
ghURL : "https://api.github.com" ,
68
+ reVersion : "0" ,
67
69
}
68
70
}
69
71
@@ -81,6 +83,12 @@ func (doc *GHDoc) SetGHURL(url string) *GHDoc {
81
83
return doc
82
84
}
83
85
86
+ // SetReVersion sets reg exp version
87
+ func (doc * GHDoc ) SetReVersion (v string ) * GHDoc {
88
+ doc .reVersion = v
89
+ return doc
90
+ }
91
+
84
92
// IsRemoteFile checks if path is for remote file or not
85
93
func (doc * GHDoc ) IsRemoteFile () bool {
86
94
u , err := url .Parse (doc .Path )
@@ -160,16 +168,18 @@ func (doc *GHDoc) GrabToc() *GHToc {
160
168
// si:
161
169
// - s - let . match \n (single-line mode)
162
170
// - i - case-insensitive
163
- // re := `(?si)<h(?P<num>[1-6]) id="[^"]+">\s*` +
164
- // `<a class="heading-link"\s*` +
165
- // `href="(?P<href>[^"]+)">\s*` +
166
- // `(?P<name>.*?)<span`
167
- re := `(?si)<h(?P<num>[1-6])>\s*` +
168
- `<a\s*id="user-content-[^"]*"\s*class="anchor"\s*` +
169
- `(aria-hidden="[^"]*"\s*)?` +
170
- `(tabindex="[^"]*"\s*)?` +
171
- `href="(?P<href>[^"]*)"[^>]*>\s*` +
172
- `.*?</a>(?P<name>.*?)</h`
171
+ re := `(?si)<h(?P<num>[1-6]) id="[^"]+">\s*` +
172
+ `<a class="heading-link"\s*` +
173
+ `href="(?P<href>[^"]+)">\s*` +
174
+ `(?P<name>.*?)<span`
175
+ if doc .reVersion == "0" {
176
+ re = `(?si)<h(?P<num>[1-6])>\s*` +
177
+ `<a\s*id="user-content-[^"]*"\s*class="anchor"\s*` +
178
+ `(aria-hidden="[^"]*"\s*)?` +
179
+ `(tabindex="[^"]*"\s*)?` +
180
+ `href="(?P<href>[^"]*)"[^>]*>\s*` +
181
+ `.*?</a>(?P<name>.*?)</h`
182
+ }
173
183
r := regexp .MustCompile (re )
174
184
listIndentation := internal .GenerateListIndentation (doc .Indent )
175
185
0 commit comments