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

strip_code() doesn't strip image formatting code #169

Closed
halfak opened this issue Oct 28, 2016 · 4 comments
Closed

strip_code() doesn't strip image formatting code #169

halfak opened this issue Oct 28, 2016 · 4 comments

Comments

@halfak
Copy link

halfak commented Oct 28, 2016

Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mwparserfromhell as mwp
>>> mwp.__version__
'0.4.3'
>>> mwp.parse("[[File:Fly|thumb|alt=A drawing of a fly from facing up|A fly]]").strip_code()
'thumb|alt=A drawing of a fly from facing up|A fly'

Expected A fly, got thumb|alt=A drawing of a fly from facing up|A fly.

@halfak
Copy link
Author

halfak commented Oct 28, 2016

It seems like that strip_code() should always only return the last block of content in a wikilink, split by |. This would skip the whole thumb and alt=... portions of the link.

@halfak
Copy link
Author

halfak commented Oct 28, 2016

OK... so it looks like [[Test|thumb|Bar]] renders as "thumb|Bar", so images are simply crazy. sigh Maybe there would be a good way that I could implement my own strip for a particular node type in strip_code(). E.g. strip_code(for={Wikilink: lambda wl:wl.text.split("|")[-1]})

@earwig
Copy link
Owner

earwig commented Oct 28, 2016

You already reported this?

#136

@halfak
Copy link
Author

halfak commented Oct 28, 2016

Indeed. It looks like I did. Was looking at the problem from a different direction.

@earwig earwig assigned earwig and unassigned earwig Dec 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants