Glavin001 / atom-beautify

:mega: Help Wanted - Looking for Maintainer: https://github.com/Glavin001/atom-beautify/issues/2572 | :lipstick: Universal beautification package for Atom editor (:warning: Currently migrating to https://github.com/Unibeautify/ and have very limited bandwidth for Atom-Beautify Issues. Thank you for your patience and understanding :heart: )
http://unibeautify.com/
MIT License
1.5k stars 453 forks source link

Add Sass support to Vue beautifier #1344

Open xream opened 8 years ago

xream commented 8 years ago

Description

The results of beautification are not what I expect.

Input Before Beautification

This is what the code looked like before:

<template lang="pug">
.counter
</template>

<script>
export default {
  name: 'Counter',
}
</script>

<style lang="sass" scoped>
body
  color: red
  background-color: red
</style>

Expected Output

The beautified code should have looked like this:

<template lang="pug">
.counter
</template>

<script>
export default {
  name: 'Counter',
}
</script>

<style lang="sass" scoped>
body
  color: red
  background-color: red
</style>

Actual Output

The beautified code actually looked like this:

<template lang="pug">

.counter

</template>

<script>
export default {
  name: 'Counter',
}
</script>

<style lang="sass" scoped>
body color:red background-color:red</style>

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. This beautified code does not look right!

Debug

Here is a link to the debug.md Gist: https://gist.github.com/anonymous/bf36458f0777ea046ef706b9cd09cbaf

Checklist

I have:

Glavin001 commented 7 years ago
<template lang="pug">
.counter
</template>

becoming

<template lang="pug">

.counter

</template>

is caused by the two additional \n wrapping the beautified code: https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee#L29

This can be fixed. I recommend submitting a Pull Request and I would be happy to review and merge it.

 <style lang="sass" scoped>
body color:red background-color:red</style>

might be a Pretty Diff bug: https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee#L37 /cc @prettydiff

prettydiff commented 7 years ago

I am not able to reproduce the extra new lines around .counter and Pretty Diff provides no support for SASS lang. SCSS, yes, but not SASS.

Glavin001 commented 7 years ago

The extra newlines created are another bug: https://github.com/Glavin001/atom-beautify/issues/1557

I'm changing this issue to adding support for Sass to Vue, which currently uses Pretty Diff (like SCSS) however it is not expected to work properly. Looking at https://github.com/Glavin001/atom-beautify#language-support only beautifier Sass-Convert supports Sass beautification, so it will likely need to be used.