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

html-tidy writing unknown options to buffer #104

Closed
f-a-a opened this issue Aug 6, 2017 · 1 comment
Closed

html-tidy writing unknown options to buffer #104

f-a-a opened this issue Aug 6, 2017 · 1 comment
Labels

Comments

@f-a-a
Copy link
Contributor

f-a-a commented Aug 6, 2017

I encountered a curious case where "unknown option: wrap125" is being printed to the buffer on save.

HTML Tidy: unknown option: w
HTML Tidy: unknown option: r
HTML Tidy: unknown option: a
HTML Tidy: unknown option: p
HTML Tidy: unknown option: 1
HTML Tidy: unknown option: 2
HTML Tidy: unknown option: 5
<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="UTF-8">

  <title>
  </title>
</head>

<body>
  <div id="app">
  </div>
</body>
</html>

Debug log:

Neoformat: executable: html-beautify is not an executable
Neoformat: ['<!DOCTYPE html>', '', '<html lang="en">', '<head>', '  <meta charset="UTF-8">', '', '  <title>', '  </title>', '</head>', '', '<body>', '  <div id="app">', '  </div>', '</body>', '</html>']
Neoformat: tidy -quiet --indent auto --indent-spaces 2 --vertical-space yes --tidy-mark no -wrap125 /var/folders/nt/jmjtq3cj43s6jy_l65l0cg940000gn/T/nvimMDh7DX/31
Neoformat: using tmp file
Neoformat: ['HTML Tidy: unknown option: w', 'HTML Tidy: unknown option: r', 'HTML Tidy: unknown option: a', 'HTML Tidy: unknown option: p', 'HTML Tidy: unknown option: 1', 'HTML Tidy: unknown option: 2', 'HTML Tidy: unknown option: 5', '<!DOCTYPE html>', '', '<html lang="en">', '<head>', '  <meta charset="UTF-8">', '', '  <title>', '  </title>', '</head>', '', '<body>', '  <div id="app">', '  </div>', '</body>', '</html>']

My current tidy version is 5.4.0 and it seems to expect -wrap 125 instead of -wrap125.

By making a small tweak to the current formatters/html.vim seems to fix for me.

function! neoformat#formatters#html#tidy() abort
    return {
        \ 'exe': 'tidy',
        \ 'args': ['-quiet',
        \          '--indent auto',
        \          '--indent-spaces ' . shiftwidth(),
        \          '--vertical-space yes',
        \          '--tidy-mark no',
-       \          '-wrap' .&textwidth
+       \          '-wrap ' . &textwidth
        \         ]
        \ }
endfunction

I'm happy to have a PR up for this fix but I'm afraid that it might just be a version issue and it will break previous versions. Please let me know if I can proceed with the PR.

@sbdchd sbdchd added the bug label Aug 13, 2017
@sbdchd
Copy link
Owner

sbdchd commented Aug 13, 2017

That looks like a good fix.

Thanks!

sbdchd pushed a commit that referenced this issue Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants