mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-02 21:32:34 +00:00
drop attachment:// proto, improve docs
Removed attachment:// proto from docs, back compatibility is saved. Now using the implementatin of `Attachment:` provided by @csoutherland. Removed a bunch of swear stuff from docs, oh boy I was so frustrated at that time.
This commit is contained in:
@@ -186,16 +186,40 @@ func CompileAttachmentLinks(markdown []byte, attaches []Attachment) []byte {
|
||||
})
|
||||
|
||||
for _, replace := range replaces {
|
||||
from := replace
|
||||
to := links[replace]
|
||||
|
||||
log.Debugf(nil, "replacing: %q -> %q", from, to)
|
||||
found := false
|
||||
if bytes.Contains(markdown, []byte("attachment://"+replace)) {
|
||||
from := "attachment://" + replace
|
||||
|
||||
markdown = bytes.ReplaceAll(
|
||||
markdown,
|
||||
[]byte(from),
|
||||
[]byte(to),
|
||||
)
|
||||
log.Debugf(nil, "replacing legacy link: %q -> %q", from, to)
|
||||
|
||||
markdown = bytes.ReplaceAll(
|
||||
markdown,
|
||||
[]byte(from),
|
||||
[]byte(to),
|
||||
)
|
||||
|
||||
found = true
|
||||
}
|
||||
|
||||
if bytes.Contains(markdown, []byte(replace)) {
|
||||
from := replace
|
||||
|
||||
log.Debugf(nil, "replacing link: %q -> %q", from, to)
|
||||
|
||||
markdown = bytes.ReplaceAll(
|
||||
markdown,
|
||||
[]byte(from),
|
||||
[]byte(to),
|
||||
)
|
||||
|
||||
found = true
|
||||
}
|
||||
|
||||
if !found {
|
||||
log.Warningf(nil, "unused attachment: %s", replace)
|
||||
}
|
||||
}
|
||||
|
||||
return markdown
|
||||
|
||||
@@ -11,12 +11,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
HeaderParent = `Parent`
|
||||
HeaderSpace = `Space`
|
||||
HeaderTitle = `Title`
|
||||
HeaderLayout = `Layout`
|
||||
HeaderAttachment = `Attachment`
|
||||
HeaderExactAttachment = `ExactAttachment`
|
||||
HeaderParent = `Parent`
|
||||
HeaderSpace = `Space`
|
||||
HeaderTitle = `Title`
|
||||
HeaderLayout = `Layout`
|
||||
HeaderAttachment = `Attachment`
|
||||
)
|
||||
|
||||
type Meta struct {
|
||||
@@ -89,9 +88,6 @@ func ExtractMeta(data []byte) (*Meta, []byte, error) {
|
||||
meta.Layout = strings.TrimSpace(value)
|
||||
|
||||
case HeaderAttachment:
|
||||
meta.Attachments["attachment://"+value] = value
|
||||
|
||||
case HeaderExactAttachment:
|
||||
meta.Attachments[value] = value
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user