diff --git a/README.md b/README.md index e845c90..5a798f4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ ## 更新日誌 +### v1.4 + +- 增加 Windows 換行顯示上相容性 + ### v1.31 - 優化判斷式 diff --git a/getReJDocString.js b/getReJDocString.js index ab8e7ed..c6cd5fb 100644 --- a/getReJDocString.js +++ b/getReJDocString.js @@ -3,8 +3,11 @@ * Copyright (c) 2017-Present lisez * All rights reserved. This code is governed by a BSD-style license * that can be found in the LICENSE file. - * version: 1.31 + * version: 1.4 ***********************************************/ +'use strict'; + +/* exported getReJDocString */ /*************************************** * Re-layout ROC Judicial doc to easy reuse style. @@ -12,13 +15,13 @@ ***************************************/ function getReJDocString(input) { - 'use strict'; - if (typeof input === 'undefined'){return null;} var d = input.split('\n'), o = '', term, + // detect OS type + isWin = navigator.platform.toUpperCase().indexOf('WIN')>-1 ? true : false, // breaks rule duelBreaks = function(t){o+="\n"+t+"\n";}, topBreak = function(t){o+="\n"+t;}, @@ -47,7 +50,8 @@ function getReJDocString(input) { regexParagraphMarks = /[,。、]+/, regexFootMarks = /[。:!?]$/, regexClosureMarks = /[\n\r]+([〉》」』】〕〗〙〛,,)\]])/gim, - regexBreakMarks = /^[\n\r]+/gim; + regexBreakMarks = /^[\n\r]+/gim, + regexLineBreak = /\n|\r/gm; for (var i=0; i * All rights reserved. This code is governed by a BSD-style license * that can be found in the LICENSE file. - * version: 1.31 + * version: 1.4 ***********************************************/ +'use strict'; + +/* exported getReJDocString */ /*************************************** * Re-layout ROC Judicial doc to easy reuse style. @@ -12,13 +15,13 @@ ***************************************/ function getReJDocString(input) { - 'use strict'; - if (typeof input === 'undefined'){return null;} var d = input.split('\n'), o = '', term, + // detect OS type + isWin = navigator.platform.toUpperCase().indexOf('WIN')>-1 ? true : false, // breaks rule duelBreaks = function(t){o+="\n"+t+"\n";}, topBreak = function(t){o+="\n"+t;}, @@ -47,7 +50,8 @@ function getReJDocString(input) { regexParagraphMarks = /[\uff0c\u3002\u3001]+/, regexFootMarks = /[\u3002\uff1a\uff01\uff1f]$/, regexClosureMarks = /[\n\r]+([\u3009\u300b\u300d\u300f\u3011\u3015\u3017\u3019\u301b\uff0c,)\]])/gim, - regexBreakMarks = /^[\n\r]+/gim; + regexBreakMarks = /^[\n\r]+/gim, + regexLineBreak = /\n|\r/gm; for (var i=0; i