Permalink
Browse files

formatting by xmlns attribute is added

  • Loading branch information...
1 parent 261dd07 commit 0cdb8999896d4b3e8d5eecf2d19dd0b0ffc12e72 @vkiryukhin committed Jun 13, 2012
Showing with 22 additions and 8 deletions.
  1. +10 −2 index.html
  2. +1 −4 main.js
  3. +11 −2 vkbeautify.js
View
@@ -1,8 +1,11 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!--html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" itemscope itemtype="http://schema.org/Article">
<head>
+<meta itemprop="name" content="vkBeautify">
+<meta itemprop="description" content="Beautify or Minify XML JSON CSS SQL text">
<script src="jquery.1.5.0.js" type="text/javascript"></script>
<script src="vkbeautify.js"></script>
@@ -12,7 +15,11 @@
<title>vkBeautify - javascript plugin</title>
<script type="text/javascript">
-
+ (function() {
+ var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
+ po.src = 'https://apis.google.com/js/plusone.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
+ })();
</script>
</head>
<body>
@@ -28,6 +35,7 @@
&nbsp;|&nbsp;<li ><a href="https://github.com/vkiryukhin/vkBeautify" title="Source on GitHub" target="_blank">GitHub</a></li>&nbsp;|&nbsp;
</ul>
+ <div style="inline-block;position:relative;top:-41px" ><g:plusone size="small" annotation="none"></g:plusone></div>
</div> <!-- /header -->
<!-- ================= container ======================= -->
View
@@ -90,10 +90,7 @@ function loadTemplate(name)
case 'basic':
$('#ta').width(400);
$('#leftpanel').show();
- document.getElementById('ta').value = '<?xml version="1.0" encoding="UTF-8" ?>'
- + '<!DOCTYPE foo SYSTEM "Foo.dtd"><a><b>bbb</b><c/>'
- + '<d><!-- comment --></d><e><![CDATA[ <z></z> ]]>'
- + '</e><f><g> </g></f></a>';
+ document.getElementById('ta').value = '<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE foo SYSTEM "Foo.dtd"><a><b>bbb</b><c/><d><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></soapenv></d><e><![CDATA[ <z></z> ]]></e><f><g></g></f></a>';
$('#rightpanel').empty().load('html/basic.html');
$('#mode').html('XML');
countChars();
View
@@ -84,7 +84,10 @@ function vkbeautify(){
vkbeautify.prototype.xml = function(text,step) {
- var ar = text.replace(/>\s{0,}</g,"><").replace(/</g,"~::~<").split('~::~'),
+ var ar = text.replace(/>\s{0,}</g,"><")
+ .replace(/</g,"~::~<")
+ .replace(/xmlns/g,"~::~xmlns:")
+ .split('~::~'),
len = ar.length,
inComment = false,
deep = 0,
@@ -132,7 +135,13 @@ vkbeautify.prototype.xml = function(text,step) {
// <? xml ... ?> //
if(ar[ix].search(/<\?/) > -1) {
str += shift[deep]+ar[ix];
- } else {
+ } else
+ // xmlns: //
+ if(ar[ix].search(/xmlns/) > -1) {
+ str += shift[deep]+ar[ix];
+ }
+
+ else {
str += ar[ix];
}
}

0 comments on commit 0cdb899

Please sign in to comment.