1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
'use strict';
const START = /^(\[_+)/g;
const END = /(_+])/g;
function locator(value, fromIndex) {
var index = value.indexOf(START, fromIndex);
return index;
}
function plugin() {
function blockTokenizer(eat, value, silent) {
if (!this.options.gfm || value.search(START) != 0) {
return;
}
if( value.search(END) > 0 ) {
return eat(value.slice(0,value.search(END))+value.match(END)[0])({
type:'html',
value:'<textarea>' + value.slice(value.match(START)[0].length+1, value.search(END)-1 ) + '</textarea>'
/*
type: 'form',
children: [ {
type: 'texterea',
children: [ { type: 'text',
value: value.slice(value.match(START)[0].length+1, value.search(END)-1 )
} ],
data: {
hName: 'textarea'
}
}],
*/
/*
data: {
hName: 'form',
hChildren : [ {
type: 'texterea',
data: {
hName: 'textarea',
hChildren : [ { type: 'text',
value: value.slice(value.match(START)[0].length+1, value.search(END)-1 )
} ]
}
}]
}
hName: 'form'
}*/
});
} else
return true;
}
blockTokenizer.locator = locator;
var Parser = this.Parser;
// Inject blockTokenizer
const blockTokenizers = Parser.prototype.blockTokenizers
const blockMethods = Parser.prototype.blockMethods
blockTokenizers.textinput = blockTokenizer
blockMethods.splice(blockMethods.indexOf('fencedCode') + 1, 0, 'textinput')
var Compiler = this.Compiler;
// Stringify
if (Compiler) {
var visitors = Compiler.prototype.visitors;
visitors.textinput = function (node) {
return '[__' + this.all(node).join('') + '__]';
};
}
}
module.exports = plugin;
|