-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<template> | ||
<base-view> | ||
<div slot="page-body" class="row"> | ||
Your content here! | ||
</div> | ||
</base-view> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data: function() { | ||
return { | ||
text: 'Hello, world!' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="sass"> | ||
nav { | ||
ul { | ||
margin:0 padding: 0; | ||
} | ||
li { | ||
display: inline-block; | ||
} | ||
a { | ||
display: block; | ||
} | ||
} | ||
</style> | ||
|
||
<style lang="scss"> | ||
nav { | ||
ul { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
li { | ||
display: inline-block; | ||
} | ||
a { | ||
display: block; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<template> | ||
<base-view> | ||
<div slot="page-body" class="row"> | ||
Your content here! | ||
</div> | ||
</base-view> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data: function() { | ||
return { | ||
text: 'Hello, world!' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="sass"> | ||
nav { | ||
ul { | ||
margin: 0 | ||
padding: 0 | ||
} | ||
li { | ||
display: inline-block | ||
} | ||
a { | ||
display: block | ||
} | ||
} | ||
</style> | ||
|
||
<style lang="scss"> | ||
nav { | ||
ul { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
li { display: inline-block; } | ||
a { | ||
display: block; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use strict" | ||
Beautifier = require('./beautifier') | ||
prettydiff = require("prettydiff") | ||
_ = require('lodash') | ||
|
||
module.exports = class VueBeautifier extends Beautifier | ||
name: "Vue Beautifier" | ||
|
||
options: | ||
Vue: true | ||
|
||
beautify: (text, language, options) -> | ||
return new @Promise((resolve, reject) -> | ||
regexp = /(<(template|script|style)[^>]*>)((\s|\S)*?)<\/\2>/gi | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
resolve(text.replace(regexp, (match, begin, type, text) -> | ||
lang = /lang\s*=\s*['"](\w+)["']/.exec(begin)?[1] | ||
|
||
switch type | ||
when "template" | ||
switch lang | ||
when "pug", "jade" | ||
match.replace(text, "\n" + require("pug-beautify")(text, options) + "\n") | ||
This comment has been minimized.
Sorry, something went wrong.
kaven276
Contributor
|
||
when undefined | ||
match.replace(text, "\n" + require("js-beautify").html(text, options) + "\n") | ||
else | ||
match | ||
when "script" | ||
match.replace(text, "\n" + require("js-beautify")(text, options) + "\n") | ||
when "style" | ||
switch lang | ||
when "sass", "scss" | ||
options = _.merge options, | ||
source: text | ||
lang: "scss" | ||
mode: "beautify" | ||
match.replace(text, prettydiff.api(options)[0]) | ||
when "less" | ||
options = _.merge options, | ||
source: text | ||
lang: "less" | ||
mode: "beautify" | ||
match.replace(text, prettydiff.api(options)[0]) | ||
when undefined | ||
match.replace(text, "\n" + require("js-beautify").css(text, options) + "\n") | ||
else | ||
match | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ module.exports = class Languages | |
"twig" | ||
"typescript" | ||
"vala" | ||
"vue" | ||
"visualforce" | ||
"xml" | ||
"xtemplate" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
|
||
name: "Vue" | ||
namespace: "vue" | ||
fallback: ['html'] | ||
|
||
### | ||
Supported Grammars | ||
### | ||
grammars: [ | ||
"Vue Component" | ||
] | ||
|
||
### | ||
Supported extensions | ||
### | ||
extensions: [ | ||
"vue" | ||
] | ||
|
||
defaultBeautifier: "Vue Beautifier" | ||
|
||
} |
1 comment
on commit 7ebc41b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a vue file like this will format bad
<template>
<div>xxx</div>
</template>
<script>
export default {
}
</script>
<style>
body { margin: 0}
</style>
formated to that add additional one blank line before </template></script></style>
<template>
<div>xxx</div>
</template>
<script>
export default {
}
</script>
<style>
body { margin: 0}
</style>
only
<template></template><script></script><style></style>
that start at begining of line should be considered markers for section.change
regexp = /(<(template|script|style)[^>]*>)((\s|\S)*?)<\/\2>/gi
to
regexp = /(^<(template|script|style)[^>]*>)((\s|\S)*?)^<\/\2>/gim