mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: 即时预览astyle-format
This commit is contained in:
1 parent
a89d8bfde8
commit
92986442d4
5 files changed
+193
-3
No files matched your search
@@ -5,7 +5,11 @@ export default async function load() {
|
||||
try {
|
||||
await init(astyleBinaryUrl);
|
||||
console.log('WAstyle is ready!');
|
||||
return [true, format];
|
||||
const formatter = (code, options) => {
|
||||
const [success, result] = format(code, options);
|
||||
return [success, (result || '').replace(/^#(include|import)[\t ]*(<|")/gm, (match, p1, p2) => `#${p1} ${p2}`)];
|
||||
};
|
||||
return [true, formatter];
|
||||
} catch (e) {
|
||||
return [false, e.message];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user