mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-06-01 17:15:48 +08:00
feat: add XML and HTML formatting support (#721)
This commit is contained in:
18
lib/utils/xml_formatter.dart
Normal file
18
lib/utils/xml_formatter.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:xml/xml.dart';
|
||||
|
||||
class XML {
|
||||
/// 格式化 XML
|
||||
static String pretty(String xmlString) {
|
||||
if (xmlString.trim().isEmpty || !xmlString.contains('<')) {
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
try {
|
||||
final document = XmlDocument.parse(xmlString);
|
||||
return document.toXmlString(pretty: true, indent: ' ');
|
||||
} catch (_) {
|
||||
return xmlString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user