mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 11:46:16 +00:00
Fix icons being escaped in paragraphs
This commit is contained in:
parent
8ac27fc385
commit
df26dfe511
@ -143,8 +143,8 @@ numberState:
|
||||
launchpadState:
|
||||
switch {
|
||||
case startsWith("=>"):
|
||||
href, text, class := Rocketlink(line, state.name)
|
||||
state.buf += fmt.Sprintf(` <li class="launchpad__entry"><a class="rocketlink %s" href="%s">%s</a></li>`, class, href, text)
|
||||
href, text, class, icon := Rocketlink(line, state.name)
|
||||
state.buf += fmt.Sprintf(` <li class="launchpad__entry"><a class="rocketlink %s" href="%s">%s%s</a></li>`, class, href, text, icon)
|
||||
case startsWith("```"):
|
||||
state.where = "pre"
|
||||
addLine(state.buf + "</ul>")
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
//
|
||||
// => 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 == "" {
|
||||
text = addr
|
||||
} else {
|
||||
@ -26,9 +26,9 @@ func LinkParts(addr, display, hyphaName string) (href, text, class string) {
|
||||
if strings.HasPrefix(text, "//") && len(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, "/"):
|
||||
return addr, text, class
|
||||
return addr, text, class, ""
|
||||
case strings.HasPrefix(addr, "./"):
|
||||
hyphaName = canonicalName(path.Join(hyphaName, addr[2:]))
|
||||
case strings.HasPrefix(addr, "../"):
|
||||
@ -39,12 +39,12 @@ func LinkParts(addr, display, hyphaName string) (href, text, class string) {
|
||||
if !HyphaExists(hyphaName) {
|
||||
class += " wikilink_new"
|
||||
}
|
||||
return "/page/" + hyphaName, text, class
|
||||
return "/page/" + hyphaName, text, class, ""
|
||||
}
|
||||
|
||||
// Parse markup line starting with "=>" according to wikilink rules.
|
||||
// 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 =>
|
||||
if src == "" {
|
||||
return
|
||||
|
@ -56,8 +56,8 @@ func getLinkNode(input *bytes.Buffer, hyphaName string) string {
|
||||
currBuf.WriteByte(b)
|
||||
}
|
||||
}
|
||||
href, text, class := LinkParts(addrBuf.String(), displayBuf.String(), hyphaName)
|
||||
return fmt.Sprintf(`<a href="%s" class="%s">%s</a>`, href, class, html.EscapeString(text))
|
||||
href, text, class, icon := LinkParts(addrBuf.String(), displayBuf.String(), hyphaName)
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user