Skip to content

Commit

Permalink
Improve the 'Coercing non-XML name' warning (html5lib#418)
Browse files Browse the repository at this point in the history
This can be helpful in finding the code triggering the warning.
  • Loading branch information
Ms2ger authored and gsnedders committed Apr 26, 2019
1 parent 2d8919a commit 4b22754
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions html5lib/_ihatexml.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ def toXmlName(self, name):
nameRest = name[1:]
m = nonXmlNameFirstBMPRegexp.match(nameFirst)
if m:
warnings.warn("Coercing non-XML name", DataLossWarning)
warnings.warn("Coercing non-XML name: %s" % name, DataLossWarning)
nameFirstOutput = self.getReplacementCharacter(nameFirst)
else:
nameFirstOutput = nameFirst

nameRestOutput = nameRest
replaceChars = set(nonXmlNameBMPRegexp.findall(nameRest))
for char in replaceChars:
warnings.warn("Coercing non-XML name", DataLossWarning)
warnings.warn("Coercing non-XML name: %s" % name, DataLossWarning)
replacement = self.getReplacementCharacter(char)
nameRestOutput = nameRestOutput.replace(char, replacement)
return nameFirstOutput + nameRestOutput
Expand Down

0 comments on commit 4b22754

Please sign in to comment.