diff --git a/lib/common/html_re.js b/lib/common/html_re.js index 4fd9369..c7d9a4f 100644 --- a/lib/common/html_re.js +++ b/lib/common/html_re.js @@ -2,27 +2,27 @@ 'use strict'; -var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*'; +var attrName = '[a-zA-Z_:][a-zA-Z0-9:._-]*'; var unquoted = '[^"\'=<>`\\x00-\\x20]+'; -var single_quoted = "'[^']*'"; -var double_quoted = '"[^"]*"'; +var singleQuoted = "'[^']*'"; +var doubleQuoted = '"[^"]*"'; -var attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')'; +var attrValue = '(?:' + unquoted + '|' + singleQuoted + '|' + doubleQuoted + ')'; -var attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)'; +var attribute = '(?:\\s+' + attrName + '(?:\\s*=\\s*' + attrValue + ')?)'; -var open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'; +var openTag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'; -var close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'; +var closeTag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'; var comment = '|'; var processing = '<[?].*?[?]>'; var declaration = ']*>'; var cdata = ''; -var HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment + +var HTML_TAG_RE = new RegExp('^(?:' + openTag + '|' + closeTag + '|' + comment + '|' + processing + '|' + declaration + '|' + cdata + ')'); -var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')'); +var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + openTag + '|' + closeTag + ')'); module.exports.HTML_TAG_RE = HTML_TAG_RE; module.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE; diff --git a/lib/renderer.js b/lib/renderer.js index ae3a155..6376a37 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -15,20 +15,20 @@ var escapeHtml = require('./common/utils').escapeHtml; //////////////////////////////////////////////////////////////////////////////// -var default_rules = {}; +var defaultRules = {}; -default_rules.code_inline = function (tokens, idx /*, options, env */) { +defaultRules.code_inline = function (tokens, idx /*, options, env */) { return '' + escapeHtml(tokens[idx].content) + ''; }; -default_rules.code_block = function (tokens, idx /*, options, env */) { +defaultRules.code_block = function (tokens, idx /*, options, env */) { return '
' + escapeHtml(tokens[idx].content) + '
\n'; }; -default_rules.fence = function (tokens, idx, options, env, slf) { +defaultRules.fence = function (tokens, idx, options, env, slf) { var token = tokens[idx], info = token.info ? unescapeAll(token.info).trim() : '', langName = '', @@ -55,7 +55,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) { }; -default_rules.image = function (tokens, idx, options, env, slf) { +defaultRules.image = function (tokens, idx, options, env, slf) { var token = tokens[idx]; // "alt" attr MUST be set, even if empty. Because it's mandatory and @@ -70,23 +70,23 @@ default_rules.image = function (tokens, idx, options, env, slf) { }; -default_rules.hardbreak = function (tokens, idx, options /*, env */) { +defaultRules.hardbreak = function (tokens, idx, options /*, env */) { return options.xhtmlOut ? '
\n' : '
\n'; }; -default_rules.softbreak = function (tokens, idx, options /*, env */) { +defaultRules.softbreak = function (tokens, idx, options /*, env */) { return options.breaks ? (options.xhtmlOut ? '
\n' : '
\n') : '\n'; }; -default_rules.text = function (tokens, idx /*, options, env */) { +defaultRules.text = function (tokens, idx /*, options, env */) { return escapeHtml(tokens[idx].content); }; -default_rules.html_block = function (tokens, idx /*, options, env */) { +defaultRules.html_block = function (tokens, idx /*, options, env */) { return tokens[idx].content; }; -default_rules.html_inline = function (tokens, idx /*, options, env */) { +defaultRules.html_inline = function (tokens, idx /*, options, env */) { return tokens[idx].content; }; @@ -117,7 +117,7 @@ function Renderer() { * Each rule is called as independed static function with fixed signature: * * ```javascript - * function my_token_render(tokens, idx, options, env, renderer) { + * function myTokenRender(tokens, idx, options, env, renderer) { * // ... * return renderedHTML; * } @@ -126,7 +126,7 @@ function Renderer() { * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js) * for more details and examples. **/ - this.rules = assign({}, default_rules); + this.rules = assign({}, defaultRules); } diff --git a/lib/rules_block/html_block.js b/lib/rules_block/html_block.js index abef36d..a5b16b1 100644 --- a/lib/rules_block/html_block.js +++ b/lib/rules_block/html_block.js @@ -3,7 +3,7 @@ 'use strict'; -var block_names = require('../common/html_blocks'); +var blockNames = require('../common/html_blocks'); var HTML_OPEN_CLOSE_TAG_RE = require('../common/html_re').HTML_OPEN_CLOSE_TAG_RE; // An array of opening and corresponding closing sequences for html tags, @@ -15,12 +15,12 @@ var HTML_SEQUENCES = [ [ /^<\?/, /\?>/, true ], [ /^/, true ], [ /^/, true ], - [ new RegExp('^|$))', 'i'), /^$/, true ], + [ new RegExp('^|$))', 'i'), /^$/, true ], [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ] ]; -module.exports = function html_block(state, startLine, endLine, silent) { +module.exports = function htmlBlock(state, startLine, endLine, silent) { var i, nextLine, token, lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; diff --git a/lib/rules_block/state_block.js b/lib/rules_block/state_block.js index f08bdb2..774037b 100644 --- a/lib/rules_block/state_block.js +++ b/lib/rules_block/state_block.js @@ -7,7 +7,7 @@ var isSpace = require('../common/utils').isSpace; function StateBlock(src, md, env, tokens) { - var ch, s, start, pos, len, indent, offset, indent_found; + var ch, s, start, pos, len, indent, offset, indentFound; this.src = src; @@ -44,12 +44,12 @@ function StateBlock(src, md, env, tokens) { // Create caches // Generate markers. s = this.src; - indent_found = false; + indentFound = false; for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) { ch = s.charCodeAt(pos); - if (!indent_found) { + if (!indentFound) { if (isSpace(ch)) { indent++; @@ -60,7 +60,7 @@ function StateBlock(src, md, env, tokens) { } continue; } else { - indent_found = true; + indentFound = true; } } @@ -71,7 +71,7 @@ function StateBlock(src, md, env, tokens) { this.tShift.push(indent); this.sCount.push(offset); - indent_found = false; + indentFound = false; indent = 0; offset = 0; start = pos + 1; diff --git a/lib/rules_core/replacements.js b/lib/rules_core/replacements.js index bcdf5a9..a796220 100644 --- a/lib/rules_core/replacements.js +++ b/lib/rules_core/replacements.js @@ -33,7 +33,7 @@ function replaceFn(match, name) { return SCOPED_ABBR[name.toLowerCase()]; } -function replace_scoped(inlineTokens) { +function replaceScoped(inlineTokens) { var i, token; for (i = inlineTokens.length - 1; i >= 0; i--) { @@ -44,7 +44,7 @@ function replace_scoped(inlineTokens) { } } -function replace_rare(inlineTokens) { +function replaceRare(inlineTokens) { var i, token; for (i = inlineTokens.length - 1; i >= 0; i--) { @@ -78,11 +78,11 @@ module.exports = function replace(state) { if (state.tokens[blkIdx].type !== 'inline') { continue; } if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) { - replace_scoped(state.tokens[blkIdx].children); + replaceScoped(state.tokens[blkIdx].children); } if (RARE_RE.test(state.tokens[blkIdx].content)) { - replace_rare(state.tokens[blkIdx].children); + replaceRare(state.tokens[blkIdx].children); } } diff --git a/lib/rules_core/smartquotes.js b/lib/rules_core/smartquotes.js index e599990..4665479 100644 --- a/lib/rules_core/smartquotes.js +++ b/lib/rules_core/smartquotes.js @@ -16,7 +16,7 @@ function replaceAt(str, index, ch) { return str.substr(0, index) + ch + str.substr(index + 1); } -function process_inlines(tokens, state) { +function processInlines(tokens, state) { var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, canOpen, canClose, j, isSingle, stack, openQuote, closeQuote; @@ -188,6 +188,6 @@ module.exports = function smartquotes(state) { continue; } - process_inlines(state.tokens[blkIdx].children, state); + processInlines(state.tokens[blkIdx].children, state); } }; diff --git a/lib/rules_inline/emphasis.js b/lib/rules_inline/emphasis.js index fa26e61..696c1d6 100644 --- a/lib/rules_inline/emphasis.js +++ b/lib/rules_inline/emphasis.js @@ -50,8 +50,8 @@ module.exports.tokenize = function emphasis(state, silent) { // Boolean flags that determine if this delimiter could open or close // an emphasis. // - open: scanned.can_open, - close: scanned.can_close + open: scanned.canOpen, + close: scanned.canClose }); } diff --git a/lib/rules_inline/state_inline.js b/lib/rules_inline/state_inline.js index 2847496..0797682 100644 --- a/lib/rules_inline/state_inline.js +++ b/lib/rules_inline/state_inline.js @@ -67,11 +67,11 @@ StateInline.prototype.push = function (type, tag, nesting) { // - canSplitWord - determine if these markers can be found inside a word // StateInline.prototype.scanDelims = function (start, canSplitWord) { - var pos = start, lastChar, nextChar, count, can_open, can_close, + var pos = start, lastChar, nextChar, count, canOpen, canClose, isLastWhiteSpace, isLastPunctChar, isNextWhiteSpace, isNextPunctChar, - left_flanking = true, - right_flanking = true, + leftFlanking = true, + rightFlanking = true, max = this.posMax, marker = this.src.charCodeAt(start); @@ -92,32 +92,32 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) { isNextWhiteSpace = isWhiteSpace(nextChar); if (isNextWhiteSpace) { - left_flanking = false; + leftFlanking = false; } else if (isNextPunctChar) { if (!(isLastWhiteSpace || isLastPunctChar)) { - left_flanking = false; + leftFlanking = false; } } if (isLastWhiteSpace) { - right_flanking = false; + rightFlanking = false; } else if (isLastPunctChar) { if (!(isNextWhiteSpace || isNextPunctChar)) { - right_flanking = false; + rightFlanking = false; } } if (!canSplitWord) { - can_open = left_flanking && (!right_flanking || isLastPunctChar); - can_close = right_flanking && (!left_flanking || isNextPunctChar); + canOpen = leftFlanking && (!rightFlanking || isLastPunctChar); + canClose = rightFlanking && (!leftFlanking || isNextPunctChar); } else { - can_open = left_flanking; - can_close = right_flanking; + canOpen = leftFlanking; + canClose = rightFlanking; } return { - can_open: can_open, - can_close: can_close, + canOpen: canOpen, + canClose: canClose, length: count }; }; diff --git a/lib/rules_inline/strikethrough.js b/lib/rules_inline/strikethrough.js index 0347241..fb60f8a 100644 --- a/lib/rules_inline/strikethrough.js +++ b/lib/rules_inline/strikethrough.js @@ -36,8 +36,8 @@ module.exports.tokenize = function strikethrough(state, silent) { token: state.tokens.length - 1, level: state.level, end: -1, - open: scanned.can_open, - close: scanned.can_close + open: scanned.canOpen, + close: scanned.canClose }); }