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

Markdown renderer crashes CMS from 2.9.2 onwards #2440

Closed
cunneen opened this issue Jul 12, 2019 · 6 comments
Closed

Markdown renderer crashes CMS from 2.9.2 onwards #2440

cunneen opened this issue Jul 12, 2019 · 6 comments

Comments

@cunneen
Copy link

cunneen commented Jul 12, 2019

Describe the bug
The Markdown renderer crashes the CMS in some cases, from netlify-cms@2.9.2 upwards (currently 2.9.6), but doesn't in 2.9.1

I can reliably reproduce the issue by adding a newline and an image reference, see attached screen recording.

To Reproduce

config.yml

backend:
  name: test-repo

media_folder: "site/static/img"
public_folder: "/img" 
site_url: "https://example.com"
logo_url: "https://placekitten.com/200/200"

collections:
  - name: "post" 
    label: "Blog Posts" # Used in the UI
    label_singular: "Blog Post"
    description: "Articles"
    folder: "site/content/post"
    create: true 
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    fields: 
      - {label: "Layout", name: "layout", widget: "hidden", default: "post"}
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Publish Date", name: "date", widget: "datetime"}
      - {label: "Body", name: "body", widget: "markdown"}

admin/index.html

<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Content Manager</title>
</head>
<body>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script src="https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js"></script>
</body>
</html>

Then create a new item in the collection with the following markdown including ONE newline above the image (GitHub seems to strip the newline):


![Kitty Cat](https://placekitten.com/640/480)

One newline above seems to trigger the error, while zero or two newlines does not.

The error is:

"Error: Incorrectly eaten value: please report this warning on http://git.io/vg5Ft
    at https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:275:1183
    at E (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:275:1276)
    at s.<anonymous> (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:802:28196)
    at s.tokenizeBlock (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:275:358)
    at s.e.exports [as parse] (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:289:217)
    at Function.E.parse (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:240:11556)
    at T (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:65:85083)
    at t.markdownToHtml (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:65:85779)
    at l (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:802:69937)
    at Jo (https://unpkg.com/netlify-cms@2.9.6/dist/netlify-cms.js:151:53042)"

Expected behavior

Cute kitten shown.

Screenshots

(Screen recording will load below):

netlify-cms-markdown-bug

(screen recording will load above)

Applicable Versions:

  • Netlify CMS version: 2.9.2 upwards
  • Git provider: n/a
  • OS: macOS
  • Browser version: chrome (75.0.3770.100 (Official Build) (64-bit)) and safari 12.1.1 (14607.2.6.1.1)
  • Node.JS version: v8.16.0

CMS configuration
See above

Additional context
See above

@marcojakob
Copy link

Looks like the same as #2421. Should also be resolved by #2402, I guess.

@cunneen
Copy link
Author

cunneen commented Jul 12, 2019

Damn sorry @marcojakob , I did search but didn't see #2421. It does look the same. I'll add a comment to #2421 with my workaround (i.e. downgrade) and close this as a duplicate of #2421.

@erquhart
Copy link
Contributor

Interesting, I found a newline following frontmatter to crash the CMS as far back as I could go, well before 2.0. Are you certain it worked in 2.9.1?

Sent with GitHawk

@cunneen
Copy link
Author

cunneen commented Jul 13, 2019

@erquhart I'm referring to a newline within the markdown body. It sounds like your issue is slightly different. Yes, downgrading to 2.9.1 reliably fixes my issue (and presumably @marcojakob's). See the screen recording above.

@erquhart
Copy link
Contributor

We're referring to the same issue, a newline following the frontmatter. I fixed it just recently for a post in the Gatsby starter: decaporg/gatsby-starter-decap-cms@a1d1830

Sent with GitHawk

@erquhart
Copy link
Contributor

You can try it in the demo from 2.9.1: https://5cae562f07575f0008d96910--cms-demo.netlify.com/#/collections/posts/new

Sent with GitHawk

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

No branches or pull requests

3 participants