Git Product home page Git Product logo

web-beautify's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web-beautify's Issues

Unwanted wrapping on methods

Hello good day,

I have wrap_line_length set to 80, but when using the beautifier it will wrap the line if the method(including the paramaters) length reach 31.

Emacs freezes while saving after applying web-beautify-html

First of all: this is a very usefull package! Thanks a lot for the developement.

I encounter the following behaviour:

  • Save xhtml-file from browser
  • load file in emacs using web-mode
  • apply web-beautify-html
  • trying to save the file lets emacs freeze (only solution: kill emacs process)

I tried the same with emacs started with -q, only loading web-mode.el and web-beautify.el. This works flawlessly.

Before I start dissecting my .emacs-configuration (which will probably take ages) I wanted to ask, if anyone has encountered this behaviour before or if anyone can give a hint, what could trigger that annoying side-effect? An help appreciated.

Martin

Fails on MS Windows as js-beautify cmd exits with no direct output

On MS Windows, calling the beautify functions simply deletes all content of the buffer. I believe this is because js-beautify is a shell script that opens a node.js process on the js-beautify module. Thus, the script itself has no direct output. This behaviour can also be observed by simply invoking js-beautify from M-x shell or similar methods.

For the record, this bug also exists in the package prettier-js, and probably others.

I have tried to fix the issue by invoking node.exe directly. Unfortunately, this process somehow never terminates when called from emacs.

Shouldn't beautify min files

If a file is named *.min.js or *-min.js, perhaps the beautify should not happen unless something like web-beautify-js-force is called? Then the auto-beautify on save would still work without poking around in mimized code blowing it up.

zsh:1: command not found: html-beautify

when I use web-beautify-html in web-mode, it's say command not found: html-beautify. But I could found in zsh:
~: which html-beautify
/Users/wangchuande/.nvm/versions/node/v10.10.0/bin/html-beautify

js-beautify as a node library(install locally)

I installed js-beautify locally in my project directory.
Is there a way to make it work with web-beautify?
When I run M-x web-beautify-js , it says js-beautify not found and asks to install it globally.
Thank You

JSHint whines "This character may get silently deleted by one or more browsers."

Hi, everytime I run web-beautify on my js files, an additional character is apparently added to the top of the file, on the first line. The problem here is that JSHint, which my grunt runs, complains each time and refuse to run as a result. Any idea how to prevent that additional character from being added?

Thanks in advance for your attention.

js-beautify not found

Even after installing js-beautify globally, I'm getting errors running this in EMACS. This may be because I use NPM. Can you add some notes about setting up the paths correctly in EMACS, so that this package can find js-beautify?

Buffer scrolls on long js files

I have setup web-beautify to run after js2-mode like so:

(eval-after-load 'js2-mode
  '(add-hook 'js2-mode-hook
         (lambda ()
           (add-hook 'before-save-hook 'web-beautify-js-buffer t t))))

Everytime I save, this causes the buffer to scroll, after it's done the cursor is one line from the bottom of the window. This makes using web-beautify very frustrating to use. If it matters, I am using emacs prelude, but had disabled nearly everything debugging this problem.

I did not get this behavior with a similar setup before using emacs prelude. Perhaps there's something else going on in prelude?

web-beautify not working for html / css

Hi,

I have installed js-beautify via npm.
In emacs running web-beautify-js works just fine, but using ..-html or ..-css give me the error that [html/css]-beautify not found. Install it with 'npm -g install js-beautify'.

How do I solve this?

For Frodo
Daniel

Hooks for formatting before saving

When I use the following in my init.el

(eval-after-load 'css-mode
  '(add-hook 'css-mode-hook
             (lambda ()
               (add-hook 'before-save-hook 'web-beautify-css-buffer t t))))

I get a compiler error when I compile my init file.

When I remove the eval-after-load part, as follows

(add-hook 'css-mode-hook
      (lambda ()
        (add-hook 'before-save-hook 'web-beautify-css-buffer t t)))

The compiler error goes away. The effect seems to the same. Any idea what might be wrong? I think the issue is probably due to something about Emacs Lisp that I don't understand.

I'm using Emacs version 24.4.50.1.

dash having space before and after ,auto saving

after i auto saving my script file reformat it self

import my-components from '@/components/my-components'

become to this after auto save ,all the dash space out

import my - components from '@/components/my-components'

which giving me a headcha how to config it ? do anyone know how to fix this space problem , can point me to a right direction ? i also hear js-beautify can disable this but where to ?

Highlighting "flickering" while applying formatting

Under some circumstances, lines lose their syntax highlighting for a while when formatting is applied.

The attached image illustrates it.

web-beautify

I would like for the text not to temporarily turn to the foreground color.

- Symbol's function definition is void: use-region-p

i have an init.el under .emacs.d and folder disp host the plugin. I also followed your instruction and had npm installed. But when I tried to turn on region and M-x web-beautify-js it, it gave me-

  • Symbol's function definition is void: use-region-p

I'm running emacs 22 on mac osx. Please advise.

Thank you,
/ky

Typical format for .jsbeautifyrc is ignored.

Hi, so I was using web-beautify without a .jsbeautifyrc file until recently, when I needed to change the indent_size for scss files to be 2. That's when I realized the typical .jsbeautifyrc format is ignored. When I use the below:

{ "indent_size": 2, "indent_char": " ", "eol": "\n", "indent_level": 0, "indent_with_tabs": false, "preserve_newlines": true, "max_preserve_newlines": 10, "jslint_happy": false, "space_after_anon_function": false, "brace_style": "collapse", "keep_array_indentation": false, "keep_function_indentation": false, "space_before_conditional": true, "break_chained_methods": false, "eval_code": false, "unescape_strings": false, "wrap_line_length": 0, "wrap_attributes": "auto", "wrap_attributes_indent_size": 4, "end_with_newline": false }

, web-beautify works great and indents my js file as per expected. But once I added the css and html objects (the typical way it is with other editors) like the below:

{ "html": { //rules here }, "css": { // rules here }, "js": { // rules here } }

, web-beautify stops working, and it doesn't even read the original js segment. It's only until I took out the js segment and put it on its own like in my first example does web-beautify work again.

Can somebody please enlighten me as to how exactly I should be formatting my .jsbeautifyrc so that web-beautify understands the options for HTML CSS and JS? Thanks.

web-beautify ignore editorconfig option in .jsbeautifyrc

Hi, in my project, there is a .editorconfig file and a .jsbeautifyrc file. The content of jsbeautifyrc is:

{
  "editorconfig": true
}

In command line, I use js-beautify main.js command. And editorconfig will work.But in emacs, I use 'web-beautify-js' command, the editorconfig will not work.

Infomation: Ubuntu 16.04, Emacs 25.1, Spacemacs latest, js-beautify 1.6.4. Thank you!

Unnecessary tmp files?

Your implementation saves the output of js-beautify to a tmp file. Can you not simply replace the input region with the shell command's output?

(shell-command-on-region START END COMMAND &optional OUTPUT-BUFFER REPLACE
ERROR-BUFFER DISPLAY-ERROR-BUFFER)
...
Optional fourth arg OUTPUT-BUFFER specifies where to put the
command's output. If the value is a buffer or buffer name, put
the output there. Any other value, including nil, means to
insert the output in the current buffer. In either case, the
output is inserted after point (leaving mark after it).

Optional fifth arg REPLACE, if non-nil, means to insert the
output in place of text from START to END, putting point and mark
around it.

(shell-command-on-region (point-min) (point-max) "js-beautify -f -" nil t)

not same behaviour as atom-beautify

Thank you for creating this, it's very useful in my day to day work. Nevertheless It's not very useful when trying to beautify things that are not perfectly spaced after tags.

given this example

<li class="nope ">
    <a class="tile" href="#">
        <div class="yeap nope__bg-image">
            <div class="yeap__background"></div><img alt="A Camper" onload="lazyLoad && lazyLoad.addToQueue(this)" src="//image.jpg">
        </div>
    </a>
    <div class="nope__link"><a class="ellipsis-2" href="#">such text</a></div><span class="nope__price">$39.00</span>
</li>

it does not put the img tag in a new line, and the later a tags and span tags are also not put in a new line.

Whereas using atom beautify: https://github.com/Glavin001/atom-beautify this is true, and therefore it makes the file more readable. This is why I would like support for atom-beautify-like functionality because I think it would be very useful for the community

Unable to open path "/home/user/project/-", "Run `js-beautify` -h for help"

Whenever I run web-beautify-js on a file, say /home/user/project/file.js, I get the following error message:

Unable to open path "/home/user/project/-"
Run `js-beautify -h` for help.

Why is a - replacing the actual file.js file name?
It remember having used web-beautify-js last year without problems.

This happens at least in Emacs 26.1, both plain and with Spacemacs 0.200.13.
Added web-beautify and js2-mode from MELPA, nothing else.

(Currently using js-beautify version 1.8.9)

Shouldn't beautify org-mode files

I save my configuration in a org-mode file. when I do some change, I re-load it with M-x load-file RET ~/.emacs.d/init.el. If I add or remove text from my org file and save it, web-beautify beautifies that file!

Loading /home/jorge/.emacs.d/emacs-init.el (source)...
Loading /home/jorge/.emacs.d/paquetes.el (source)...done
Loading /home/jorge/.emacs.d/site-packages/golang/company-go.el (source)...done
Loading /home/jorge/.emacs.d/site-packages/erosiond-theme/erosiond-theme.el (source)...done
Loading /home/jorge/.emacs.d/site-packages/u-vm-color/u-vm-color.el (source)...done
Loading /home/jorge/.emacs.d/custom.el (source)...done
Loading /home/jorge/.emacs.d/mu4e-conf.secret.gpg...
Decrypting /home/jorge/.emacs.d/mu4e-conf.secret.gpg...done
Loading /home/jorge/.emacs.d/mu4e-conf.secret.gpg...done
[sml] sml/theme set to respectful
Loading /home/jorge/.emacs.d/emacs-init.el (source)...done
Saving file /home/jorge/.emacs.d/emacs-init.org...
Wrote /tmp/web-beautify8266lci.html
Applied web-beautify
Wrote /home/jorge/.emacs.d/emacs-init.org

I have set the before-save-hook to call web-beautify-html-buffer in my configuration

Must define at least one file.

I installed web-beautify by command:
npm -g install js-beautify
and web-beautify-html and web-beautify-css work correctly, but
fireing web-beautify-js throws an error:

Must define at least one file.
[email protected]

However, if i select whole buffer, then it works...

What to do?

Not clear where .jsbeautifyrc should live

Hi I've just started playing with web-beautify in emacs and so far I think it's great , the only issue I'm having at the moment is that the formatting it is producing isn't quite correct for me, I have written a .jsbeautifyrc file as stated in the README, but I am unsure as to where it should be placed for web-beautify to make use of it?

I've tried placing it in the root of the project I am working on but it doesn't appear to be picking it up, have I missed something?

Thanks in advance

Addon is closing with an error upon execution.

When trying to apply on the unformatted html page:
M-x web-beautify-html
I get an error:
/usr/local/lib/node_modules/js-beautify/node_modules/minimatch/dist/cjs/index.js:192
options;
^

SyntaxError: Unexpected token ;
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/usr/local/lib/node_modules/js-beautify/node_modules/editorconfig/lib/index.js:33:21)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

Please preserve the trailing newline

If you web-beautify-js the entire buffer, the trailing newline gets deleted (which defies UNIX conventions and annoys Git users, among other things).

If you web-beautify-js a region that includes a trailing newline, that newline gets deleted, even if that smashes the last line in the region into the first line following the region, which may even change the meaning of code that was relying on automatic semicolon insertion.

Please pass the -n/--end_with_newline option to js-beautify (beautifier/js-beautify#492), or otherwise preserve the trailing newline. (Perhaps you want to avoid adding a newline inside a region that ends in the middle of a line, but that’s probably a rare case.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.