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

Cannot read property 'type' of undefined #300

Closed
jtppragg opened this issue Nov 15, 2020 · 6 comments
Closed

Cannot read property 'type' of undefined #300

jtppragg opened this issue Nov 15, 2020 · 6 comments

Comments

@jtppragg
Copy link

I am trying to use markdown-it-footnote from marp-cli but I always get the following error message:

Cannot read property 'type' of undefined

Here there is my engine.js code:

const { Marp } = require('@marp-team/marp-core')

module.exports = (opts) => new Marp(opts)
        .use(require('markdown-it-container'), 'columns')
        .use(require('markdown-it-footnote'))
        .use(require('markdown-it-mark'))

I use several markdown-it plugins, but the error only appears when enabling markdown-it-footnote. However this plugin has online demo working as expected, so I guess the error could be related to marp ...

Thanks!

@yhatt
Copy link
Member

yhatt commented Nov 16, 2020

I've tried to use same plugins with exactly same engine.js but I cannot reproduce that. At least there are no problem in both of the latest markdown-it-footnote and Marp CLI. Please share procedure to reproduce.

However, some markdown-it plugins may not work as you expected because the most of these plugins are not designed for Marp. markdown-it-footnote is the most mentioned plugin as not working as user expected (#226). Even if it's worked by fixing that error, footnotes would not render as you expected. (markdown-it/markdown-it-footnote#38)

We always recommend to develop Marp (Marpit) specific plugin like marp(it)-footnote. (https://marpit-api.marp.app/)

@jtppragg
Copy link
Author

Thank you for pointing me out the known compatibility problems between this plugin and marp. Anyway I would like to give it a chance. My error happens only when using footnotes in the markdown, for instance using the example code provided with the documentation:

Here is a footnote reference,[^1] and another.[^longnote]

[^1]: Here is the footnote.

[^longnote]: Here's one with multiple blocks.

    Subsequent paragraphs are indented to show that they
belong to the previous footnote.

If I leave the plugin in engine.js but don't use footnotes in the markdown there is no error message.

Thanks!

@jtppragg
Copy link
Author

Just in case this is useful for anyone, I have achieved the desired behavior following @yhatt's suggestion here #226 (comment) using markdown-it-container as a footnote block and defining this style:

section .note {
  position: absolute;
  left: 70px;
  right: 70px;
  bottom: 50px;
  border-top: 1px solid lightgray;
  padding-top: 5px;
  font-size: 0.5em;
  text-align: left;
}

@yhatt
Copy link
Member

yhatt commented Nov 16, 2020

Still cannot reproduce. I've tried following the procedure in below but I have no errors.

npm i @marp-team/marp-cli @marp-team/marp-core markdown-it-container markdown-it-footnote markdown-it-mark
npx marp --engine ./engine.js slide.md

engine.js

const { Marp } = require('@marp-team/marp-core')

module.exports = (opts) =>
  new Marp(opts)
    .use(require('markdown-it-container'), 'columns')
    .use(require('markdown-it-footnote'))
    .use(require('markdown-it-mark'))

slide.md

Here is a footnote reference,[^1] and another.[^longnote]

[^1]: Here is the footnote.

[^longnote]: Here's one with multiple blocks.

    Subsequent paragraphs are indented to show that they
belong to the previous footnote.
  • node version: v12.18.2
  • OS: macOS Big Sur 11.0.1

@jtppragg
Copy link
Author

jtppragg commented Nov 16, 2020

Try with this slide.md instead, I guess the problem is related to enabling a footer:

---
footer: the footer
---

Here is a footnote reference,[^1] and another.[^longnote]

[^1]: Here is the footnote.

[^longnote]: Here's one with multiple blocks.

    Subsequent paragraphs are indented to show that they
belong to the previous footnote.

In any case the footnotes appear in the last slide instead of the current slide as desired, so I will continue with this workaround instead: #300 (comment)

Thank you!

@yhatt
Copy link
Member

yhatt commented Nov 16, 2020

OK. This report shows the footnote plugin designed for Marp(it) should be responsible dealing with Marpit footer. It would be helpful information for plugin developer.

Of course, should not expect Marp support for the plugin designed just for markdown-it.

@yhatt yhatt closed this as completed Nov 16, 2020
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

2 participants