element-modifications/patch/greentext.patch
2021-08-05 17:50:40 +00:00

57 lines
2.4 KiB
Diff

--- ./commonmark.js.original 2021-03-27 12:41:48.000000000 -0400
+++ ./commonmark.js 2021-07-21 17:51:49.408590728 -0400
@@ -9877,17 +9877,42 @@
this.cr();
}
- function block_quote(node, entering) {
- var attrs = this.attrs(node);
- if (entering) {
- this.cr();
- this.tag("blockquote", attrs);
- this.cr();
- } else {
- this.cr();
- this.tag("/blockquote");
- this.cr();
- }
+ function block_quote(node, entering) {
+ var attrs = this.attrs(node);
+ if (node.firstChild !== null) {
+ var w = node.walker(), e, m=node.firstChild
+ while (m.firstChild !== null)
+ m = m.firstChild
+ while (m.type !== 'document') {
+ if (m.type == 'text' && m.literal[0] !== '>')
+ m.literal = '>' + m.literal
+ m = m.parent
+ }
+ while (e = w.next()) {
+ const n = e.node
+ if (e.entering == false)
+ continue
+ if (n.type == 'text') {
+ let o = n.parent
+ while (o.type !== 'document')
+ if (o.type == 'block_quote')
+ break
+ else
+ o = o.parent
+ if (o.type == 'block_quote' && (n.prev && n.prev.type == 'softbreak') && n.literal[0] !== '>') {
+ n.literal = '>' + n.literal
+ }
+ }
+ }
+ }
+
+ if (entering) {
+ this.tag('font', [...attrs, ['color', '#789922']]);
+ if (!node.firstChild)
+ this.buffer += '<p>&gt;</p>'
+ } else {
+ this.tag('/font');
+ }
}
function list(node, entering) {