prettier-emacs icon indicating copy to clipboard operation
prettier-emacs copied to clipboard

Unable to run in the org mode source code block

Open kkweon opened this issue 6 years ago • 4 comments

Steps to reproduce

  1. Create any org file temp.org
  2. Create a source code block
#+BEGIN_SRC js
  const a = {
    data: [],
    nextOffset: 1
  }
#+END_SRC
  1. Edit and run prettier-js
prettier errors:
[error] No parser could be inferred for file: /Users/kkweon/temp/temp.org[*Org Src temp.org[ js ]*]

Thank you.

kkweon avatar Jul 02 '18 23:07 kkweon

You could fix this using the custom variable prettier-js-args to specify the prettier parse you want to use.

rcoedo avatar Jul 03 '18 06:07 rcoedo

And can still be used to format js, ts, json, less, scss ? It will force the parser?

kkweon avatar Jul 03 '18 06:07 kkweon

Yes, it forces the parser. You will have to set the variable to the right format for each one of these files. You could do this with hooks for example.

Edit: If you need more info on the prettier args you can run prettier --help in the command line.

rcoedo avatar Jul 03 '18 06:07 rcoedo

Sorry to revive an old thread, but perhaps prettier could infer a reasonable extension from the major mode when there is no buffer-file-name, as is the case in org-mode source blocks?

bcc32 avatar Jul 12 '21 00:07 bcc32