Skip to content

Markdown renderer crashes CMS from 2.9.2 onwards #2440

@cunneen

Description

@cunneen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions