aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2017-12-06 12:28:48 +0100
committerache <ache@ache.one>2017-12-06 12:28:48 +0100
commit749e7200f5fbff27bc20250ceb410ec8629e4a26 (patch)
treea2679d9e870ac0c711b2395d15cbc5e0705d2c64
Init commit
-rw-r--r--LICENSE19
-rw-r--r--README.md3
-rw-r--r--app.js63
-rw-r--r--package.json17
4 files changed, 102 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..9cf1062
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b1a339c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# remark-text-input
+
+
diff --git a/app.js b/app.js
new file mode 100644
index 0000000..b244cb8
--- /dev/null
+++ b/app.js
@@ -0,0 +1,63 @@
+'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'
+ }*/
+ });
+ } 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;
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..f791330
--- /dev/null
+++ b/package.json
@@ -0,0 +1,17 @@
+{
+ "name": "remark-text-input",
+ "version": "0.1.0",
+ "description": "A remark plugin that parse a syntax for textarea",
+ "main": "app.js",
+ "dependencies": {
+ "unist-util-visit": "^1.1.3"
+ },
+ "author": "ache",
+ "license": "MIT",
+ "keywords": [
+ "text",
+ "input",
+ "textarea",
+ "remark"
+ ]
+}