Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty comments are not detected #256

Open
tbayer opened this issue Sep 10, 2020 · 5 comments
Open

Empty comments are not detected #256

tbayer opened this issue Sep 10, 2020 · 5 comments

Comments

@tbayer
Copy link

tbayer commented Sep 10, 2020

Example (updated and fixed, see comments):

>>> wikicode = mwparserfromhell.parse('Person<ref>Woman<!--Man</ref>Camera TV\n')

>>> wikicode.strip_code()
'PersonWoman<!--ManCamera TV'

Expected instead: 'PersonWomanCamera TV', consistent with MediaWiki's behavior

>>> wikicode.filter_comments()
[]

Expected instead: ['<!--Man']

(Encountered in this real-life example, in the form <ref> ...<!--->]</ref>.)

@lahwaacz
Copy link
Contributor

@tbayer <!---> is not even a valid HTML, there is one missing dash. The correct empty comment is with 4 dashes: <!---->. I think you should fix the source wikicode.

@tbayer
Copy link
Author

tbayer commented Sep 10, 2020

@lahwaacz There is ambiguity on whether <!---> is valid HTML. But you're right, MediaWiki at least doesn't recognize it as such, and the reason for the inconsistency in the given example is a different one (I abstracted a bit too much here) - MediaWiki ends the comment at the closing tag, but mwparserfromhell doesn't. I'll update the example.

@tbayer
Copy link
Author

tbayer commented Sep 10, 2020

I have updated the example. The bug apparently has to do with the different choices about recognizing and ending a run-on comment at a closing ref tag. Thus it might or might not be a special case of the preceding issue 255.

@tbayer
Copy link
Author

tbayer commented Sep 10, 2020

@lahwaacz, to your note about fixing the source wikicode: This seems a bit beside the point, as the issue is about having mwparserfromhell and MediaWiki yield the same result.

(For background: I encountered this problem while using mwp to search for certain kinds of malformed comments so that they can be fixed, in response to a request by editors on English Wikipedia, who had noticed cases where such typos had caused substantial parts of article text to be hidden unintentionally. If mwp doesn't detect such comments even though MW does, then that kind of search won't give the expected results.)

@lahwaacz
Copy link
Contributor

The problems with overlapping HTML nodes are tracked in the epic issue #40.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants