Support code fenced blocks
All checks were successful
continuous-integration/drone/push Build is passing

- Improve rendering of code fence html
- Add slash command "Code Block"
- Use editor version 0.6.6
This commit is contained in:
Peter Stuifzand 2020-06-01 01:57:23 +02:00
parent d51dfa09a9
commit b27332057f
5 changed files with 32 additions and 6 deletions

View File

@ -7548,9 +7548,9 @@
} }
}, },
"wiki-list-editor": { "wiki-list-editor": {
"version": "0.6.5", "version": "0.6.6",
"resolved": "https://registry.npmjs.org/wiki-list-editor/-/wiki-list-editor-0.6.5.tgz", "resolved": "https://registry.npmjs.org/wiki-list-editor/-/wiki-list-editor-0.6.6.tgz",
"integrity": "sha512-1/XQ7JSJoet/TCq5RiF0JAHFZYveI3fEW8drc6gPnAfwz4e2t7vHBZV5sDhFO+z4fD+uISfsBveW4oJzVNteNA==", "integrity": "sha512-9Kcpr/hKzMXlnb/gI9nMoE1OwXiWT4VpYvel0vjz++du8Z9wU+2qXIl3sWuFZl77stZpyrtKqV5BRhx63KN0RA==",
"requires": { "requires": {
"dragula": "^3.7.2", "dragula": "^3.7.2",
"jquery": "^3.5.1", "jquery": "^3.5.1",

View File

@ -20,7 +20,7 @@
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"sass-loader": "^7.3.1", "sass-loader": "^7.3.1",
"style-loader": "^1.0.0", "style-loader": "^1.0.0",
"wiki-list-editor": "^0.6.5" "wiki-list-editor": "^0.6.6"
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",

View File

@ -15,6 +15,7 @@ function createTitleSearch() {
{title: 'Yesterday', name: 'yesterday'}, {title: 'Yesterday', name: 'yesterday'},
{title: 'TODO', name: 'todo'}, {title: 'TODO', name: 'todo'},
{title: 'Page Reference', name: 'page_reference'}, {title: 'Page Reference', name: 'page_reference'},
{title: 'Code Block', name: 'code_block'},
]; ];
const fuseIndex = Fuse.createIndex(options.keys, documents) const fuseIndex = Fuse.createIndex(options.keys, documents)

View File

@ -184,6 +184,9 @@ if (holder) {
} else if (linkName === "Page Reference") { } else if (linkName === "Page Reference") {
commandResult = "[[]]" commandResult = "[[]]"
adjustment = -2 adjustment = -2
} else if (linkName === "Code Block") {
commandResult = "```\n\n```"
adjustment = -5
} }
let startAndLink = prefix let startAndLink = prefix

26
main.go
View File

@ -473,11 +473,33 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
pageText = "" builder := strings.Builder{}
for _, item := range listItems { for _, item := range listItems {
pageText += strings.Repeat(" ", item.Indented) + "* " + item.Text + "\n" lines := strings.Split(item.Text, "\n")
if len(lines) > 1 {
first := true
for _, line := range lines {
if first {
builder.WriteString(strings.Repeat(" ", item.Indented))
builder.WriteString("* ")
builder.WriteString(line)
builder.WriteByte('\n')
first = false
} else {
builder.WriteString(strings.Repeat(" ", item.Indented+1))
builder.WriteString(line)
builder.WriteByte('\n')
} }
} }
} else {
builder.WriteString(strings.Repeat(" ", item.Indented))
builder.WriteString("* ")
builder.WriteString(item.Text)
builder.WriteByte('\n')
}
}
pageText = builder.String()
}
pageText = renderLinks(pageText) pageText = renderLinks(pageText)