Example #1
0
 def test_set_target(self):
     wl = WikiLink('[[A | B]]')
     wl.target = ' C '
     self.assertEqual('[[ C | B]]', wl.string)
     wl = WikiLink('[[A]]')
     wl.target = ' C '
     self.assertEqual('[[ C ]]', wl.string)
Example #2
0
def test_set_target():
    wl = WikiLink('[[A | B]]')
    wl.target = ' C '
    assert '[[ C | B]]' == wl.string
    del wl.target
    assert '[[ B]]' == wl.string
    del wl.target
    assert '[[]]' == wl.string
    wl = WikiLink('[[A]]')
    wl.target = ' C '
    assert '[[ C ]]' == wl.string
Example #3
0
def link(instance: WikiPage, wikilink: wikitextparser.WikiLink):
    target = wikilink.target[len(":folder:"):].strip()

    # As we are browsing folders, [[Folder:en]] and [[Folder:en/]] are
    # identical in meaning.
    if not target.endswith("/"):
        target += "/"
    target += "Main Page"

    wikilink.target = "Folder/" + target
    return False
Example #4
0
def link_file(instance: WikiPage, wikilink: wikitextparser.WikiLink):
    target = wikilink.target[len(":file:"):].strip()

    # Generate a link to the language root, which will list all templates
    # of that language.
    # Example: [[:Template:en]]
    if len(target) == 2:
        target += "/Main Page"

    wikilink.target = "File/" + target
    return False
Example #5
0
def link(instance: WikiPage, wikilink: wikitextparser.WikiLink):
    target = wikilink.target[len(":category:"):].strip()

    # Generate a link to the language root, which will list all categories
    # of that language.
    # Example: [[:Category:en]]
    if len(target) == 2:
        target += "/Main Page"

    # Tell the target what the URL is to find this category, and let the
    # normal WikiLink handler take care of making that into a link.
    wikilink.target = "Category/" + target
    return False