|
|
@ -216,7 +216,7 @@ func parseLinks(root ast.Node, source []byte) ([]note.Link, error) {
|
|
|
|
case *ast.Link:
|
|
|
|
case *ast.Link:
|
|
|
|
href := string(link.Destination)
|
|
|
|
href := string(link.Destination)
|
|
|
|
if href != "" {
|
|
|
|
if href != "" {
|
|
|
|
snippet, snStart, snEnd := extractLines(n.Parent(), source)
|
|
|
|
snippet, snStart, snEnd := extractLines(n, source)
|
|
|
|
links = append(links, note.Link{
|
|
|
|
links = append(links, note.Link{
|
|
|
|
Title: string(link.Text(source)),
|
|
|
|
Title: string(link.Text(source)),
|
|
|
|
Href: href,
|
|
|
|
Href: href,
|
|
|
@ -230,7 +230,7 @@ func parseLinks(root ast.Node, source []byte) ([]note.Link, error) {
|
|
|
|
|
|
|
|
|
|
|
|
case *ast.AutoLink:
|
|
|
|
case *ast.AutoLink:
|
|
|
|
if href := string(link.URL(source)); href != "" && link.AutoLinkType == ast.AutoLinkURL {
|
|
|
|
if href := string(link.URL(source)); href != "" && link.AutoLinkType == ast.AutoLinkURL {
|
|
|
|
snippet, snStart, snEnd := extractLines(n.Parent(), source)
|
|
|
|
snippet, snStart, snEnd := extractLines(n, source)
|
|
|
|
links = append(links, note.Link{
|
|
|
|
links = append(links, note.Link{
|
|
|
|
Title: string(link.Label(source)),
|
|
|
|
Title: string(link.Label(source)),
|
|
|
|
Href: href,
|
|
|
|
Href: href,
|
|
|
@ -252,6 +252,11 @@ func extractLines(n ast.Node, source []byte) (content string, start, end int) {
|
|
|
|
if n == nil {
|
|
|
|
if n == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch n.Type() {
|
|
|
|
|
|
|
|
case ast.TypeInline:
|
|
|
|
|
|
|
|
return extractLines(n.Parent(), source)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ast.TypeBlock:
|
|
|
|
segs := n.Lines()
|
|
|
|
segs := n.Lines()
|
|
|
|
if segs.Len() == 0 {
|
|
|
|
if segs.Len() == 0 {
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -259,6 +264,8 @@ func extractLines(n ast.Node, source []byte) (content string, start, end int) {
|
|
|
|
start = segs.At(0).Start
|
|
|
|
start = segs.At(0).Start
|
|
|
|
end = segs.At(segs.Len() - 1).Stop
|
|
|
|
end = segs.At(segs.Len() - 1).Stop
|
|
|
|
content = string(source[start:end])
|
|
|
|
content = string(source[start:end])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|