Skip to content

Commit

Permalink
Added some grammars
Browse files Browse the repository at this point in the history
 * works like shit.
  • Loading branch information
LiteHell authored and LiteHell committed Feb 16, 2018
1 parent 26d1b27 commit a15b4b7
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Expand Up @@ -8,7 +8,7 @@
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}\\test\\app.js"
"program": "${workspaceRoot}/test/app.js"
}
]
}
13 changes: 13 additions & 0 deletions basicHTMLRenderer.js
Expand Up @@ -294,6 +294,19 @@ function HTMLRenderer(_options) {
break;
case 'paragraph-end':
appendResult('</p>');
break;
case 'wiki-box-start':
appendResult('<div ' + (i.style || '') + '>');
break;
case 'wiki-box-end':
appendResult('</div>');
break;
case 'folding-start':
appendResult('<details><summary>' + encodeHTMLComponent(i.summary) + '</summary>');
break;
case 'folding-end':
appendResult('</details>');
break;
}
}
function finalLoop(callback) {
Expand Down
1 change: 1 addition & 0 deletions processors/linkProcessor.js
Expand Up @@ -17,6 +17,7 @@ module.exports = (text, type, configs) => {
if (!configs.included)
return [{
name: "add-category",
blur: href[0].endsWith('#blur'),
categoryName: category
}];
} else if (/^파일:(.+)$/.test(href[0])) {
Expand Down
77 changes: 76 additions & 1 deletion processors/renderProcessor.js
Expand Up @@ -4,7 +4,82 @@ module.exports = (text, type) => {
name: "unsafe-plain",
text: text.substring(6)
}];
}
} else if (/^#!folding/i.test(text) && text.indexOf('\n') >= 10) {
return [{
name: "folding-start",
summary: text.substring(10, text.indexOf('\n'))
}, {
name: "wikitext",
treatAsBlock: true,
text: text.substring(text.indexOf('\n') + 1)
},
{
name: "folding-end"
}
];
} else if (/^#!syntax/i.test(text) && text.indexOf('\n') >= 9) {
return [{
name: "syntax-highlighting",
header: text.substring(9, text.indexOf('\n')),
body: text.substring(text.indexOf('\n') + 1)
}];
} else if (/^#!wiki/i.test(text)) {
if (text.indexOf('\n') >= 7) {
let params = text.substring(7, text.indexOf('\n'));
if (params.startsWith("style=\"") && /" +$/.test(params)) {
return [{
name: "wiki-box-start",
style: params.substring(7, params.length - /" +$/.exec(params)[0].length)
}, {
name: "wikitext",
treatAsBlock: true,
text: text.substring(text.indexOf('\n') + 1)
}, {
name: "wiki-box-end"
}]
} else {
return [{
name: "wiki-box-start"
}, {
name: "wikitext",
treatAsBlock: true,
text: text.substring(text.indexOf('\n') + 1)
}, {
name: "wiki-box-end"
}]

}
}
} else if (/^#([A-Fa-f0-9]{3,6}) (.*)$/.test(text)) {
let matches = /^#([A-Fa-f0-9]{3,6}) (.*)$/.exec(text);
if (matches[1].length === 0 && matches[2].length === 0)
return [{
name: "plain",
text: text
}];
return [{
name: "font-color-start",
color: matches[1]
}, {
name: "wikitext",
parseFormat: true,
text: matches[2]
}, {
name: "font-color-end"
}];
} else if (/^\+([1-5]) (.*)$/.test(text)) {
let matches = /^\+([1-5]) (.*)$/.exec(text);
return [{
name: "font-size-start",
level: matches[1]
}, {
name: "wikitext",
parseFormat: true,
text: matches[2]
}, {
name: "font-size-end"
}];
};
return [{
name: "monoscape-font-start",
pre: true
Expand Down

0 comments on commit a15b4b7

Please sign in to comment.