Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

directive inside blockquote with continuation results in error #16

Open
4 tasks done
ChristianMurphy opened this issue Dec 6, 2021 · 0 comments
Open
4 tasks done
Labels
🤞 phase/open Post is being triaged manually

Comments

@ChristianMurphy
Copy link
Member

ChristianMurphy commented Dec 6, 2021

Initial checklist

Affected packages and versions

micrmark-extension-directive 2.1.1

Link to runnable example

https://stackblitz.com/edit/node-4dutob?file=index.js

Steps to reproduce

Run

import { micromark } from "micromark";
import { directive, directiveHtml } from "micromark-extension-directive";

const content = `> :::directive
>
`;

console.log(
  micromark(content, {
    extensions: [directive()],
    htmlExtensions: [directiveHtml],
  })
);

Expected behavior

no error and the html text:

<blockquote>
</blockquote>

Actual behavior

with DEBUG="*"

  micromark main: passing `62` to start +0ms
  micromark enter: `blockQuote` +2ms
  micromark enter: `blockQuotePrefix` +0ms
  micromark enter: `blockQuoteMarker` +0ms
  micromark consume: `62` +0ms
  micromark exit: `blockQuoteMarker` +1ms
  micromark main: passing `32` to after +0ms
  micromark enter: `blockQuotePrefixWhitespace` +0ms
  micromark consume: `32` +0ms
  micromark exit: `blockQuotePrefixWhitespace` +0ms
  micromark exit: `blockQuotePrefix` +0ms
  micromark main: passing `58` to ok +0ms
  micromark main: passing `58` to ok +1ms
  micromark main: passing `58` to containerContinue +0ms
  micromark position: restore: `{"line":1,"column":3,"offset":2,"_index":0,"_bufferIndex":2}` +0ms
  micromark main: passing `58` to flowStart +0ms
  micromark enter: `chunkFlow` +1ms
  micromark consume: `58` +0ms
  micromark main: passing `58` to flowContinue +0ms
  micromark consume: `58` +0ms
  micromark main: passing `58` to flowContinue +0ms
  micromark consume: `58` +0ms
  micromark main: passing `100` to flowContinue +0ms
  micromark consume: `100` +0ms
  micromark main: passing `105` to flowContinue +0ms
  micromark consume: `105` +0ms
  micromark main: passing `114` to flowContinue +0ms
  micromark consume: `114` +0ms
  micromark main: passing `101` to flowContinue +1ms
  micromark consume: `101` +0ms
  micromark main: passing `99` to flowContinue +0ms
  micromark consume: `99` +0ms
  micromark main: passing `116` to flowContinue +0ms
  micromark consume: `116` +0ms
  micromark main: passing `105` to flowContinue +0ms
  micromark consume: `105` +0ms
  micromark main: passing `118` to flowContinue +0ms
  micromark consume: `118` +0ms
  micromark main: passing `101` to flowContinue +0ms
  micromark consume: `101` +0ms
  micromark main: passing `-4` to flowContinue +0ms
  micromark consume: `-4` +0ms
  micromark position: after eol: `{"line":2,"column":1,"offset":15,"_index":1,"_bufferIndex":-1}` +0ms
  micromark exit: `chunkFlow` +0ms
  micromark position: define skip: `{"line":1,"column":3,"offset":2,"_index":0,"_bufferIndex":-1}` +1ms
  micromark main: passing `58` to start +0ms
  micromark position: restore: `{"line":1,"column":3,"offset":2,"_index":0,"_bufferIndex":0}` +0ms
  micromark main: passing `58` to start +0ms
  micromark enter: `directiveContainer` +0ms
  micromark enter: `directiveContainerFence` +0ms
  micromark enter: `directiveContainerSequence` +0ms
  micromark consume: `58` +0ms
  micromark main: passing `58` to sequenceOpen +0ms
  micromark consume: `58` +0ms
  micromark main: passing `58` to sequenceOpen +1ms
  micromark consume: `58` +0ms
  micromark main: passing `100` to sequenceOpen +0ms
  micromark exit: `directiveContainerSequence` +0ms
  micromark enter: `directiveContainerName` +0ms
  micromark consume: `100` +0ms
  micromark main: passing `105` to name +0ms
  micromark consume: `105` +0ms
  micromark main: passing `114` to name +0ms
  micromark consume: `114` +0ms
  micromark main: passing `101` to name +0ms
  micromark consume: `101` +0ms
  micromark main: passing `99` to name +0ms
  micromark consume: `99` +1ms
  micromark main: passing `116` to name +0ms
  micromark consume: `116` +0ms
  micromark main: passing `105` to name +0ms
  micromark consume: `105` +0ms
  micromark main: passing `118` to name +0ms
  micromark consume: `118` +0ms
  micromark main: passing `101` to name +0ms
  micromark consume: `101` +0ms
  micromark main: passing `-4` to name +0ms
  micromark exit: `directiveContainerName` +0ms
  micromark exit: `directiveContainerFence` +0ms
  micromark enter: `lineEnding` +1ms
  micromark consume: `-4` +0ms
  micromark position: after eol: `{"line":2,"column":1,"offset":15,"_index":1,"_bufferIndex":-1}` +0ms
  micromark exit: `lineEnding` +0ms
  micromark main: passing `62` to start +0ms
  micromark enter: `blockQuotePrefix` +0ms
  micromark enter: `blockQuoteMarker` +0ms
  micromark consume: `62` +0ms
  micromark exit: `blockQuoteMarker` +0ms
  micromark main: passing `-4` to after +0ms
  micromark exit: `blockQuotePrefix` +0ms
  micromark main: passing `-4` to ok +1ms
  micromark main: passing `-4` to documentContinue +0ms
  micromark enter: `chunkFlow` +0ms
  micromark consume: `-4` +0ms
  micromark position: after eol: `{"line":3,"column":1,"offset":17,"_index":3,"_bufferIndex":-1}` +0ms
  micromark exit: `chunkFlow` +0ms
  micromark position: define skip: `{"line":2,"column":2,"offset":16,"_index":2,"_bufferIndex":-1}` +0ms
  micromark main: passing `-4` to lineStart +0ms
  micromark main: passing `-4` to contentStart +0ms
  micromark enter: `directiveContainerContent` +0ms
  micromark enter: `directiveContainerFence` +0ms
  micromark enter: `directiveContainerSequence` +0ms
  micromark position: restore: `{"line":2,"column":2,"offset":16,"_index":2,"_bufferIndex":-1}` +1ms
  micromark main: passing `-4` to chunkStart +0ms
  micromark enter: `chunkDocument` +0ms
  micromark enter: `lineEnding` +0ms
  micromark consume: `-4` +0ms
  micromark position: after eol: `{"line":3,"column":1,"offset":17,"_index":2,"_bufferIndex":-1}` +0ms
  micromark exit: `lineEnding` +0ms
  micromark main: passing `null` to start +0ms
  micromark position: restore: `{"line":3,"column":1,"offset":17,"_index":4,"_bufferIndex":-1}` +0ms
  micromark main: passing `null` to nok +0ms
  micromark position: restore: `{"line":3,"column":1,"offset":17,"_index":4,"_bufferIndex":-1}` +0ms
  micromark main: passing `null` to checkNewContainers +0ms
  micromark position: restore: `{"line":3,"column":1,"offset":17,"_index":4,"_bufferIndex":-1}` +0ms
  micromark main: passing `null` to thereIsNoNewContainer +1ms
  micromark main: passing `null` to lineStart +0ms
  micromark position: restore: `{"line":2,"column":2,"offset":16,"_index":2,"_bufferIndex":-1}` +0ms
  micromark main: passing `-4` to lineAfter +0ms

with --conditions=development

/node_modules/uvu/assert/index.mjs:33
	throw new Assertion({ actual, expects, operator, message, details, generated: !msg });
	      ^

Assertion: expected non-empty token (`chunkDocument`)
    at assert (/node_modules/uvu/assert/index.mjs:33:8)
    at ok (/node_modules/uvu/assert/index.mjs:37:2)
    at Object.exit (/node_modules/micromark/dev/lib/create-tokenizer.js:302:5)
    at lineAfter (/node_modules/micromark-extension-directive/dev/lib/directive-container.js:184:23)
    at go (/node_modules/micromark/dev/lib/create-tokenizer.js:218:13)
    at main (/node_modules/micromark/dev/lib/create-tokenizer.js:201:9)
    at Object.write (/node_modules/micromark/dev/lib/create-tokenizer.js:124:5)
    at closeFlow (/node_modules/micromark/dev/lib/initialize/document.js:405:15)
    at flowStart (/node_modules/micromark/dev/lib/initialize/document.js:225:22)
    at thereIsNoNewContainer (/node_modules/micromark/dev/lib/initialize/document.js:192:12) {
  code: 'ERR_ASSERTION',
  details: false,
  generated: false,
  operator: 'ok',
  expects: true,
  actual: false
}

Node.js v17.2.0

and without conditions

/node_modules/micromark/lib/create-tokenizer.js:514
    view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]
                               ^

TypeError: chunks[startIndex].slice is not a function
    at sliceChunks (/node_modules/micromark/lib/create-tokenizer.js:514:32)
    at Object.sliceStream (/node_modules/micromark/lib/create-tokenizer.js:154:12)
    at subcontent (/node_modules/micromark-util-subtokenize/index.js:172:24)
    at subtokenize (/node_modules/micromark-util-subtokenize/index.js:82:30)
    at postprocess (/node_modules/micromark/lib/postprocess.js:11:11)
    at micromark (/node_modules/micromark/index.js:36:7)
    at /test.mjs:9:3
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:331:24)

Node.js v17.2.0

Runtime

Node v16

Package manager

npm v7

OS

Linux

Build and bundle tools

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 phase/open Post is being triaged manually
Development

No branches or pull requests

1 participant