diff --git a/node/utils/ExportDokuWiki.js b/node/utils/ExportDokuWiki.js index 48e4b2915..395b4b3c8 100644 --- a/node/utils/ExportDokuWiki.js +++ b/node/utils/ExportDokuWiki.js @@ -1,12 +1,12 @@ /** * Copyright 2011 Adrian Lang - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS-IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ function getPadDokuWiki(pad, revNum, callback) function (callback) { - if (revNum != undefined) + if (revNum) { pad.getInternalRevisionAText(revNum, function (err, revisionAtext) { @@ -122,6 +122,8 @@ function getDokuWikiFromAtext(pad, atext) var iter = Changeset.opIterator(Changeset.subattribution(attribs, idx, idx + numChars)); idx += numChars; + var i; + while (iter.hasNext()) { var o = iter.next(); @@ -142,7 +144,7 @@ function getDokuWikiFromAtext(pad, atext) } } }); - for (var i = 0; i < propVals.length; i++) + for (i = 0; i < propVals.length; i++) { if (propVals[i] === true) { @@ -160,7 +162,7 @@ function getDokuWikiFromAtext(pad, atext) { // leaving bold (e.g.) also leaves italics, etc. var left = false; - for (var i = 0; i < propVals.length; i++) + for (i = 0; i < propVals.length; i++) { var v = propVals[i]; if (!left) @@ -179,7 +181,7 @@ function getDokuWikiFromAtext(pad, atext) } } - for (var i = propVals.length - 1; i >= 0; i--) + for (i = propVals.length - 1; i >= 0; i--) { if (propVals[i] === LEAVE) { @@ -191,7 +193,7 @@ function getDokuWikiFromAtext(pad, atext) emitCloseTag(i); } } - for (var i = 0; i < propVals.length; i++) + for (i = 0; i < propVals.length; i++) { if (propVals[i] === ENTER || propVals[i] === STAY) { @@ -210,7 +212,7 @@ function getDokuWikiFromAtext(pad, atext) assem.append(_escapeDokuWiki(s)); } // end iteration over spans in line - for (var i = propVals.length - 1; i >= 0; i--) + for (i = propVals.length - 1; i >= 0; i--) { if (propVals[i]) { @@ -310,7 +312,7 @@ exports.getPadDokuWikiDocument = function (padId, revNum, callback) getPadDokuWiki(pad, revNum, callback); }); -} +}; function _escapeDokuWiki(s) { @@ -321,7 +323,7 @@ function _escapeDokuWiki(s) // copied from ACE var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/; var _REGEX_SPACE = /\s/; -var _REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#;()$]/.source + '|' + _REGEX_WORDCHAR.source + ')'); +var _REGEX_URLCHAR = new RegExp('(' + (/[\-:@a-zA-Z0-9_.,~%+\/\\?=&#;()$]/).source + '|' + _REGEX_WORDCHAR.source + ')'); var _REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt):\/\/|mailto:)/.source + _REGEX_URLCHAR.source + '*(?![:.,;])' + _REGEX_URLCHAR.source, 'g'); // returns null if no URLs, or [[startIndex1, url1], [startIndex2, url2], ...]