Skip to content

Commit fdf984d

Browse files
ThunderEXpfalcon
authored andcommitted
xmltok: Skip comment markup in XML.
This is provisional solution, at later time, comments may become tokenized and fed to the caller, like other syntactic elements.
1 parent 79f13b6 commit fdf984d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

xmltok/test.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
baz
1010

1111
</u:GetConnectionTypeInfo>
12+
<!-- Comments, you won't see me after tokenize. -->
1213
</s:Body>
1314
</s:Envelope>

xmltok/xmltok.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ def tokenize(self):
9595
yield from self.lex_attrs_till()
9696
self.expect("?")
9797
self.expect(">")
98+
elif self.match("!"):
99+
self.expect("-")
100+
self.expect("-")
101+
last3 = ''
102+
while True:
103+
last3 = last3[-2:] + self.getch()
104+
if last3 == "-->":
105+
break
98106
else:
99107
tag = self.getnsident()
100108
yield (START_TAG, tag)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy