Feature summary:
I would like to easily create multiple <pages /> tags using pywikibot. However, when I create a new instance of PagesTagParser and asign the attributes, the parser fails when the values have two or more words, as it doesn't add quotes automatically as one might expect
tag = PagesTagParser() tag.index = 'Sample index with more than two words.pdf' tag.ffrom = 5 tag.to = "6" tag.fromsection = '"chapter XVI"' print(tag)
'<pages index=Sample index with more than two words.pdf from=5 to=6 fromsection="chapter XVI" />'
This <pages> tag won't display accordingly, as there is no "Sample" index page.
I propose the following changes on the definition of TagAttr, on proofreadpage.py (lines 137 onwards)
if ' ' in str(value) and '"' not in value and "'" not in value: self._orig_value = f'"{value}"' else: self._orig_value = value
this might be not in the coding style of pywikibot, but it does the work and it doesn't make a mess when you explicitly add the quotes.
tag = PagesTagParser() tag.index = 'Sample index with more than two words.pdf' tag.ffrom = 5 tag.to = "6" tag.fromsection = '"chapter XVI"' print(tag)
<pages index="Sample index with more than two words.pdf" from=5 to=6 fromsection="chapter XVI" />