mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-10-31 23:53:01 +00:00
Add anchor links
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"html"
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
// HyphaExists holds function that checks that a hypha is present.
|
||||
@@ -83,7 +85,8 @@ func lineToAST(line string, state *GemLexerState, ast *[]Line) {
|
||||
return strings.HasPrefix(line, token)
|
||||
}
|
||||
addHeading := func(i int) {
|
||||
addLine(fmt.Sprintf("<h%d id='%d'>%s</h%d>", i, state.id, ParagraphToHtml(state.name, line[i+1:]), i))
|
||||
id := util.LettersNumbersOnly(line[i+1:])
|
||||
addLine(fmt.Sprintf(`<h%d id='%d'>%s<a href="#%s" id="%s" class="heading__link"></a></h%d>`, i, state.id, ParagraphToHtml(state.name, line[i+1:]), id, id, i))
|
||||
}
|
||||
|
||||
// Beware! Usage of goto. Some may say it is considered evil but in this case it helped to make a better-structured code.
|
||||
|
||||
Reference in New Issue
Block a user