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

Example from documentation crashes with TypeError #132

Open
tolmasky opened this issue Dec 1, 2018 · 4 comments
Open

Example from documentation crashes with TypeError #132

tolmasky opened this issue Dec 1, 2018 · 4 comments

Comments

@tolmasky
Copy link

tolmasky commented Dec 1, 2018

This example currently breaks with

TypeError: Expected Array or iterable object of values: [object Object]

RunKit Link showing full stack trace

const { State } = require('markup-it');
const markdown = require('markup-it/lib/markdown');

const state = State.create(markdown);
const document = state.deserializeToDocument('Hello **World**');

I've tried with [email protected] and [email protected], and @gitbook/[email protected] and @gitbook/[email protected].

@tageecc
Copy link

tageecc commented Dec 11, 2018

the same to me, any updates? @tolmasky

@tolmasky
Copy link
Author

I've not gotten it to work. Sticking with remark for now, but want to eventually switch to markup-it for template support.

@MartinSadovy
Copy link

Hi, I would like to try this compiler (and then add support for textile (JIRA format)). But I got stuck on this error.
Is there any progress? @Soreine

@jspdown
Copy link

jspdown commented Apr 24, 2019

@tolmasky Indeed, it doesn't work.

markup-it/lib/markdown is using ES6 Modules:

import block from './blocks';
import inline from './inlines';
import document from './document';

export default {
    document: [document],
    inline,
    block
};

Once converted by Babel into CommonJS, the exported object becomes:

{
   "default": {
      "document": ...,
      "inline": ...,
      "block": ...
   }
}

So, in order to make it works you can either replace State.create(markdown) by State.create(markdown.default) or use ES6 modules:

import { State } from 'markup-it'
import markdown from 'markup-it/lib/markdown'
import { Map, List } from 'immutable'

const state = State.create(markdown);
const doc = state.deserializeToDocument('Hello **World**');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants