5j9 / wikitextparser

A Python library to parse MediaWiki WikiText
GNU General Public License v3.0
289 stars 22 forks source link

Error getting `plain_text` when link has no title (e.g. points to a section) #123

Closed KennyChenBasis closed 12 months ago

KennyChenBasis commented 12 months ago

Using version 0.55.4, here's a minimal reproducible example:

import wikitextparser as wtp

text = "[[#Fitzmaurice|Fitzmaurice (1996)]]"
wtp.parse(text).plain_text()

(e.g. https://en.wikipedia.org/wiki/Belgium). It errors at:

wikitextparser/_wikitext.py", line 773, in plain_text
    if title[0] != ':' and (
IndexError: string index out of range