From e5075bcaff3c13d0e9e4893c36db0f38012a1047 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Sun, 15 May 2016 13:13:28 +0900 Subject: [PATCH 01/29] [fix] fix bottom --- nml.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nml.css b/nml.css index cd8210d..8e27b2f 100644 --- a/nml.css +++ b/nml.css @@ -36,7 +36,7 @@ pre { float: left; width: 80%; margin-top: 0.5em; - margin-bottom: 3em; + margin-bottom: 0.5em; } .formarea { float: left; From 6dfeb4c2df281ccd44dc1354f213f64fb5403d71 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Sun, 15 May 2016 13:16:10 +0900 Subject: [PATCH 02/29] [fix] jquery url --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index bb6b0b0..d2d82aa 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ NML-Converter - + From ece737cd177449defbff864f58faba5007491ceb Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Sun, 15 May 2016 13:40:40 +0900 Subject: [PATCH 03/29] [add] add drop shadow --- nml.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nml.css b/nml.css index 8e27b2f..e93a1cf 100644 --- a/nml.css +++ b/nml.css @@ -55,6 +55,8 @@ pre { color: #fff; background-color: #009688; text-align: center; + box-shadow: 0px 1px 2px 1px #999; + } .footer{ line-height:1.2; From dd3c9240a4cbac2b39c96544390e593701170e1e Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Sun, 15 May 2016 14:06:34 +0900 Subject: [PATCH 04/29] [add] return --- bundle.js | 10 +++++++++- src/nml.coffee | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bundle.js b/bundle.js index 042e8ad..7d4fef4 100644 --- a/bundle.js +++ b/bundle.js @@ -31,7 +31,7 @@ $(function(){ },{"./out/nml":2}],2:[function(require,module,exports){ (function() { module.exports = this.NML = (function() { - var checkBlockquotes, checkBold, checkItalic, checkLine, checkLink, checkNewPage, checkPunctuationNumber, checkPunctuationSymbol, checkReturn, checkRuby, checkSharp, checkSpace, checkStrikethrough, mode; + var checkBlockquotes, checkBold, checkItalic, checkLine, checkLink, checkNewPage, checkNextLine, checkPunctuationNumber, checkPunctuationSymbol, checkReturn, checkRuby, checkSharp, checkSpace, checkStrikethrough, mode; mode = 0; @@ -78,6 +78,7 @@ $(function(){ line = checkLink(line); line = checkPunctuationNumber(line); line = checkPunctuationSymbol(line); + line = checkNextLine(line); return line; }; @@ -273,6 +274,13 @@ $(function(){ return line; }; + checkNextLine = function(line) { + if (line.match(/[ \s]{3,}$/)) { + line = line + "
"; + } + return line; + }; + return NML; })(); diff --git a/src/nml.coffee b/src/nml.coffee index 5e93812..396016c 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -39,6 +39,7 @@ module.exports = class @NML line = checkLink(line) line = checkPunctuationNumber(line) line = checkPunctuationSymbol(line) + line = checkNextLine(line) line #形式段落 @@ -198,3 +199,9 @@ module.exports = class @NML if mode is 1 line = '
' line + + #改行 + checkNextLine = (line) -> + if line.match(/[ \s]{3,}$/) + line = line + "
" + line From 43bf17b1393069d690c6683b56fa2b6e1e410ec8 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Sun, 15 May 2016 14:09:55 +0900 Subject: [PATCH 05/29] [add] add LICENSE file --- LICENSE | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1fac5f0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright © 2016 AI-create-team + +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. From 09969ec45ecf1f06ee479a66663035601d7c9739 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Tue, 17 May 2016 23:03:57 +0900 Subject: [PATCH 06/29] [fix] fix Html tag --- src/nml.coffee | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/nml.coffee b/src/nml.coffee index 396016c..ad0a389 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -4,6 +4,12 @@ module.exports = class @NML # mode # 1:html # 2:plain + multi_line = "" + multi_line_mode = 0 + # mode + # 0:not multi line + # 1:html + # 2:plain constructor: (@text) -> @@ -156,13 +162,13 @@ module.exports = class @NML linkText = linkText.substring(1, linkText.length - 1) url = url.substring(1, url.length - 1) name = name.substring(1, name.length - 1) - line = line.replace(text, '' + linkText + '') + line = line.replace(text, '' + linkText + '') else linkText = line.match(/\[.*?\]/)[0] url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), '') linkText = linkText.substring(1, linkText.length - 1) url = url.substring(1, url.length - 1) - line = line.replace(text, '' + linkText + '') + line = line.replace(text, '' + linkText + '') else if mode is 2 line = line.replace(text, "") @@ -190,18 +196,18 @@ module.exports = class @NML checkPunctuationNumber = (line) -> if line.match(/^[0-9]+\.$/) if mode is 1 - line = '
' + line = '
' line #記号区切り checkPunctuationSymbol = (line) -> if line.match(/^[-*ー*]+\.$/) if mode is 1 - line = '
' + line = '
' line #改行 checkNextLine = (line) -> if line.match(/[ \s]{3,}$/) - line = line + "
" + line = line + "
" line From 301fe26d0bb603cdba989f8297eee9da1b3e0205 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Tue, 17 May 2016 23:08:45 +0900 Subject: [PATCH 07/29] [fix] fixed #3 --- bundle.js | 101 ++++++++++++++++++++++++++++++++++++++++++++++++----- index.html | 1 + main.js | 85 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 175 insertions(+), 12 deletions(-) diff --git a/bundle.js b/bundle.js index 7d4fef4..e3fe301 100644 --- a/bundle.js +++ b/bundle.js @@ -9,15 +9,94 @@ window.convert = function() { var novel = new NML(textarea.value) var output = document.getElementById("output"); - if (mode.options[mode.selectedIndex].value === "plain"){ - output.innerHTML = "
" + novel.to(mode.options[mode.selectedIndex].value) + "
"; + if (mode.options[mode.selectedIndex].value === "htmlpre"){ + output.innerHTML = novel.to("html"); + }else if (mode.options[mode.selectedIndex].value === "html"){ + var text = novel.to(mode.options[mode.selectedIndex].value); + text = text.replace( /\n/g , "" ) ; + output.innerHTML = "
" + format_xml(text) + "
"; + + var pre = document.querySelectorAll('pre'); + for(var i = 0; i < pre.length; i++) { + pre[i].innerHTML = escapeHtml(pre[i].innerHTML); + } }else{ - output.innerHTML = novel.to(mode.options[mode.selectedIndex].value); + output.innerHTML = "
" + novel.to(mode.options[mode.selectedIndex].value) + "
"; } +} +function spaces(len) +{ + var s = ''; + var indent = len*4; + for (i=0;i)(<)(\/*)/g,"$1\r$2$3"); + + // add indents + var pad = 0; + var indent; + var node; + // split the string + var strArr = str.split("\r"); + // check the various tag states + for (var i = 0; i < strArr.length; i++) { + indent = 0; + node = strArr[i]; + + if(node.match(/.+<\/\w[^>]*>$/)){ //open and closing in the same line + indent = 0; + } else if(node.match(/^<\/\w/)){ // closing tag + if (pad > 0){pad -= 1;} + } else if (node.match(/^<\w[^>]*[^\/]>.*$/)){ //opening tag + indent = 1; + } else + indent = 0; + //} + + xml += spaces(pad) + node + "\r"; + pad += indent; + } + + return xml; } +var escapeHtml = (function (String) { + var escapeMap = { + '&': '&', + "'": ''', + '`': '`', + '"': '"', + '<': '<', + '>': '>' + }; + var escapeReg = '['; + var reg; + for (var p in escapeMap) { + if (escapeMap.hasOwnProperty(p)) { + escapeReg += p; + } + } + escapeReg += ']'; + reg = new RegExp(escapeReg, 'g'); + return function escapeHtml (str) { + str = (str === null || str === undefined) ? '' : '' + str; + return str.replace(reg, function (match) { + return escapeMap[match]; + }); + }; +}(String)); + + $(function(){ convert(); }); @@ -31,10 +110,14 @@ $(function(){ },{"./out/nml":2}],2:[function(require,module,exports){ (function() { module.exports = this.NML = (function() { - var checkBlockquotes, checkBold, checkItalic, checkLine, checkLink, checkNewPage, checkNextLine, checkPunctuationNumber, checkPunctuationSymbol, checkReturn, checkRuby, checkSharp, checkSpace, checkStrikethrough, mode; + var checkBlockquotes, checkBold, checkItalic, checkLine, checkLink, checkNewPage, checkNextLine, checkPunctuationNumber, checkPunctuationSymbol, checkReturn, checkRuby, checkSharp, checkSpace, checkStrikethrough, mode, multi_line, multi_line_mode; mode = 0; + multi_line = ""; + + multi_line_mode = 0; + function NML(text1) { this.text = text1; } @@ -220,13 +303,13 @@ $(function(){ linkText = linkText.substring(1, linkText.length - 1); url = url.substring(1, url.length - 1); name = name.substring(1, name.length - 1); - line = line.replace(text, '' + linkText + ''); + line = line.replace(text, '' + linkText + ''); } else { linkText = line.match(/\[.*?\]/)[0]; url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), ''); linkText = linkText.substring(1, linkText.length - 1); url = url.substring(1, url.length - 1); - line = line.replace(text, '' + linkText + ''); + line = line.replace(text, '' + linkText + ''); } } else if (mode === 2) { line = line.replace(text, ""); @@ -259,7 +342,7 @@ $(function(){ checkPunctuationNumber = function(line) { if (line.match(/^[0-9]+\.$/)) { if (mode === 1) { - line = '
'; + line = '
'; } } return line; @@ -268,7 +351,7 @@ $(function(){ checkPunctuationSymbol = function(line) { if (line.match(/^[-*ー*]+\.$/)) { if (mode === 1) { - line = '
'; + line = '
'; } } return line; @@ -276,7 +359,7 @@ $(function(){ checkNextLine = function(line) { if (line.match(/[ \s]{3,}$/)) { - line = line + "
"; + line = line + "
"; } return line; }; diff --git a/index.html b/index.html index d2d82aa..fe2540e 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ NML Convert to
'; - } else if (mode === 2) { - line = ''; - } - } - return line; - }; - - checkSharp = function(line) { - var count, md; - if (mode === 1) { - md = void 0; - if ((md = line.match(/^[##]*/)[0]) !== '') { - count = md.length > 6 ? 6 : md.length; - line = line.replace(/^[##]*/, ''); - line = '' + line + ''; - } - } else if (mode === 2) { - line = line.replace(/^[##]*/, ''); - } - return line; - }; - - checkStrikethrough = function(line) { - var myArray, myRe, text; - myRe = /[\~〜]{2}.*?[\~〜]{2}/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (mode === 1) { - line = line.replace(text, '' + text.substring(2, text.length - 2) + ''); - } else if (mode === 2) { - line = line.replace(text, text.substring(2, text.length - 2)); - } - } - return line; - }; - - checkItalic = function(line) { - var myArray, myRe, text; - myRe = /[\__**]{1}.*?[\__**]{1}/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (mode === 1) { - if (!text.match(/^[\__**]{2}$/)) { - line = line.replace(text, '' + text.substring(1, text.length - 1) + ''); - } - } else if (mode === 2) { - if (!text.match(/^[\__**]{2}$/)) { - line = line.replace(text, text.substring(1, text.length - 1)); - } - } - } - return line; - }; - - checkBold = function(line) { - var myArray, myRe, text; - myRe = /[\__**]{2}.*?[\__**]{2}/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (mode === 1) { - line = line.replace(text, '' + text.substring(2, text.length - 2) + ''); - } else if (mode === 2) { - line = line.replace(text, text.substring(2, text.length - 2)); - } - } - return line; - }; - - checkBlockquotes = function(line) { - if (line.match(/^[>>]/)) { - if (mode === 1) { - line = '
' + line.substring(1) + '
'; - } - } - return line; - }; - - checkLink = function(line) { - var linkText, myArray, myRe, name, text, url; - myRe = /[!!]*\[.*?\][\((].*?[\))]/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (text.match(/[!!]{1,}\[.*?\][\((].*?[\))]/)) { - if (mode === 1) { - if (text.match(/\".*\"/)) { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\"]/)[0].replace(RegExp(' ', 'g'), ''); - name = line.match(/[\"].*?[\"]/)[0]; - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - name = name.substring(1, name.length - 1); - line = line.replace(text, '' + linkText + ''); - } else { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), ''); - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - line = line.replace(text, '' + linkText + ''); - } - } else if (mode === 2) { - line = line.replace(text, ""); - } - } else { - if (mode === 1) { - if (text.match(/\".*\"/)) { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\"]/)[0].replace(RegExp(' ', 'g'), ''); - name = line.match(/[\"].*?[\"]/)[0]; - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - name = name.substring(1, name.length - 1); - line = line.replace(text, '' + linkText + ''); - } else { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), ''); - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - line = line.replace(text, '' + linkText + ''); - } - } else if (mode === 2) { - line = line.replace(text, ""); - } - } - } - return line; - }; - - checkPunctuationNumber = function(line) { - if (line.match(/^[0-9]+\.$/)) { - if (mode === 1) { - line = '
'; - } - } - return line; - }; - - checkPunctuationSymbol = function(line) { - if (line.match(/^[-*ー*]+\.$/)) { - if (mode === 1) { - line = '
'; - } - } - return line; - }; - - checkNextLine = function(line) { - if (line.match(/[ \s]{3,}$/)) { - line = line + "
"; - } - return line; - }; - - return NML; - - })(); - -}).call(this); - -},{}]},{},[1]); diff --git a/main.js b/main.js deleted file mode 100644 index 240af87..0000000 --- a/main.js +++ /dev/null @@ -1,106 +0,0 @@ -NML = require("./out/nml") - -window.convert = function() { - - var textarea = document.getElementsByTagName('textarea')[0]; - var mode = document.getElementById('mode'); - - var novel = new NML(textarea.value) - var output = document.getElementById("output"); - - if (mode.options[mode.selectedIndex].value === "htmlpre"){ - $("#output").replaceWith("
" + novel.to("html") + "
"); - }else if (mode.options[mode.selectedIndex].value === "html"){ - var text = novel.to(mode.options[mode.selectedIndex].value); - text = text.replace( /\n/g , "" ) ; - $("#output").replaceWith(""); - var pre = document.querySelectorAll('pre'); - for(var i = 0; i < pre.length; i++) { - pre[i].innerHTML = escapeHtml(pre[i].innerHTML); - } - }else{ - $("#output").replaceWith("
" + "
" + novel.to(mode.options[mode.selectedIndex].value) + "
" + "
"); - } -} -function spaces(len) -{ - var s = ''; - var indent = len*4; - for (i=0;i)(<)(\/*)/g,"$1\r$2$3"); - - // add indents - var pad = 0; - var indent; - var node; - - // split the string - var strArr = str.split("\r"); - - // check the various tag states - for (var i = 0; i < strArr.length; i++) { - indent = 0; - node = strArr[i]; - - if(node.match(/.+<\/\w[^>]*>$/)){ //open and closing in the same line - indent = 0; - } else if(node.match(/^<\/\w/)){ // closing tag - if (pad > 0){pad -= 1;} - } else if (node.match(/^<\w[^>]*[^\/]>.*$/)){ //opening tag - indent = 1; - } else - indent = 0; - //} - - xml += spaces(pad) + node + "\r"; - pad += indent; - } - - return xml; -} - -var escapeHtml = (function (String) { - var escapeMap = { - '&': '&', - "'": ''', - '`': '`', - '"': '"', - '<': '<', - '>': '>' - }; - var escapeReg = '['; - var reg; - for (var p in escapeMap) { - if (escapeMap.hasOwnProperty(p)) { - escapeReg += p; - } - } - escapeReg += ']'; - reg = new RegExp(escapeReg, 'g'); - return function escapeHtml (str) { - str = (str === null || str === undefined) ? '' : '' + str; - return str.replace(reg, function (match) { - return escapeMap[match]; - }); - }; -}(String)); - - -$(function(){ - convert(); -}); - -$(function(){ - $("#textarea").bind("keyup", function(){ - convert(); - }); -}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..0747d06 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "nml", + "version": "1.0.0", + "description": "NML(Novel Markup Language) converter for js", + "main": "main.js", + "scripts": { + "test": "ava -v" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/WriterLighter/NML-JavaScript.git" + }, + "keywords": [ + "nml", + "converter", + "novel", + "markup" + ], + "author": "Ritsuki Goto (http://kawakawaplanning.xyz/)", + "license": "MIT", + "bugs": { + "url": "https://github.com/WriterLighter/NML-JavaScript/issues" + }, + "homepage": "https://github.com/WriterLighter/NML-JavaScript#readme", + "devDependencies": { + "ava": "^0.14.0" + } +} From 52e3963d5582f9e85ebac4da26e577ff5eaecccb Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 17:31:03 +0900 Subject: [PATCH 12/29] [modify] package.json "test" --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0747d06..588d010 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "NML(Novel Markup Language) converter for js", "main": "main.js", "scripts": { - "test": "ava -v" + "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", From a69fa6053fab421be8613ee05d0be26dcaa72377 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 17:45:50 +0900 Subject: [PATCH 13/29] [add] devDependencies --- package.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 588d010..bb14ba3 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,13 @@ }, "homepage": "https://github.com/WriterLighter/NML-JavaScript#readme", "devDependencies": { - "ava": "^0.14.0" + "browserify": "^13.0.0", + "coffee-script": "^1.10.0", + "gulp": "^3.9.0", + "gulp-coffee": "^2.3.1", + "gulp-plumber": "^1.1.0", + "gulp-concat": "^2.6.0", + "gulp-watch": "^4.3.5", + "gulp-notify": "^2.2.0" } } From ffbcf611b1fec37e393d41df332cc5fe7f886b05 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 17:50:24 +0900 Subject: [PATCH 14/29] [fix] for npm --- gulpfile.coffee | 2 +- index.html | 72 ------------- nml.css | 151 ---------------------------- nml.js | 261 ++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 5 files changed, 263 insertions(+), 225 deletions(-) delete mode 100644 index.html delete mode 100644 nml.css create mode 100644 nml.js diff --git a/gulpfile.coffee b/gulpfile.coffee index d18d80c..0dae87c 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -10,7 +10,7 @@ gulp.task 'nml', -> .pipe(plumber()) .pipe(coffee()) .pipe(concat('nml.js')) - .pipe(gulp.dest('out')) + .pipe(gulp.dest('')) .pipe notify 'nml.js done!!!', {onLast: true} gulp.task 'watch', ['default'], -> diff --git a/index.html b/index.html deleted file mode 100644 index 610af0e..0000000 --- a/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - NML-Converter - - - - - - - -
- NML Convert to -
- -
-
- -
-
- -
-
-
-
-
-
-
-
- - - diff --git a/nml.css b/nml.css deleted file mode 100644 index e93a1cf..0000000 --- a/nml.css +++ /dev/null @@ -1,151 +0,0 @@ -html, body { - height: 100%; - padding: 0; - margin: 0; -} -textarea { - resize: none; - height: 100%; - width: 100%; - padding: 1em 1em; - background-color: #E0F2F1; - font-family: sans-serif; - border:0px; - font-size: 1em; -} -pre { - font-family: sans-serif; - font-size: 1em; -} -.meg { - width: 10%; - align-items: stretch; - float: left; - height: 100%; -} -.out{ - padding: 0em 1em; - height: 100%; - width: 100%; - word-wrap: break-word; - overflow: auto; - background-color: #B2DFDB; -} -.form { - align-items: stretch; - float: left; - width: 80%; - margin-top: 0.5em; - margin-bottom: 0.5em; -} -.formarea { - float: left; - width: 49%; -} -.split { - float: left; - width: 0.5em; - height: 100%; - background-color: #FFF; -} -.title{ - width: 100%; - height: 1.5em; - font-size: 3em; - color: #fff; - background-color: #009688; - text-align: center; - box-shadow: 0px 1px 2px 1px #999; - -} -.footer{ - line-height:1.2; - z-index:9999; - text-align:center; - position:fixed; - bottom:0; - left:0; - width:100%; - padding:8px; - background:#222222; - color: #FFF; - font-size:1em; - background-color:rgba(0,0,0,0.7); -} -.footer-link{ - color: #FFF -} - -.dropdown-select { - position: relative; - width: 130%; - margin: 0; - padding: 6px 8px 6px 10px; - height: 28px; - line-height: 14px; - font-size: 12px; - color: #62717a; - text-shadow: 0 1px white; - /* Fallback for IE 8 */ - background: #f2f2f2; - /* "transparent" doesn't work with Opera */ - background: rgba(0, 0, 0, 0) !important; - border: 0; - border-radius: 0; - -webkit-appearance: none; -} -.dropdown-select:focus { - z-index: 3; - width: 100%; - color: #394349; - outline: 2px solid #49aff2; - outline: 2px solid -webkit-focus-ring-color; - outline-offset: -2px; -} -.dropdown-select > option { - margin: 3px; - padding: 6px 8px; - text-shadow: none; - background: #f2f2f2; - border-radius: 3px; - cursor: pointer; -} - -.dropdown { - display: inline-block; - position: relative; - overflow: hidden; - height: 28px; - width: 150px; - background: #f2f2f2; - border: 1px solid; - border-color: white #f7f7f7 #f5f5f5; - border-radius: 3px; - background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.06)); - background-image: -moz-linear-gradient(top, transparent, rgba(0, 0, 0, 0.06)); - background-image: -o-linear-gradient(top, transparent, rgba(0, 0, 0, 0.06)); - background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.06)); - -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08); - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08); -} -.dropdown:before, .dropdown:after { - content: ''; - position: absolute; - z-index: 2; - top: 9px; - right: 10px; - width: 0; - height: 0; - border: 4px dashed; - border-color: #888 transparent; - pointer-events: none; -} -.dropdown:before { - border-bottom-style: solid; - border-top: none; -} -.dropdown:after { - margin-top: 7px; - border-top-style: solid; - border-bottom: none; -} diff --git a/nml.js b/nml.js new file mode 100644 index 0000000..2fd7a5d --- /dev/null +++ b/nml.js @@ -0,0 +1,261 @@ +(function() { + module.exports = this.NML = (function() { + var checkBlockquotes, checkBold, checkItalic, checkLine, checkLink, checkNewPage, checkNextLine, checkPunctuationNumber, checkPunctuationSymbol, checkReturn, checkRuby, checkSharp, checkSpace, checkStrikethrough, mode, multi_line, multi_line_mode; + + mode = 0; + + multi_line = ""; + + multi_line_mode = 0; + + function NML(text1) { + this.text = text1; + } + + NML.prototype.to = function(t) { + var body, s; + switch (t) { + case "html": + mode = 1; + s = ''; + body = this.text.split('\n'); + body.forEach(function(text1) { + this.text = text1; + return s = s + checkLine(this.text) + '\n'; + }); + return '
' + s + '
'; + case "plain": + mode = 2; + s = ''; + body = this.text.split('\n'); + body.forEach(function(text1) { + this.text = text1; + return s = s + checkLine(this.text) + '\n'; + }); + return s; + default: + return "Error!"; + } + }; + + checkLine = function(line) { + line = checkSpace(line); + line = checkReturn(line); + line = checkRuby(line); + line = checkNewPage(line); + line = checkSharp(line); + line = checkStrikethrough(line); + line = checkItalic(line); + line = checkBold(line); + line = checkBlockquotes(line); + line = checkLink(line); + line = checkPunctuationNumber(line); + line = checkPunctuationSymbol(line); + line = checkNextLine(line); + return line; + }; + + checkSpace = function(line) { + if (line.match(/^[ \s]/)) { + if (mode === 1) { + line = '

' + line + '

'; + } + } + return line; + }; + + checkReturn = function(line) { + if (line === '') { + if (mode === 1) { + line = '
'; + } + } + return line; + }; + + checkRuby = function(line) { + var moji, myArray, myRe, ruby, text; + myRe = /[\||].*?[\((].*?[\))]/g; + myArray = void 0; + while ((myArray = myRe.exec(line)) !== null) { + text = myArray[0]; + if (mode === 1) { + moji = text.match(/[\||].*?[\((]/)[0]; + moji = moji.substring(1, moji.length - 1); + ruby = text.match(/[\((].*?[\))]/)[0]; + ruby = ruby.substring(1, ruby.length - 1); + line = line.replace(text, '' + moji + '' + ruby + ''); + } else { + moji = text.match(/[\||].*?[\((]/)[0]; + moji = moji.substring(1, moji.length - 1); + line = line.replace(text, moji); + } + } + return line; + }; + + checkNewPage = function(line) { + if (line.match(/^[-ーis]{3,}$/)) { + if (mode === 1) { + line = '
'; + } else if (mode === 2) { + line = ''; + } + } + return line; + }; + + checkSharp = function(line) { + var count, md; + if (mode === 1) { + md = void 0; + if ((md = line.match(/^[##]*/)[0]) !== '') { + count = md.length > 6 ? 6 : md.length; + line = line.replace(/^[##]*/, ''); + line = '' + line + ''; + } + } else if (mode === 2) { + line = line.replace(/^[##]*/, ''); + } + return line; + }; + + checkStrikethrough = function(line) { + var myArray, myRe, text; + myRe = /[\~〜]{2}.*?[\~〜]{2}/g; + myArray = void 0; + while ((myArray = myRe.exec(line)) !== null) { + text = myArray[0]; + if (mode === 1) { + line = line.replace(text, '' + text.substring(2, text.length - 2) + ''); + } else if (mode === 2) { + line = line.replace(text, text.substring(2, text.length - 2)); + } + } + return line; + }; + + checkItalic = function(line) { + var myArray, myRe, text; + myRe = /[\__**]{1}.*?[\__**]{1}/g; + myArray = void 0; + while ((myArray = myRe.exec(line)) !== null) { + text = myArray[0]; + if (mode === 1) { + if (!text.match(/^[\__**]{2}$/)) { + line = line.replace(text, '' + text.substring(1, text.length - 1) + ''); + } + } else if (mode === 2) { + if (!text.match(/^[\__**]{2}$/)) { + line = line.replace(text, text.substring(1, text.length - 1)); + } + } + } + return line; + }; + + checkBold = function(line) { + var myArray, myRe, text; + myRe = /[\__**]{2}.*?[\__**]{2}/g; + myArray = void 0; + while ((myArray = myRe.exec(line)) !== null) { + text = myArray[0]; + if (mode === 1) { + line = line.replace(text, '' + text.substring(2, text.length - 2) + ''); + } else if (mode === 2) { + line = line.replace(text, text.substring(2, text.length - 2)); + } + } + return line; + }; + + checkBlockquotes = function(line) { + if (line.match(/^[>>]/)) { + if (mode === 1) { + line = '
' + line.substring(1) + '
'; + } + } + return line; + }; + + checkLink = function(line) { + var linkText, myArray, myRe, name, text, url; + myRe = /[!!]*\[.*?\][\((].*?[\))]/g; + myArray = void 0; + while ((myArray = myRe.exec(line)) !== null) { + text = myArray[0]; + if (text.match(/[!!]{1,}\[.*?\][\((].*?[\))]/)) { + if (mode === 1) { + if (text.match(/\".*\"/)) { + linkText = line.match(/\[.*?\]/)[0]; + url = line.match(/[\((].*?[\"]/)[0].replace(RegExp(' ', 'g'), ''); + name = line.match(/[\"].*?[\"]/)[0]; + linkText = linkText.substring(1, linkText.length - 1); + url = url.substring(1, url.length - 1); + name = name.substring(1, name.length - 1); + line = line.replace(text, '' + linkText + ''); + } else { + linkText = line.match(/\[.*?\]/)[0]; + url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), ''); + linkText = linkText.substring(1, linkText.length - 1); + url = url.substring(1, url.length - 1); + line = line.replace(text, '' + linkText + ''); + } + } else if (mode === 2) { + line = line.replace(text, ""); + } + } else { + if (mode === 1) { + if (text.match(/\".*\"/)) { + linkText = line.match(/\[.*?\]/)[0]; + url = line.match(/[\((].*?[\"]/)[0].replace(RegExp(' ', 'g'), ''); + name = line.match(/[\"].*?[\"]/)[0]; + linkText = linkText.substring(1, linkText.length - 1); + url = url.substring(1, url.length - 1); + name = name.substring(1, name.length - 1); + line = line.replace(text, '' + linkText + ''); + } else { + linkText = line.match(/\[.*?\]/)[0]; + url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), ''); + linkText = linkText.substring(1, linkText.length - 1); + url = url.substring(1, url.length - 1); + line = line.replace(text, '' + linkText + ''); + } + } else if (mode === 2) { + line = line.replace(text, ""); + } + } + } + return line; + }; + + checkPunctuationNumber = function(line) { + if (line.match(/^[0-9]+\.$/)) { + if (mode === 1) { + line = '
'; + } + } + return line; + }; + + checkPunctuationSymbol = function(line) { + if (line.match(/^[-*ー*]+\.$/)) { + if (mode === 1) { + line = '
'; + } + } + return line; + }; + + checkNextLine = function(line) { + if (line.match(/[ \s]{3,}$/)) { + line = line + "
"; + } + return line; + }; + + return NML; + + })(); + +}).call(this); diff --git a/package.json b/package.json index bb14ba3..593bce9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nml", "version": "1.0.0", "description": "NML(Novel Markup Language) converter for js", - "main": "main.js", + "main": "nml.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, From fff158fe4b24959ec1322e777d12e82a08968247 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 18:05:14 +0900 Subject: [PATCH 15/29] [modify] package name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 593bce9..7c56928 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "nml", + "name": "nml-converter", "version": "1.0.0", "description": "NML(Novel Markup Language) converter for js", "main": "nml.js", From 7d857d203eae7dd6cc0f994a555ab69de9f028ac Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 18:12:36 +0900 Subject: [PATCH 16/29] [delete] nml.js --- .gitignore | 2 +- nml.js | 261 ----------------------------------------------------- 2 files changed, 1 insertion(+), 262 deletions(-) delete mode 100644 nml.js diff --git a/.gitignore b/.gitignore index 994fef6..225e7c1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ node_modules out bower_components -main.js bundle.js +nml.js diff --git a/nml.js b/nml.js deleted file mode 100644 index 2fd7a5d..0000000 --- a/nml.js +++ /dev/null @@ -1,261 +0,0 @@ -(function() { - module.exports = this.NML = (function() { - var checkBlockquotes, checkBold, checkItalic, checkLine, checkLink, checkNewPage, checkNextLine, checkPunctuationNumber, checkPunctuationSymbol, checkReturn, checkRuby, checkSharp, checkSpace, checkStrikethrough, mode, multi_line, multi_line_mode; - - mode = 0; - - multi_line = ""; - - multi_line_mode = 0; - - function NML(text1) { - this.text = text1; - } - - NML.prototype.to = function(t) { - var body, s; - switch (t) { - case "html": - mode = 1; - s = ''; - body = this.text.split('\n'); - body.forEach(function(text1) { - this.text = text1; - return s = s + checkLine(this.text) + '\n'; - }); - return '
' + s + '
'; - case "plain": - mode = 2; - s = ''; - body = this.text.split('\n'); - body.forEach(function(text1) { - this.text = text1; - return s = s + checkLine(this.text) + '\n'; - }); - return s; - default: - return "Error!"; - } - }; - - checkLine = function(line) { - line = checkSpace(line); - line = checkReturn(line); - line = checkRuby(line); - line = checkNewPage(line); - line = checkSharp(line); - line = checkStrikethrough(line); - line = checkItalic(line); - line = checkBold(line); - line = checkBlockquotes(line); - line = checkLink(line); - line = checkPunctuationNumber(line); - line = checkPunctuationSymbol(line); - line = checkNextLine(line); - return line; - }; - - checkSpace = function(line) { - if (line.match(/^[ \s]/)) { - if (mode === 1) { - line = '

' + line + '

'; - } - } - return line; - }; - - checkReturn = function(line) { - if (line === '') { - if (mode === 1) { - line = '
'; - } - } - return line; - }; - - checkRuby = function(line) { - var moji, myArray, myRe, ruby, text; - myRe = /[\||].*?[\((].*?[\))]/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (mode === 1) { - moji = text.match(/[\||].*?[\((]/)[0]; - moji = moji.substring(1, moji.length - 1); - ruby = text.match(/[\((].*?[\))]/)[0]; - ruby = ruby.substring(1, ruby.length - 1); - line = line.replace(text, '' + moji + '' + ruby + ''); - } else { - moji = text.match(/[\||].*?[\((]/)[0]; - moji = moji.substring(1, moji.length - 1); - line = line.replace(text, moji); - } - } - return line; - }; - - checkNewPage = function(line) { - if (line.match(/^[-ーis]{3,}$/)) { - if (mode === 1) { - line = '
'; - } else if (mode === 2) { - line = ''; - } - } - return line; - }; - - checkSharp = function(line) { - var count, md; - if (mode === 1) { - md = void 0; - if ((md = line.match(/^[##]*/)[0]) !== '') { - count = md.length > 6 ? 6 : md.length; - line = line.replace(/^[##]*/, ''); - line = '' + line + ''; - } - } else if (mode === 2) { - line = line.replace(/^[##]*/, ''); - } - return line; - }; - - checkStrikethrough = function(line) { - var myArray, myRe, text; - myRe = /[\~〜]{2}.*?[\~〜]{2}/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (mode === 1) { - line = line.replace(text, '' + text.substring(2, text.length - 2) + ''); - } else if (mode === 2) { - line = line.replace(text, text.substring(2, text.length - 2)); - } - } - return line; - }; - - checkItalic = function(line) { - var myArray, myRe, text; - myRe = /[\__**]{1}.*?[\__**]{1}/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (mode === 1) { - if (!text.match(/^[\__**]{2}$/)) { - line = line.replace(text, '' + text.substring(1, text.length - 1) + ''); - } - } else if (mode === 2) { - if (!text.match(/^[\__**]{2}$/)) { - line = line.replace(text, text.substring(1, text.length - 1)); - } - } - } - return line; - }; - - checkBold = function(line) { - var myArray, myRe, text; - myRe = /[\__**]{2}.*?[\__**]{2}/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (mode === 1) { - line = line.replace(text, '' + text.substring(2, text.length - 2) + ''); - } else if (mode === 2) { - line = line.replace(text, text.substring(2, text.length - 2)); - } - } - return line; - }; - - checkBlockquotes = function(line) { - if (line.match(/^[>>]/)) { - if (mode === 1) { - line = '
' + line.substring(1) + '
'; - } - } - return line; - }; - - checkLink = function(line) { - var linkText, myArray, myRe, name, text, url; - myRe = /[!!]*\[.*?\][\((].*?[\))]/g; - myArray = void 0; - while ((myArray = myRe.exec(line)) !== null) { - text = myArray[0]; - if (text.match(/[!!]{1,}\[.*?\][\((].*?[\))]/)) { - if (mode === 1) { - if (text.match(/\".*\"/)) { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\"]/)[0].replace(RegExp(' ', 'g'), ''); - name = line.match(/[\"].*?[\"]/)[0]; - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - name = name.substring(1, name.length - 1); - line = line.replace(text, '' + linkText + ''); - } else { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), ''); - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - line = line.replace(text, '' + linkText + ''); - } - } else if (mode === 2) { - line = line.replace(text, ""); - } - } else { - if (mode === 1) { - if (text.match(/\".*\"/)) { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\"]/)[0].replace(RegExp(' ', 'g'), ''); - name = line.match(/[\"].*?[\"]/)[0]; - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - name = name.substring(1, name.length - 1); - line = line.replace(text, '' + linkText + ''); - } else { - linkText = line.match(/\[.*?\]/)[0]; - url = line.match(/[\((].*?[\))]/)[0].replace(RegExp(' ', 'g'), ''); - linkText = linkText.substring(1, linkText.length - 1); - url = url.substring(1, url.length - 1); - line = line.replace(text, '' + linkText + ''); - } - } else if (mode === 2) { - line = line.replace(text, ""); - } - } - } - return line; - }; - - checkPunctuationNumber = function(line) { - if (line.match(/^[0-9]+\.$/)) { - if (mode === 1) { - line = '
'; - } - } - return line; - }; - - checkPunctuationSymbol = function(line) { - if (line.match(/^[-*ー*]+\.$/)) { - if (mode === 1) { - line = '
'; - } - } - return line; - }; - - checkNextLine = function(line) { - if (line.match(/[ \s]{3,}$/)) { - line = line + "
"; - } - return line; - }; - - return NML; - - })(); - -}).call(this); From 02f04c1454e264e38bb06a2708372f1b2da4ff20 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 18:23:00 +0900 Subject: [PATCH 17/29] [modify] README --- README.md | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb33ba6..383d982 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,36 @@ # NML-JavaScript -NML to HTML/PlainText for JavaScript by @kawakawaritsuki +## What's this? +NML to HTML/PlainText for JavaScript. -NMLをいろいろと変換するためのnpmパッケージ。 +## How to use? +Install +``` +npm install nml-converter +``` +Use +``` +var NML = require('nml-converter') -このリンクから試せます。 +var novel = new NML("# NML format\nExample!") + +console.log(novel.to("html")) +# or +console.log(novel.to("plain")) +``` + +## Test now! http://writerlighter.github.io/NML-JavaScript/ + +## Contributor +@kawakawaritsuki + +## License + The MIT License (MIT) + +Copyright © 2016 ai-create-team + +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. From d8e7a57bf25ada736bd0e40d9605d223be889ebe Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 18:24:25 +0900 Subject: [PATCH 18/29] [modify] v1.0.0 -> v1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c56928..97d0609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nml-converter", - "version": "1.0.0", + "version": "1.0.1", "description": "NML(Novel Markup Language) converter for js", "main": "nml.js", "scripts": { From 4b70f6df62c8cc85c5e792c8edeb0f5fc43fb069 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 18:27:42 +0900 Subject: [PATCH 19/29] [fix] README title --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 383d982..d0e9ca3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NML-JavaScript +# NML-Converter ## What's this? NML to HTML/PlainText for JavaScript. diff --git a/package.json b/package.json index 97d0609..b9bfab6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nml-converter", - "version": "1.0.1", + "version": "1.0.2", "description": "NML(Novel Markup Language) converter for js", "main": "nml.js", "scripts": { From 0923e94db8090c081eadc820211c26e101734358 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Fri, 20 May 2016 20:29:12 +0900 Subject: [PATCH 20/29] [modify] v1.0.2 -> v1.0.3 --- bower.json | 35 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..81b74c1 --- /dev/null +++ b/bower.json @@ -0,0 +1,35 @@ +{ + "name": "nml-converter", + "version": "1.0.3", + "description": "NML(Novel Markup Language) converter for js", + "main": "nml.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/WriterLighter/NML-JavaScript.git" + }, + "keywords": [ + "nml", + "converter", + "novel", + "markup" + ], + "author": "Ritsuki Goto (http://kawakawaplanning.xyz/)", + "license": "MIT", + "bugs": { + "url": "https://github.com/WriterLighter/NML-JavaScript/issues" + }, + "homepage": "https://github.com/WriterLighter/NML-JavaScript#readme", + "devDependencies": { + "browserify": "^13.0.0", + "coffee-script": "^1.10.0", + "gulp": "^3.9.0", + "gulp-coffee": "^2.3.1", + "gulp-plumber": "^1.1.0", + "gulp-concat": "^2.6.0", + "gulp-watch": "^4.3.5", + "gulp-notify": "^2.2.0" + } +} diff --git a/package.json b/package.json index b9bfab6..81b74c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nml-converter", - "version": "1.0.2", + "version": "1.0.3", "description": "NML(Novel Markup Language) converter for js", "main": "nml.js", "scripts": { From c295dfa160a91af7eeed0f68b6b45c37babc5eee Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Sun, 22 May 2016 21:40:30 +0900 Subject: [PATCH 21/29] [fix] Test url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0e9ca3..31397a2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ console.log(novel.to("plain")) ``` ## Test now! -http://writerlighter.github.io/NML-JavaScript/ +http://AI-create-team.github.io/NML-JavaScript/ ## Contributor @kawakawaritsuki From 5db99b83d0f84edd511de509c03b286e46113510 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Tue, 26 Jul 2016 21:15:54 +0900 Subject: [PATCH 22/29] [fix] README --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31397a2..a52d83a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## What's this? NML to HTML/PlainText for JavaScript. -## How to use? +## How to use Install ``` npm install nml-converter @@ -18,8 +18,17 @@ console.log(novel.to("html")) console.log(novel.to("plain")) ``` +## How to build + +``` +$ npm install +$ bower install +$ gulp +``` + + ## Test now! -http://AI-create-team.github.io/NML-JavaScript/ +http://WriterLighter.github.io/NML-JavaScript/ ## Contributor @kawakawaritsuki From af8ffa521edeecab60a32d375395a73f100c47b3 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Wed, 27 Jul 2016 11:49:28 +0900 Subject: [PATCH 23/29] [fix] Close #10 --- src/nml.coffee | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/nml.coffee b/src/nml.coffee index ad0a389..5efdaf7 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -21,7 +21,9 @@ module.exports = class @NML body = @text.split('\n') body.forEach (@text) -> s = s + checkLine(@text) + '\n' - return '
' + s + '
' + s = checkRemoveDiv('
' + s.substr( 0, s.length-1 ) + '
') + + return s when "plain" mode = 2 s = '' @@ -114,7 +116,6 @@ module.exports = class @NML line #斜体 - checkItalic = (line) -> myRe = /[\__**]{1}.*?[\__**]{1}/g myArray = undefined @@ -211,3 +212,10 @@ module.exports = class @NML if line.match(/[ \s]{3,}$/) line = line + "
" line + + #冗長なdivを削除 + checkRemoveDiv = (line) -> + while (line.match(/
<\/div>/)) + line = line.replace(/
<\/div>/, '') + line + From 5201338390f2d3f0054953f24f8067fa8f1bbe92 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Wed, 27 Jul 2016 11:56:03 +0900 Subject: [PATCH 24/29] [fix] Close #13 --- src/nml.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nml.coffee b/src/nml.coffee index 5efdaf7..e1e9d18 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -21,7 +21,7 @@ module.exports = class @NML body = @text.split('\n') body.forEach (@text) -> s = s + checkLine(@text) + '\n' - s = checkRemoveDiv('
' + s.substr( 0, s.length-1 ) + '
') + s = checkRemoveDiv('
' + s.substr( 0, s.length-1 ) + '
') return s when "plain" @@ -86,7 +86,7 @@ module.exports = class @NML checkNewPage = (line) -> if line.match(/^[-ーis]{3,}$/) if mode is 1 - line = '
' + line = '
' else if mode is 2 line = '' line From ebc5704e08b035de3f5f964be2b813287561c8b6 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Wed, 27 Jul 2016 12:02:27 +0900 Subject: [PATCH 25/29] [fix] Close #12 --- src/nml.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nml.coffee b/src/nml.coffee index e1e9d18..1cce11c 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -21,7 +21,7 @@ module.exports = class @NML body = @text.split('\n') body.forEach (@text) -> s = s + checkLine(@text) + '\n' - s = checkRemoveDiv('
' + s.substr( 0, s.length-1 ) + '
') + s = checkRemoveDiv('
' + s.substr( 0, s.length-1 ) + '
') return s when "plain" @@ -61,7 +61,7 @@ module.exports = class @NML checkReturn = (line) -> if line is '' if mode is 1 - line = '
' + line = '
' line #ルビ @@ -86,7 +86,7 @@ module.exports = class @NML checkNewPage = (line) -> if line.match(/^[-ーis]{3,}$/) if mode is 1 - line = '
' + line = '
' else if mode is 2 line = '' line From 23cd5cd3b3df4ec5b1c86737685cf29022eb6474 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Wed, 27 Jul 2016 12:07:35 +0900 Subject: [PATCH 26/29] [fix] Close #11 --- src/nml.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nml.coffee b/src/nml.coffee index 1cce11c..0521fa8 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -54,7 +54,7 @@ module.exports = class @NML checkSpace = (line) -> if line.match(/^[ \s]/) if mode is 1 - line = '

' + line + '

' + line = '

' + line.substr(1) + '

' line #意味段落 From 0d34b92ed987e1b1a51f8d4494136aa31cf6a596 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Wed, 27 Jul 2016 12:09:52 +0900 Subject: [PATCH 27/29] [fix] Fix #11 --- src/nml.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nml.coffee b/src/nml.coffee index 0521fa8..331587d 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -54,7 +54,7 @@ module.exports = class @NML checkSpace = (line) -> if line.match(/^[ \s]/) if mode is 1 - line = '

' + line.substr(1) + '

' + line = '

' + line.replace(/^[ \s]/,"") + '

' line #意味段落 @@ -98,7 +98,7 @@ module.exports = class @NML if (md = line.match(/^[##]*/)[0]) != '' count = if md.length > 6 then 6 else md.length line = line.replace(/^[##]*/, '') - line = '' + line + '' + line = '' + line.replace(/^[ \s]/,"") + '' else if mode is 2 line = line.replace(/^[##]*/, '') line From 2dcbfac26484db29f53e2f2f71d42dfa0d055433 Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Wed, 27 Jul 2016 12:16:41 +0900 Subject: [PATCH 28/29] [fix] Close #14 --- src/nml.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nml.coffee b/src/nml.coffee index 331587d..5065294 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -30,6 +30,7 @@ module.exports = class @NML body = @text.split('\n') body.forEach (@text) -> s = s + checkLine(@text) + '\n' + s.substr( 0, s.length-1 ) return s else "Error!" @@ -75,11 +76,13 @@ module.exports = class @NML moji = moji.substring(1, moji.length - 1) ruby = text.match(/[\((].*?[\))]/)[0] ruby = ruby.substring(1, ruby.length - 1) - line = line.replace(text, '' + moji + '' + ruby + '') + line = line.replace(text, '' + moji + '' + ruby + '') else moji = text.match(/[\||].*?[\((]/)[0] moji = moji.substring(1, moji.length - 1) - line = line.replace(text, moji) + ruby = text.match(/[\((].*?[\))]/)[0] + ruby = ruby.substring(1, ruby.length - 1) + line = line.replace(text, moji + "(" + ruby + ")") line #改ページ From 41fa874726d1f1a78ac2ab31513f8f5e0eee36bd Mon Sep 17 00:00:00 2001 From: Ritsuki Goto Date: Wed, 27 Jul 2016 23:27:10 +0900 Subject: [PATCH 29/29] [fix] Close #21 --- src/nml.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nml.coffee b/src/nml.coffee index 5065294..03a6a72 100644 --- a/src/nml.coffee +++ b/src/nml.coffee @@ -11,6 +11,8 @@ module.exports = class @NML # 1:html # 2:plain + list_indent = -1 + constructor: (@text) -> to: (t) -> @@ -49,6 +51,7 @@ module.exports = class @NML line = checkPunctuationNumber(line) line = checkPunctuationSymbol(line) line = checkNextLine(line) + line = checkDefinitionList(list) line #形式段落 @@ -218,7 +221,7 @@ module.exports = class @NML #冗長なdivを削除 checkRemoveDiv = (line) -> - while (line.match(/
<\/div>/)) - line = line.replace(/
<\/div>/, '') + while (line.match(/
<\/div>/)) + line = line.replace(/
<\/div>/, '') line