Atom-beautify: Beautifying markdown with prettier crashes

Created on 6 Mar 2018  路  5Comments  路  Source: Glavin001/atom-beautify

Description

Looks like Prettier is trying to format markdown files with some other syntax, because no matter what markdown I input, it throws an exception. A popup that usually shows for long-running async beautifiers hangs forever.

Actual Output

screen shot 2018-03-06 at 15 54 28

Steps to Reproduce

  1. Create and save a markdown file with any simple contents like:

    # abc
    
    test
    
  2. Set prettier as your default beautifier for markdown, e.g:

"*":
  "atom-beautify":
    general:
      beautifyEntireFileOnSave: false
    markdown:
      default_beautifier: "Prettier"
  1. Run command Atom Beautify: Beautify Editor

Debug

The command does not work and I see this error in Atom's console:

/Users/ak/.atom/packages/atom-beautify/node_modules/prettier/parser-babylon.js:1 Uncaught (in promise) SyntaxError: Unexpected character '#' (1:1)
> 1 | # abc
    | ^
  2 | 
  3 | test
  4 | 
    at createError (/Users/ak/.atom/packages/atom-beautify/node_modules/prettier/parser-babylon.js:1)
    at Object.parse (/Users/ak/.atom/packages/atom-beautify/node_modules/prettier/parser-babylon.js:1)
    at Object.parse$4 [as parse] (/Users/ak/.atom/packages/atom-beautify/node_modules/prettier/index.js:23124)
    at formatWithCursor (/Users/ak/.atom/packages/atom-beautify/node_modules/prettier/index.js:32482)
    at format (/Users/ak/.atom/packages/atom-beautify/node_modules/prettier/index.js:32527)
    at Object.format (/Users/ak/.atom/packages/atom-beautify/node_modules/prettier/index.js:32787)
    at prettier.coffee [sm]:10

screen shot 2018-03-06 at 16 02 54

Checklist

I have:

  • [x] Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [x] Reloaded (or restarted) Atom to ensure it is not a caching issue
  • [x] Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [x] Filled out the Input, Expected, and Actual sections above or have edited/removed them in a way that fully describes the issue.
  • [x] Generated debugging information by executing Atom Beautify: Help Debug Editor command in Atom and added link for debug.md Gist to this issue

cc @szeck87

bug high priority published

Most helpful comment

That's not good, I have a fix in #2071.

All 5 comments

That's not good, I have a fix in #2071.

Thanks for reporting, @kachkaev !

Prettier is not the default Markdown beautifier, right? This only happens for users who manually switched to Prettier?

Yep.

Published to v0.32.2

Getting the same error in 0.33.4.

Uncaught (in promise) SyntaxError: Unexpected character '#' (1:2)
> 1 | # Variant
    |  ^
  2 | 
  3 | Format Version v1.0.0
  4 | 
    at t (/Users/sb/.atom/packages/atom-beautify/node_modules/prettier/parser-babylon.js:1:419)
    at Object.d [as parse] (/Users/sb/.atom/packages/atom-beautify/node_modules/prettier/parser-babylon.js:1:188061)
    at Object.parse$2 [as parse] (/Users/sb/.atom/packages/atom-beautify/node_modules/prettier/index.js:7138:19)
    at coreFormat (/Users/sb/.atom/packages/atom-beautify/node_modules/prettier/index.js:10398:23)
    at format (/Users/sb/.atom/packages/atom-beautify/node_modules/prettier/index.js:10570:16)
    at formatWithCursor (/Users/sb/.atom/packages/atom-beautify/node_modules/prettier/index.js:10582:12)
    at /Users/sb/.atom/packages/atom-beautify/node_modules/prettier/index.js:34924:15
    at Object.format (/Users/stephen.bush/.atom/packages/atom-beautify/node_modules/prettier/index.js:34943:12)
    at /Users/sb/.atom/packages/atom-beautify/src/beautifiers/prettier.coffee:42:29
    at <anonymous>
Was this page helpful?
0 / 5 - 0 ratings