Last active
June 6, 2021 15:28
-
-
Save gosoccerboy5/795755a753472371f816f426917044aa to your computer and use it in GitHub Desktop.
Minify XML generated by Blockly.
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
(function minifyXML(source) { | |
source.value = source.value.replaceAll(/\n */g, ""); | |
source.select(); | |
})(document.querySelector("#content_xml")); | |
/* | |
Blockly { | |
https://scratch.mit.edu/discuss/topic/491165/ | |
} | |
Context { | |
https://scratch.mit.edu/discuss/post/4990156/ | |
} | |
To test { | |
Navigate to <https://blockly-demo.appspot.com/static/demos/code/index.html>, | |
view the "XML" tab, | |
then paste the code | |
} | |
*/ |
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
javascript:(function minifyXML(source){source.value=source.value.replaceAll(/\n */g,"");source.select()})(document.querySelector("#content_xml")); |
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
<style> | |
textarea { | |
width: 500px; | |
height: 200px; | |
} | |
</style> | |
<textarea id="content_xml"><xml xmlns="https://developers.google.com/blockly/xml"> | |
<block type="text_print" id="kKf,GaluJo~ApYPxGGjn" x="113" y="163"> | |
<value name="TEXT"> | |
<shadow type="text" id="hL19Vek;njuYt?P7..P`"> | |
<field name="TEXT">abc</field> | |
</shadow> | |
<block type="text" id="5xy/0L@a]QqKt]ETW@{6"> | |
<field name="TEXT">Hello, world!</field> | |
</block> | |
</value> | |
</block> | |
</xml> | |
</textarea> | |
<br> | |
<button id="minify">Minify</button> |
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
import 'dart:html'; | |
void minifyXML(TextAreaElement source) { | |
source.value = source.value?.replaceAll(RegExp("\n *"), ""); | |
source.select(); | |
} | |
void main() { | |
(querySelector("#minify") as ButtonElement).addEventListener("click", (_) { | |
minifyXML(querySelector("#content_xml") as TextAreaElement); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://dartpad.dev/795755a753472371f816f426917044aa?null_safety=true