Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #113 from philipsens/master
Browse files Browse the repository at this point in the history
Add auto indent for xml
  • Loading branch information
alexdima authored Oct 5, 2020
2 parents 425b0e3 + a7400fc commit 506dba1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/xml/xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { languages } from '../fillers/monaco-editor-core';
import { languages } from '../fillers/monaco-editor-core';

export const conf: languages.LanguageConfiguration = {
comments: {
Expand All @@ -19,6 +19,19 @@ export const conf: languages.LanguageConfiguration = {
{ open: '<', close: '>' },
{ open: "'", close: "'" },
{ open: '"', close: '"' }
],
onEnterRules: [
{
beforeText: new RegExp(`<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
action: {
indentAction: languages.IndentAction.IndentOutdent
}
},
{
beforeText: new RegExp(`<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
action: { indentAction: languages.IndentAction.Indent }
}
]
};

Expand Down

0 comments on commit 506dba1

Please # to comment.