micromark / micromark-extension-directive

micromark extension to support generic directives (`:cite[smith04]`)
https://unifiedjs.com
MIT License
29 stars 16 forks source link

space before directive and a space on the line after causes null exception #1

Closed ChristianMurphy closed 3 years ago

ChristianMurphy commented 3 years ago

Subject of the issue

const micromark = require("micromark");
const directive = require("micromark-extension-directive");
const source = `
  :::i
 `;
micromark(source, "utf-8", {
  extensions: [directive()],
});

throws

micromark/dist/util/slice-chunks.js:11
    view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]
                               ^
TypeError: Cannot read property 'slice' of null

Your environment

Steps to reproduce

run:

const micromark = require("micromark");
const directive = require("micromark-extension-directive");
const source = `
  :::i
 `;
micromark(source, "utf-8", {
  extensions: [directive()],
});

Expected behavior

No error, or a more specific markdown syntax related error

Actual behavior

micromark/dist/util/slice-chunks.js:11
    view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]
                               ^
TypeError: Cannot read property 'slice' of null

or when running micromark/lib

AssertionError [ERR_ASSERTION]: expected non-empty token (`chunkDocument`)