Browse Source

deps update, configs & code cleanup

pull/148/head
Vitaly Puzrin 9 years ago
parent
commit
bf424c8a49
  1. 2
      .eslintrc
  2. 10
      .npmignore
  3. 2
      README.md
  4. 4
      lib/index.js
  5. 2
      lib/presets/commonmark.js
  6. 2
      lib/presets/default.js
  7. 2
      lib/presets/zero.js
  8. 10
      lib/renderer.js
  9. 14
      package.json
  10. 8
      support/demo_template/index.js
  11. 2
      test/misc.js

2
.eslintrc

@ -99,7 +99,7 @@ rules:
quotes: [ 2, single, avoid-escape ]
radix: 2
semi: 2
space-after-keywords: [ 2, always, , { "checkFunctionKeyword": true } ]
space-after-keywords: [ 2, always ]
space-before-blocks: 2
space-in-brackets: [ 2, always, { propertyName: false } ]
space-in-parens: [ 2, never ]

10
.npmignore

@ -1,10 +0,0 @@
benchmark/
coverage/
demo/
docs/
apidoc/
support/
test/
Makefile
.*
*.log

2
README.md

@ -2,7 +2,7 @@
[![Build Status](https://img.shields.io/travis/markdown-it/markdown-it/master.svg?style=flat)](https://travis-ci.org/markdown-it/markdown-it)
[![NPM version](https://img.shields.io/npm/v/markdown-it.svg?style=flat)](https://www.npmjs.org/package/markdown-it)
[![Coverage Status](https://img.shields.io/coveralls/markdown-it/markdown-it/master.svg?style=flat)](https://coveralls.io/r/markdown-it/markdown-it?branch=master)
[![Coverage Status](https://coveralls.io/repos/markdown-it/markdown-it/badge.svg?branch=master&service=github)](https://coveralls.io/github/markdown-it/markdown-it?branch=master)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/markdown-it/markdown-it)
> Markdown parser done right. Fast and easy to extend.

4
lib/index.js

@ -57,7 +57,7 @@ function normalizeLink(url) {
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toASCII(parsed.hostname);
} catch(er) {}
} catch (er) { /**/ }
}
}
@ -77,7 +77,7 @@ function normalizeLinkText(url) {
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toUnicode(parsed.hostname);
} catch(er) {}
} catch (er) { /**/ }
}
}

2
lib/presets/commonmark.js

@ -19,7 +19,7 @@ module.exports = {
//
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
quotes: '\u201c\u201d\u2018\u2019' /* “”‘’ */,
quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
// Highlighter function. Should return escaped HTML,
// or '' if input not changed

2
lib/presets/default.js

@ -19,7 +19,7 @@ module.exports = {
//
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
quotes: '\u201c\u201d\u2018\u2019' /* “”‘’ */,
quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
// Highlighter function. Should return escaped HTML,
// or '' if input not changed

2
lib/presets/zero.js

@ -20,7 +20,7 @@ module.exports = {
//
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
quotes: '\u201c\u201d\u2018\u2019' /* “”‘’ */,
quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
// Highlighter function. Should return escaped HTML,
// or '' if input not changed

10
lib/renderer.js

@ -28,7 +28,7 @@ default_rules.code_block = function (tokens, idx /*, options, env */) {
};
default_rules.fence = function (tokens, idx, options, env, self) {
default_rules.fence = function (tokens, idx, options, env, slf) {
var token = tokens[idx],
info = token.info ? unescapeAll(token.info).trim() : '',
langName = '',
@ -45,13 +45,13 @@ default_rules.fence = function (tokens, idx, options, env, self) {
highlighted = escapeHtml(token.content);
}
return '<pre><code' + self.renderAttrs(token) + '>'
return '<pre><code' + slf.renderAttrs(token) + '>'
+ highlighted
+ '</code></pre>\n';
};
default_rules.image = function (tokens, idx, options, env, self) {
default_rules.image = function (tokens, idx, options, env, slf) {
var token = tokens[idx];
// "alt" attr MUST be set, even if empty. Because it's mandatory and
@ -60,9 +60,9 @@ default_rules.image = function (tokens, idx, options, env, self) {
// Replace content with actual value
token.attrs[token.attrIndex('alt')][1] =
self.renderInlineAsText(token.children, options, env);
slf.renderInlineAsText(token.children, options, env);
return self.renderToken(tokens, idx, options);
return slf.renderToken(tokens, idx, options);
};

14
package.json

@ -17,6 +17,12 @@
"scripts": {
"test": "make test"
},
"files": [
"index.js",
"bin/",
"lib/",
"dist/"
],
"dependencies": {
"argparse": "~1.0.2",
"entities": "~1.1.1",
@ -29,10 +35,10 @@
"autoprefixer-stylus": "~0.5.0",
"benchmark": "~1.0.0",
"browserify": "*",
"chai": "^2.2.0",
"commonmark": "~0.18.1",
"chai": "^3.2.0",
"commonmark": "~0.21.0",
"coveralls": "~2.11.2",
"eslint": "0.13.0",
"eslint": "0.24.0",
"eslint-plugin-nodeca": "^1.0.0",
"istanbul": "*",
"jade": "~1.9.2",
@ -47,7 +53,7 @@
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"markdown-it-testgen": "~0.1.3",
"marked": "0.3.3",
"marked": "0.3.5",
"stylus": "~0.50.0",
"mocha": "*",
"uglify-js": "*"

8
support/demo_template/index.js

@ -28,12 +28,12 @@ defaults.highlight = function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) {}
} catch (__) { /**/ }
}
try {
return hljs.highlightAuto(str).value;
} catch (__) {}
} catch (__) { /**/ }
return '';
};
@ -95,14 +95,14 @@ function mdInit() {
//
// - We track only headings and paragraphs on first level. That's enough.
// - Footnotes content causes jumps. Level limit filter it automatically.
function injectLineNumbers(tokens, idx, options, env, self) {
function injectLineNumbers(tokens, idx, options, env, slf) {
var line;
if (tokens[idx].map && tokens[idx].level === 0) {
line = tokens[idx].map[0];
tokens[idx].attrPush([ 'class', 'line' ]);
tokens[idx].attrPush([ 'data-line', String(line) ]);
}
return self.renderToken(tokens, idx, options, env, self);
return slf.renderToken(tokens, idx, options, env, slf);
}
mdHtml.renderer.rules.paragraph_open = mdHtml.renderer.rules.heading_open = injectLineNumbers;

2
test/misc.js

@ -32,7 +32,7 @@ describe('API', function () {
it('plugin', function () {
var succeeded = false;
function plugin(self, opts) { if (opts === 'bar') { succeeded = true; } }
function plugin(slf, opts) { if (opts === 'bar') { succeeded = true; } }
var md = markdownit();

Loading…
Cancel
Save