Browse Source

Bump eslint & update CS

pull/570/head
Vitaly Puzrin 6 years ago
parent
commit
c36309ef1c
  1. 2
      .eslintrc.yml
  2. 5
      lib/common/utils.js
  3. 20
      lib/rules_core/replacements.js
  4. 4
      lib/rules_inline/backticks.js
  5. 2
      package.json
  6. 36
      support/demo_template/index.js
  7. 56
      support/specsplit.js
  8. 6
      test/misc.js

2
.eslintrc.yml

@ -28,7 +28,7 @@ rules:
guard-for-in: 2
handle-callback-err: 2
indent: [ 2, 2, { VariableDeclarator: { var: 2, let: 2, const: 3 }, SwitchCase: 1 } ]
indent: [ 2, 2, { VariableDeclarator: { var: 2, let: 2, const: 3 }, SwitchCase: 1, ignoreComments: true } ]
# key-spacing: [ 2, { "align": "value" } ]
keyword-spacing: 2

5
lib/common/utils.js

@ -88,9 +88,8 @@ function replaceEntityPattern(match, name) {
if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
code = name[1].toLowerCase() === 'x' ?
parseInt(name.slice(2), 16)
:
parseInt(name.slice(1), 10);
parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);
if (isValidEntityCode(code)) {
return fromCodePoint(code);
}

20
lib/rules_core/replacements.js

@ -62,16 +62,16 @@ function replace_rare(inlineTokens) {
if (token.type === 'text' && !inside_autolink) {
if (RARE_RE.test(token.content)) {
token.content = token.content
.replace(/\+-/g, '±')
// .., ..., ....... -> …
// but ?..... & !..... -> ?.. & !..
.replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
.replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
// em-dash
.replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
// en-dash
.replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
.replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
.replace(/\+-/g, '±')
// .., ..., ....... -> …
// but ?..... & !..... -> ?.. & !..
.replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
.replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
// em-dash
.replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
// en-dash
.replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
.replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
}
}

4
lib/rules_inline/backticks.js

@ -29,8 +29,8 @@ module.exports = function backtick(state, silent) {
token = state.push('code_inline', 'code', 0);
token.markup = marker;
token.content = state.src.slice(pos, matchStart)
.replace(/\n/g, ' ')
.replace(/^ (.+) $/, '$1');
.replace(/\n/g, ' ')
.replace(/^ (.+) $/, '$1');
}
state.pos = matchEnd;
return true;

2
package.json

@ -38,7 +38,7 @@
"browserify": "^16.3.0",
"chai": "^4.2.0",
"coveralls": "^3.0.4",
"eslint": "^3.5.0",
"eslint": "^6.0.1",
"express": "^4.14.0",
"highlight.js": "^9.2.0",
"istanbul": "^0.4.5",

36
support/demo_template/index.js

@ -130,25 +130,25 @@ function mdInit() {
mdSrc = window.markdownit('commonmark');
} else {
mdHtml = window.markdownit(defaults)
.use(require('markdown-it-abbr'))
.use(require('markdown-it-container'), 'warning')
.use(require('markdown-it-deflist'))
.use(require('markdown-it-emoji'))
.use(require('markdown-it-footnote'))
.use(require('markdown-it-ins'))
.use(require('markdown-it-mark'))
.use(require('markdown-it-sub'))
.use(require('markdown-it-sup'));
.use(require('markdown-it-abbr'))
.use(require('markdown-it-container'), 'warning')
.use(require('markdown-it-deflist'))
.use(require('markdown-it-emoji'))
.use(require('markdown-it-footnote'))
.use(require('markdown-it-ins'))
.use(require('markdown-it-mark'))
.use(require('markdown-it-sub'))
.use(require('markdown-it-sup'));
mdSrc = window.markdownit(defaults)
.use(require('markdown-it-abbr'))
.use(require('markdown-it-container'), 'warning')
.use(require('markdown-it-deflist'))
.use(require('markdown-it-emoji'))
.use(require('markdown-it-footnote'))
.use(require('markdown-it-ins'))
.use(require('markdown-it-mark'))
.use(require('markdown-it-sub'))
.use(require('markdown-it-sup'));
.use(require('markdown-it-abbr'))
.use(require('markdown-it-container'), 'warning')
.use(require('markdown-it-deflist'))
.use(require('markdown-it-emoji'))
.use(require('markdown-it-footnote'))
.use(require('markdown-it-ins'))
.use(require('markdown-it-mark'))
.use(require('markdown-it-sub'))
.use(require('markdown-it-sup'));
}
// Beautify output of parser for html content

56
support/specsplit.js

@ -76,34 +76,34 @@ readFile(options.spec, 'utf8', function (error, input) {
input = input.replace(/→/g, '\t');
markdown.parse(input, {})
.filter(function (token) {
return token.tag === 'code' &&
token.info.trim() === 'example';
})
.forEach(function (token) {
var arr = token.content.split(/^\.\s*?$/m, 2);
var md = arr[0];
var html = arr[1].replace(/^\n/, '');
var result = {
md: md,
html: html,
line: token.map[0],
err: ''
};
try {
if (markdown.render(md) === normalize(html)) {
good.push(result);
} else {
result.err = markdown.render(md);
bad.push(result);
}
} catch (___) {
// bad.push(result);
throw ___;
}
});
.filter(function (token) {
return token.tag === 'code' &&
token.info.trim() === 'example';
})
.forEach(function (token) {
var arr = token.content.split(/^\.\s*?$/m, 2);
var md = arr[0];
var html = arr[1].replace(/^\n/, '');
var result = {
md: md,
html: html,
line: token.map[0],
err: ''
};
try {
if (markdown.render(md) === normalize(html)) {
good.push(result);
} else {
result.err = markdown.render(md);
bad.push(result);
}
} catch (___) {
// bad.push(result);
throw ___;
}
});
if (!options.type) {
console.log(util.format('passed samples - %s, failed samples - %s', good.length, bad.length));

6
test/misc.js

@ -215,9 +215,9 @@ describe('Misc', function () {
it('Should render link target attr', function () {
var md = markdownit()
.use(require('markdown-it-for-inline'), 'target', 'link_open', function (tokens, idx) {
tokens[idx].attrs.push([ 'target', '_blank' ]);
});
.use(require('markdown-it-for-inline'), 'target', 'link_open', function (tokens, idx) {
tokens[idx].attrs.push([ 'target', '_blank' ]);
});
assert.strictEqual(md.render('[foo](bar)'), '<p><a href="bar" target="_blank">foo</a></p>\n');
});

Loading…
Cancel
Save