mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-13 05:50:27 +00:00
Fix icons being escaped in paragraphs
This commit is contained in:
parent
8ac27fc385
commit
df26dfe511
@ -143,8 +143,8 @@ numberState:
|
|||||||
launchpadState:
|
launchpadState:
|
||||||
switch {
|
switch {
|
||||||
case startsWith("=>"):
|
case startsWith("=>"):
|
||||||
href, text, class := Rocketlink(line, state.name)
|
href, text, class, icon := Rocketlink(line, state.name)
|
||||||
state.buf += fmt.Sprintf(` <li class="launchpad__entry"><a class="rocketlink %s" href="%s">%s</a></li>`, class, href, text)
|
state.buf += fmt.Sprintf(` <li class="launchpad__entry"><a class="rocketlink %s" href="%s">%s%s</a></li>`, class, href, text, icon)
|
||||||
case startsWith("```"):
|
case startsWith("```"):
|
||||||
state.where = "pre"
|
state.where = "pre"
|
||||||
addLine(state.buf + "</ul>")
|
addLine(state.buf + "</ul>")
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
//
|
//
|
||||||
// => addr display
|
// => addr display
|
||||||
// [[addr|display]]
|
// [[addr|display]]
|
||||||
func LinkParts(addr, display, hyphaName string) (href, text, class string) {
|
func LinkParts(addr, display, hyphaName string) (href, text, class, icon string) {
|
||||||
if display == "" {
|
if display == "" {
|
||||||
text = addr
|
text = addr
|
||||||
} else {
|
} else {
|
||||||
@ -26,9 +26,9 @@ func LinkParts(addr, display, hyphaName string) (href, text, class string) {
|
|||||||
if strings.HasPrefix(text, "//") && len(text) > 2 {
|
if strings.HasPrefix(text, "//") && len(text) > 2 {
|
||||||
text = text[2:]
|
text = text[2:]
|
||||||
}
|
}
|
||||||
return addr, text + fmt.Sprintf(`<img class="wikilink__destination-type" src="/static/icon/%s" width="16" height="16"/>`, destination), "wikilink_external"
|
return addr, text, "wikilink_external", fmt.Sprintf(`<img class="wikilink__destination-type" src="/static/icon/%s" width="16" height="16"/>`, destination)
|
||||||
case strings.HasPrefix(addr, "/"):
|
case strings.HasPrefix(addr, "/"):
|
||||||
return addr, text, class
|
return addr, text, class, ""
|
||||||
case strings.HasPrefix(addr, "./"):
|
case strings.HasPrefix(addr, "./"):
|
||||||
hyphaName = canonicalName(path.Join(hyphaName, addr[2:]))
|
hyphaName = canonicalName(path.Join(hyphaName, addr[2:]))
|
||||||
case strings.HasPrefix(addr, "../"):
|
case strings.HasPrefix(addr, "../"):
|
||||||
@ -39,12 +39,12 @@ func LinkParts(addr, display, hyphaName string) (href, text, class string) {
|
|||||||
if !HyphaExists(hyphaName) {
|
if !HyphaExists(hyphaName) {
|
||||||
class += " wikilink_new"
|
class += " wikilink_new"
|
||||||
}
|
}
|
||||||
return "/page/" + hyphaName, text, class
|
return "/page/" + hyphaName, text, class, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse markup line starting with "=>" according to wikilink rules.
|
// Parse markup line starting with "=>" according to wikilink rules.
|
||||||
// See http://localhost:1737/page/wikilink
|
// See http://localhost:1737/page/wikilink
|
||||||
func Rocketlink(src, hyphaName string) (href, text, class string) {
|
func Rocketlink(src, hyphaName string) (href, text, class, icon string) {
|
||||||
src = strings.TrimSpace(src[2:]) // Drop =>
|
src = strings.TrimSpace(src[2:]) // Drop =>
|
||||||
if src == "" {
|
if src == "" {
|
||||||
return
|
return
|
||||||
|
@ -56,8 +56,8 @@ func getLinkNode(input *bytes.Buffer, hyphaName string) string {
|
|||||||
currBuf.WriteByte(b)
|
currBuf.WriteByte(b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
href, text, class := LinkParts(addrBuf.String(), displayBuf.String(), hyphaName)
|
href, text, class, icon := LinkParts(addrBuf.String(), displayBuf.String(), hyphaName)
|
||||||
return fmt.Sprintf(`<a href="%s" class="%s">%s</a>`, href, class, html.EscapeString(text))
|
return fmt.Sprintf(`<a href="%s" class="%s">%s%s</a>`, href, class, html.EscapeString(text), icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTextNode splits the `input` into two parts `textNode` and `rest` by the first encountered rune that resembles a span tag. If there is none, `textNode = input`, `rest = ""`. It handles escaping with backslash.
|
// getTextNode splits the `input` into two parts `textNode` and `rest` by the first encountered rune that resembles a span tag. If there is none, `textNode = input`, `rest = ""`. It handles escaping with backslash.
|
||||||
|
Loading…
Reference in New Issue
Block a user