Link meta key value
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2020-07-01 17:36:36 +02:00
parent 594f7ab96c
commit 4f6c87c14e
5 changed files with 19 additions and 2 deletions

View File

@ -4,8 +4,10 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"html/template" "html/template"
"log"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"strings" "strings"
) )
@ -111,6 +113,13 @@ func getBackrefs(fp *FilePages, p string) (map[string][]Backref, error) {
if line[0] == '*' && line[1] == ' ' { if line[0] == '*' && line[1] == ' ' {
line = line[2:] line = line[2:]
} }
metaKV, err := regexp.Compile(`(\w+)::\s+(.*)`)
if err != nil {
log.Fatal(err)
}
line = metaKV.ReplaceAllString(line, "**[[$1]]**: $2")
links := renderLinks(line) links := renderLinks(line)
pageText := renderMarkdown2(links) pageText := renderMarkdown2(links)

View File

@ -211,7 +211,7 @@ if (holder) {
converted = MD.render(converted) converted = MD.render(converted)
} else { } else {
if (text.match(/^(\w+):: (.+)$/)) { if (text.match(/^(\w+):: (.+)$/)) {
converted = converted.replace(/^(\w+):: (.*)$/, '**$1**: $2') converted = converted.replace(/^(\w+):: (.*)$/, '**[[$1]]**: $2')
} else if (text.match(/#\[\[TODO]]/)) { } else if (text.match(/#\[\[TODO]]/)) {
converted = converted.replace('#[[TODO]]', '<input class="checkbox" type="checkbox" />') converted = converted.replace('#[[TODO]]', '<input class="checkbox" type="checkbox" />')
} else if (text.match(/#\[\[DONE]]/)) { } else if (text.match(/#\[\[DONE]]/)) {

View File

@ -683,6 +683,12 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
if format == "html" { if format == "html" {
metaKV, err := regexp.Compile(`(\w+)::\s+(.*)`)
if err != nil {
log.Fatal(err)
}
pageText = metaKV.ReplaceAllString(pageText, "**[[$1]]**: $2")
pageText = renderLinks(pageText) pageText = renderLinks(pageText)
pageText = renderMarkdown2(pageText) pageText = renderMarkdown2(pageText)

View File

@ -27,6 +27,7 @@ func renderMarkdown2(pageText string) string {
html.WithUnsafe(), html.WithUnsafe(),
), ),
) )
var buf bytes.Buffer var buf bytes.Buffer
if err := md.Convert([]byte(pageText), &buf); err != nil { if err := md.Convert([]byte(pageText), &buf); err != nil {
panic(err) panic(err)

View File

@ -17,7 +17,8 @@
} }
#autocomplete { #autocomplete {
z-index: 1; z-index: 1;
width: 217px; right: 0;
width: 400px;
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
height: 300px; height: 300px;