mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-10-29 14:47:41 +00:00
Improve links visually
This commit is contained in:
@@ -59,6 +59,9 @@ func geminiLineToAST(line string, state *GemLexerState, ast *[]Line) {
|
||||
addLine(state.buf + "</ol>")
|
||||
case "pre":
|
||||
state.buf += "\n"
|
||||
case "launchpad":
|
||||
state.where = ""
|
||||
addLine(state.buf + "</ul>")
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -80,6 +83,8 @@ func geminiLineToAST(line string, state *GemLexerState, ast *[]Line) {
|
||||
goto listState
|
||||
case "number":
|
||||
goto numberState
|
||||
case "launchpad":
|
||||
goto launchpadState
|
||||
default:
|
||||
goto normalState
|
||||
}
|
||||
@@ -135,6 +140,23 @@ numberState:
|
||||
}
|
||||
return
|
||||
|
||||
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)
|
||||
case startsWith("```"):
|
||||
state.where = "pre"
|
||||
addLine(state.buf + "</ul>")
|
||||
state.id++
|
||||
state.buf = fmt.Sprintf("<pre id='%d' alt='%s' class='codeblock'><code>", state.id, strings.TrimPrefix(line, "```"))
|
||||
default:
|
||||
state.where = ""
|
||||
addLine(state.buf + "</ul>")
|
||||
goto normalState
|
||||
}
|
||||
return
|
||||
|
||||
normalState:
|
||||
state.id++
|
||||
switch {
|
||||
@@ -168,9 +190,9 @@ normalState:
|
||||
addLine(fmt.Sprintf(
|
||||
"<blockquote id='%d'>%s</blockquote>", state.id, remover(">")(line)))
|
||||
case startsWith("=>"):
|
||||
href, text, class := Rocketlink(line, state.name)
|
||||
addLine(fmt.Sprintf(
|
||||
`<p><a id='%d' class='rocketlink %s' href="%s">%s</a></p>`, state.id, class, href, text))
|
||||
state.where = "launchpad"
|
||||
state.buf = fmt.Sprintf("<ul class='launchpad' id='%d'>\n", state.id)
|
||||
goto launchpadState
|
||||
|
||||
case startsWith("<="):
|
||||
addLine(parseTransclusion(line, state.name))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package markup
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
@@ -19,7 +20,13 @@ func LinkParts(addr, display, hyphaName string) (href, text, class string) {
|
||||
|
||||
switch {
|
||||
case strings.ContainsRune(addr, ':'):
|
||||
return addr, text, "wikilink_external"
|
||||
pos := strings.IndexRune(addr, ':')
|
||||
destination := addr[:pos]
|
||||
text = addr[pos+1:]
|
||||
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"
|
||||
case strings.HasPrefix(addr, "/"):
|
||||
return addr, text, class
|
||||
case strings.HasPrefix(addr, "./"):
|
||||
|
||||
@@ -11,11 +11,6 @@ type MycoDoc struct {
|
||||
// data
|
||||
hyphaName string
|
||||
contents string
|
||||
|
||||
// state
|
||||
recursionDepth int
|
||||
|
||||
// results
|
||||
}
|
||||
|
||||
// Constructor
|
||||
@@ -27,10 +22,17 @@ func Doc(hyphaName, contents string) *MycoDoc {
|
||||
}
|
||||
|
||||
// AsHtml returns an html representation of the document
|
||||
func (md *MycoDoc) AsHtml() string {
|
||||
func (md *MycoDoc) AsHTML() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// OpenGraphHTML returns an html representation of og: meta tags.
|
||||
func (md *MycoDoc) OpenGraphHTML() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
/* The rest of this file is currently unused. TODO: use it I guess */
|
||||
|
||||
type BlockType int
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user