mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-10-31 23:53:01 +00:00
Migrate to mycomarkup/links module
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/link"
|
||||
"github.com/bouncepaw/mycomarkup/links"
|
||||
)
|
||||
|
||||
var imgRe = regexp.MustCompile(`^img\s+{`)
|
||||
@@ -33,8 +33,8 @@ type Img struct {
|
||||
|
||||
func (img *Img) pushEntry() {
|
||||
if strings.TrimSpace(img.currEntry.path.String()) != "" {
|
||||
img.currEntry.srclink = link.From(img.currEntry.path.String(), "", img.hyphaName)
|
||||
img.currEntry.srclink.DoubtExistence()
|
||||
img.currEntry.srclink = links.From(img.currEntry.path.String(), "", img.hyphaName)
|
||||
// img.currEntry.srclink.DoubtExistence()
|
||||
img.entries = append(img.entries, img.currEntry)
|
||||
img.currEntry = imgEntry{}
|
||||
img.currEntry.path.Reset()
|
||||
@@ -164,7 +164,7 @@ func parseDimensions(dimensions string) (sizeW, sizeH string) {
|
||||
func (img *Img) markExistenceOfSrcLinks() {
|
||||
HyphaIterate(func(hn string) {
|
||||
for _, entry := range img.entries {
|
||||
if hn == entry.srclink.Address {
|
||||
if hn == entry.srclink.Address() {
|
||||
entry.srclink.DestinationUnknown = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package markup
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/link"
|
||||
"github.com/bouncepaw/mycomarkup/links"
|
||||
)
|
||||
|
||||
type imgEntry struct {
|
||||
srclink *link.Link
|
||||
srclink *links.Link
|
||||
path strings.Builder
|
||||
sizeW strings.Builder
|
||||
sizeH strings.Builder
|
||||
|
||||
@@ -3,7 +3,7 @@ package markup
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/link"
|
||||
"github.com/bouncepaw/mycomarkup/links"
|
||||
)
|
||||
|
||||
// LinkParts determines what href, text and class should resulting <a> have based on mycomarkup's addr, display and hypha name.
|
||||
@@ -12,11 +12,11 @@ import (
|
||||
// [[addr|display]]
|
||||
// TODO: deprecate
|
||||
func LinkParts(addr, display, hyphaName string) (href, text, class string) {
|
||||
l := link.From(addr, display, hyphaName)
|
||||
if l.Kind == link.LinkLocalHypha && !HyphaExists(l.Address) {
|
||||
l := links.From(addr, display, hyphaName)
|
||||
if l.OfKind(links.LinkLocalHypha) && !HyphaExists(l.Address()) {
|
||||
l.DestinationUnknown = true
|
||||
}
|
||||
return l.Href(), l.Display, l.Classes()
|
||||
return l.Href(), l.Display(), l.Classes()
|
||||
}
|
||||
|
||||
// Parse markup line starting with "=>" according to wikilink rules.
|
||||
|
||||
@@ -3,12 +3,13 @@ package markup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"html"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/link"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
|
||||
"github.com/bouncepaw/mycomarkup/links"
|
||||
)
|
||||
|
||||
// A Mycomarkup-formatted document
|
||||
@@ -83,7 +84,7 @@ func (md *MycoDoc) ogFillVars() *MycoDoc {
|
||||
case Img:
|
||||
if !foundImg && len(v.entries) > 0 {
|
||||
md.firstImageURL = v.entries[0].srclink.ImgSrc()
|
||||
if v.entries[0].srclink.Kind != link.LinkExternal {
|
||||
if !v.entries[0].srclink.OfKind(links.LinkExternal) {
|
||||
md.firstImageURL = cfg.URL + md.firstImageURL
|
||||
}
|
||||
foundImg = true
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/link"
|
||||
"github.com/bouncepaw/mycomarkup/links"
|
||||
)
|
||||
|
||||
// OutLinks returns a channel of names of hyphae this mycodocument links.
|
||||
@@ -50,8 +50,8 @@ func extractLinks(html string, ch chan string) {
|
||||
|
||||
func extractImageLinks(img Img, ch chan string) {
|
||||
for _, entry := range img.entries {
|
||||
if entry.srclink.Kind == link.LinkLocalHypha {
|
||||
ch <- entry.srclink.Address
|
||||
if entry.srclink.OfKind(links.LinkLocalHypha) {
|
||||
ch <- entry.srclink.Address()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
// "github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
var tableRe = regexp.MustCompile(`^table\s+{`)
|
||||
|
||||
Reference in New Issue
Block a user