Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

xml header processing, closes #8

  • Loading branch information...
commit 78da832e7af7c9f46a0fa4cf7bd18f5fae90c7d3 1 parent 8d5a5d8
@alek-sys authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 indentxml.py
View
7 indentxml.py
@@ -37,9 +37,10 @@ def run(self, edit):
s = self.indentxml(s)
view.replace(edit, alltextreg, s)
- def indentxml(self, s):
+ def indentxml(self, s):
# convert to utf
- s = s.encode("utf-8")
+ s = s.encode("utf-8")
+ xmlheader = re.compile("<\?.*\?>").match(s)
# convert to plain string without indents and spaces
s = re.compile('>\s+([^\s])', re.DOTALL).sub('>\g<1>', s)
# replace tags to convince minidom process cdata as text
@@ -51,4 +52,6 @@ def indentxml(self, s):
s = s.replace('%CDATAESTART%', '<![CDATA[').replace('%CDATAEEND%', ']]>')
# remove xml header
s = s.replace("<?xml version=\"1.0\" ?>", "").strip()
+ if xmlheader:
+ s = xmlheader.group() + "\n" + s
return s
Please sign in to comment.
Something went wrong with that request. Please try again.