vscode icon indicating copy to clipboard operation
vscode copied to clipboard

django template comments crash unibeautify

Open Somberland opened this issue 5 years ago • 4 comments

using django-template comments in html-files for example:

{% comment %} <button type='button' class='btn btn-secondary'>Secondary</button> {% endcomment %}

will break unibeautify.

HTML:
  beautifiers:
    - Pretty Diff
    # - JS-Beautify
  align_assignments: true
  indent_comments: true
  indent_style: tab
  indent_size: 1
  max_preserve_newlines: 4
  quotes: single
  brace_style: collapse
  break_chained_methods: true
  end_with_comma: false
  multiline_ternary: always-multiline
  end_with_newline: true
  force_indentation: false
  preserve_newlines: true
  indent_inner_html: true
  indent_scripts: normal
  newline_before_tags: []

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at markuppretty__beautify_apply_attArray (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3349:47)
    at markuppretty__beautify_apply (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3367:34)
    at markuppretty__beautify (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3479:20)
    at Object.markuppretty_ [as markuppretty] (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3480:10)
    at core__markuppretty (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:77:30)
    at core_ (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:307:37)
    at prettydiff_ (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:334:16)
    at commonjs_prettydiff (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:369:20)
    at exports.beautifier.beautify.Promise (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/@unibeautify/beautifier-prettydiff/src/index.ts:120:22)
    at new Promise (<anonymous>)
    at Object.beautify (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/@unibeautify/beautifier-prettydiff/src/index.ts:49:12)
    at beautifyWithBeautifiers.beautifiers.reduce.promise.then.dependencyManager.load.then.then (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/unibeautify/src/beautifier.ts:410:18)

 WARN Error: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at markuppretty__beautify_apply_attArray (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3349)
    at markuppretty__beautify_apply (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3367)
    at markuppretty__beautify (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3479)
    at Object.markuppretty_ [as markuppretty] (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/lib/markuppretty.js:3480)
    at core__markuppretty (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:77)
    at core_ (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:307)
    at prettydiff_ (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:334)
    at commonjs_prettydiff (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/prettydiff2/prettydiff.js:369)
    at exports.beautifier.beautify.Promise (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/@unibeautify/beautifier-prettydiff/src/index.ts:120)
    at new Promise (<anonymous>)
    at Object.beautify (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/@unibeautify/beautifier-prettydiff/src/index.ts:49)
    at beautifyWithBeautifiers.beautifiers.reduce.promise.then.dependencyManager.load.then.then (/.vscode/extensions/glavin001.unibeautify-vscode-0.7.0/node_modules/unibeautify/src/beautifier.ts:410)

Somberland avatar May 06 '19 11:05 Somberland

Hi @Somberland. This looks to be an issue with prettydiff, I'll need to investigate further. Also, you're .unibeautifyrc.yml file is incorrect, you want:

HTML: 
  align_assignments : true 
  beautifiers : ["JS-Beautify", "Pretty Diff"] 
  brace_style : "collapse" 
  break_chained_methods : true 
  end_with_comma : true 
  end_with_newline : true 
  force_indentation : false 
  indent_comments : true 
  indent_inner_html : true
  indent_scripts : "normal" 
  indent_size : 1 
  indent_style : "tab" 
  max_preserve_newlines : 4 
  multiline_ternary : "always-multiline" 
  newline_before_tags : [] 
  preserve_newlines : true 
  quotes : "single"

stevenzeck avatar May 08 '19 00:05 stevenzeck

thanks for the reply :) looking forward for an solution.

created the config-file via https://assistant.unibeautify.com/#/setup , strange

Somberland avatar May 08 '19 06:05 Somberland

I'm able to reproduce with Unibeautify Playground:

image

This bug needs to be reported to https://github.com/prettydiff/prettydiff

Glavin001 avatar Apr 25 '20 21:04 Glavin001

@Glavin001 @Somberland

Hi, I see that this issue is still unresolved, have you created an issue on prettydiff?

yaegassy avatar Apr 23 '21 04:04 yaegassy