{"action":"created","issue":{"url":"https://api.github.com/repos/earwig/mwparserfromhell/issues/198","repository_url":"https://api.github.com/repos/earwig/mwparserfromhell","labels_url":"https://api.github.com/repos/earwig/mwparserfromhell/issues/198/labels{/name}","comments_url":"https://api.github.com/repos/earwig/mwparserfromhell/issues/198/comments","events_url":"https://api.github.com/repos/earwig/mwparserfromhell/issues/198/events","html_url":"https://github.com/earwig/mwparserfromhell/issues/198","id":354681555,"node_id":"MDU6SXNzdWUzNTQ2ODE1NTU=","number":198,"title":"Multiple equal signs in a template are wrongly parsed as parameter name/value separator","user":{"login":"lahwaacz","id":1289205,"node_id":"MDQ6VXNlcjEyODkyMDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1289205?v=4","gravatar_id":"","url":"https://api.github.com/users/lahwaacz","html_url":"https://github.com/lahwaacz","followers_url":"https://api.github.com/users/lahwaacz/followers","following_url":"https://api.github.com/users/lahwaacz/following{/other_user}","gists_url":"https://api.github.com/users/lahwaacz/gists{/gist_id}","starred_url":"https://api.github.com/users/lahwaacz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lahwaacz/subscriptions","organizations_url":"https://api.github.com/users/lahwaacz/orgs","repos_url":"https://api.github.com/users/lahwaacz/repos","events_url":"https://api.github.com/users/lahwaacz/events{/privacy}","received_events_url":"https://api.github.com/users/lahwaacz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-28T11:07:53Z","updated_at":"2018-08-28T11:37:01Z","closed_at":null,"author_association":"NONE","body":"Consider this wikicode:\r\n```\r\n{{echo|foo\r\n== section ==\r\nbar}}\r\n```\r\nAfter template expansion, using \"Template:Echo\" containing just `{{{1}}}`, MediaWiki parses it as\r\n```html\r\n<p>foo\r\n</p>\r\n<h2><span class=\"mw-headline\" id=\"section\">section</span></h2>\r\n<p>bar\r\n</p>\r\n```\r\nI.e. everything between the `|` and `}}` is interpreted as one template parameter.\r\n\r\nBut mwparserfromhell parses it like a named parameter `foo` with the value `= section ==\\nbar`:\r\n```python\r\nIn [1]: import mwparserfromhell\r\n\r\nIn [2]: wikicode = mwparserfromhell.parse(\"{{echo|foo\\n== section ==\\nbar}}\")\r\n\r\nIn [3]: print(wikicode.get_tree())\r\n{{\r\n      echo\r\n    | foo\\n\r\n    = = section ==\\nbar\r\n}}\r\n\r\nIn [4]: t = wikicode.filter_templates()[0]\r\n\r\nIn [5]: t.has(\"foo\")\r\nOut[5]: True\r\n\r\nIn [6]: t.get(\"foo\").value\r\nOut[6]: '= section ==\\nbar'\r\n```\r\n\r\nNote that this behaviour is wrong only for named parameters, numbered parameters (like in `{{echo|1=foo}}`) behave like this even in MediaWiki."},"comment":{"url":"https://api.github.com/repos/earwig/mwparserfromhell/issues/comments/416552242","html_url":"https://github.com/earwig/mwparserfromhell/issues/198#issuecomment-416552242","issue_url":"https://api.github.com/repos/earwig/mwparserfromhell/issues/198","id":416552242,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjU1MjI0Mg==","user":{"login":"lahwaacz","id":1289205,"node_id":"MDQ6VXNlcjEyODkyMDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1289205?v=4","gravatar_id":"","url":"https://api.github.com/users/lahwaacz","html_url":"https://github.com/lahwaacz","followers_url":"https://api.github.com/users/lahwaacz/followers","following_url":"https://api.github.com/users/lahwaacz/following{/other_user}","gists_url":"https://api.github.com/users/lahwaacz/gists{/gist_id}","starred_url":"https://api.github.com/users/lahwaacz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lahwaacz/subscriptions","organizations_url":"https://api.github.com/users/lahwaacz/orgs","repos_url":"https://api.github.com/users/lahwaacz/repos","events_url":"https://api.github.com/users/lahwaacz/events{/privacy}","received_events_url":"https://api.github.com/users/lahwaacz/received_events","type":"User","site_admin":false},"created_at":"2018-08-28T11:37:01Z","updated_at":"2018-08-28T11:37:01Z","author_association":"NONE","body":"On a related note, mwparserfromhell parses URLs containing equal signs (`=`) inside templates differently depending on whether they are enclosed in brackets or not:\r\n```python\r\nIn [1]: import mwparserfromhell\r\n\r\nIn [2]: wikicode = mwparserfromhell.parse(\"{{echo|[http://example.com?foo=bar]}}\")\r\n\r\nIn [2]: print(wikicode.get_tree())\r\n{{\r\n      echo\r\n    | 1\r\n    = [\r\n            http://example.com?foo=bar\r\n      ]\r\n}}\r\n\r\nIn [3]: wikicode = mwparserfromhell.parse(\"{{echo|http://example.com?foo=bar}}\")\r\n\r\nIn [3]: print(wikicode.get_tree())\r\n{{\r\n      echo\r\n    | http://example.com?foo\r\n    = bar\r\n}}\r\n```\r\n\r\nThis is also wrong, MediaWiki parses template parameters before external links, so it goes with the named parameter in both cases."}}
{"actor":{"display_login":"lahwaacz"}}