Initial Commit

This commit is contained in:
2018-09-13 21:15:47 +02:00
commit 09f406cba7
84 changed files with 6920 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
const MarkdownIt = require("markdown-it")
const md = new MarkdownIt({
html: true,
linkify: true,
typographer: false,
langPrefix: "language-",
})
md.use(require("markdown-it-container"), "green")
md.use(require("markdown-it-container"), "orange")
md.use(require("markdown-it-container"), "blue")
md.use(require("./plugins/wikilink"))
const renderer = md.renderer
module.exports = class {
onCreate(input) {
this.state = {
render: () => {},
}
this.render(input.source || "")
}
onInput(input) {
if (input.source) {
this.render(input.source)
}
}
render(source) {
this.state.render = (out) => {
if (out.w) {
out.w(md.render(source))
}
}
}
}
renderer.rules
+3
View File
@@ -0,0 +1,3 @@
<div class=["markdown-content", "color-text", input.class]>
<include(state.render) />
</div>
@@ -0,0 +1,40 @@
/*
Based on the markdown-it-wikilinks, which is distributed under the MIT license.
https://github.com/jsepia/markdown-it-wikilinks @ 79fe609a03917f7df11128231118a66a559076d0
Copyright (c) 2016 Julio Sepia
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
const Plugin = require('markdown-it-regexp')
module.exports = new Plugin(/\[\[([\w'\s/]+)(\|([\w'\s/]+))?\]\]/, match => {
let label = ""
let page = ""
if (match[3] != null) {
label = match[3]
page = encodeURIComponent(match[1])
} else {
label = match[1]
page = encodeURIComponent(label)
}
if (label == "" || page == "") {
return match.input
}
return `<a class="wiki-link" href="https://wiki.aiterp.net?title=${page}">${label}</a>`
}
)
+117
View File
@@ -0,0 +1,117 @@
div.markdown-content {
line-height: 1.333em;
font-size: 1.25em;
h1 {
font-size: 2em;
margin: 0;
margin-top: 0.75em;
line-height: 1.2em;
text-align: left;
border-bottom: 1px solid;
}
h1:first-child {
margin-top: 0;
}
h2 {
font-size: 1.5em;
margin: 0;
margin-top: 0.75em;
padding-bottom: 0.25em;
border-bottom: 1px solid;
}
h3 {
font-size: 1.25em;
margin: 0;
margin-top: 1em;
padding: 0;
margin-bottom: -0.25em;
}
h4 {
font-size: 1em;
margin-top: 1em;
margin-bottom: -0.5em;
padding: 0;
}
h5 {
font-size: 1em;
margin: 0;
margin-bottom: -0.5em;
}
h6 {
font-size: 1em;
opacity: 0.5;
margin: 0;
margin-bottom: -0.5em;
}
hr {
border: none;
margin: 2em 2ch;
border-bottom: 4px dotted;
opacity: 0.75;
}
ul, ol {
padding: 0.5em 3ch;
margin: 0;
}
p {
padding: 0.5em 0;
margin: 0;
}
p:first-child {
padding-top: 0.25em;
}
.orange, .blue, .green, blockquote {
h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0.5em 0;
}
margin: 0.5em 0;
padding: 0.125em 0.5em 0 0.5em;
outline: 1px solid;
p {
padding: 0.5em 0;
margin: 0;
}
}
pre {
border: 1px solid;
padding: 0.5em;
}
table {
width: 100%;
border: 1px solid;
padding: 0em 0.5em;
th {
font-size: 0.75em;
padding: 0 1ch;
}
}
img {
width: 100%;
}
a {
opacity: 0.75;
}
a:hover {
opacity: 1;
}
}