diff --git a/src/views/tool/code.vue b/src/views/tool/code.vue index 34d560a32b24a69a0fe2773b6603919056bf9235..fbbdd320fd372a6afe10eff9a2675578799edc69 100644 --- a/src/views/tool/code.vue +++ b/src/views/tool/code.vue @@ -1,88 +1,86 @@ \ No newline at end of file diff --git a/src/views/tool/library/formatter.js b/src/views/tool/library/formatter.js new file mode 100644 index 0000000000000000000000000000000000000000..6c1ed91a30d740fc844a491f89396bcd463f9a5c --- /dev/null +++ b/src/views/tool/library/formatter.js @@ -0,0 +1,15 @@ +import codeFormatter from 'code-formatter' +import xmlFormatter from "xml-formatter" + +export default (code, type, isCompress = false) => { + if (type === "xml") { + return xmlFormatter(code, { + indentation: isCompress ? '' : ' ', + collapseContent: true, + lineSeparator: isCompress ? '' : '\n' + }); + } + return codeFormatter(code, { + method: isCompress ? type + "min" : type + }) +} \ No newline at end of file