Browse Source

better check for property 'references' in js object

fix for javascript error 'Cannot read property "references" from
undefined'
pull/353/head
kos 8 years ago
parent
commit
ffd3f25147
  1. 4
      lib/rules_block/reference.js
  2. 2
      lib/rules_inline/image.js
  3. 2
      lib/rules_inline/link.js

4
lib/rules_block/reference.js

@ -183,7 +183,9 @@ module.exports = function reference(state, startLine, _endLine, silent) {
// Reference can not terminate anything. This check is for safety only.
/*istanbul ignore if*/
if (silent) { return true; }
if (typeof state.env === 'undefined') {
state.env = {};
}
if (typeof state.env.references === 'undefined') {
state.env.references = {};
}

2
lib/rules_inline/image.js

@ -95,7 +95,7 @@ module.exports = function image(state, silent) {
//
// Link reference
//
if (typeof state.env.references === 'undefined') { return false; }
if (typeof state.env === 'undefined' || typeof state.env.references === 'undefined') { return false; }
if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
start = pos + 1;

2
lib/rules_inline/link.js

@ -98,7 +98,7 @@ module.exports = function link(state, silent) {
//
// Link reference
//
if (typeof state.env.references === 'undefined') { return false; }
if (typeof state.env === 'undefined' || typeof state.env.references === 'undefined') { return false; }
if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
start = pos + 1;

Loading…
Cancel
Save