Exemplo n.º 1
0
    def _default_filter_categories(self, wikicode: Wikicode) -> List[str]:
        """Return a list of categories from wikicode."""
        wikilinks = wikicode.filter_wikilinks()
        ii = len("Category:")
        category_links = [
            el for el in wikilinks if el.title.lower().startswith("category:")
        ]
        category_titles = [
            el.title.rstrip()[ii:] for el in category_links
            if len(el.title.rstrip()[ii:]) > 0
        ]
        category_titles = [
            title[0].upper() + title[1:].replace(" ", "_")
            for title in category_titles
        ]

        return category_titles
Exemplo n.º 2
0
def remove_links(wc: Wikicode) -> None:
    """
    Given a chunk of wikicode, replaces all inner links with their text representation
    """
    for link in wc.filter_wikilinks():
        wc.replace(link, link.text)