Beispiel #1
0
def make_dokuwiki_pagename(mediawiki_name):
    """
    Convert a canonical mediawiki pagename to a dokuwiki pagename

    Any namespacing that is in the form of a / is replaced with a :
    """
    result = mediawiki_name.replace(" ","_")
    return names.clean_id(camel_to_underscore(result)).replace("/",":")
Beispiel #2
0
def make_dokuwiki_pagename(mediawiki_name):
    """
    Convert a canonical mediawiki pagename to a dokuwiki pagename

    Any namespacing that is in the form of a / is replaced with a :
    """
    result = mediawiki_name.replace(" ", "_")
    return names.clean_id(camel_to_underscore(result)).replace("/", ":")
Beispiel #3
0
def make_dokuwiki_pagename(mediawiki_name):
    """
    Convert a canonical mediawiki pagename to a dokuwiki pagename

    Any namespacing that is in the form of a / is replaced with a :
    """
    result = mediawiki_name.replace(" ","_")
    result = names.clean_id(camel_to_underscore(result)).replace("/",":")
    result = codecs.encode(result, sys.getfilesystemencoding(), "replace")
    return result
Beispiel #4
0
def make_dokuwiki_pagename(mediawiki_name):
    """
    Convert a canonical mediawiki pagename to a dokuwiki pagename

    Any namespacing that is in the form of a / is replaced with a :
    """
    result = mediawiki_name.replace(" ","_")
    result = names.clean_id(camel_to_underscore(result)).replace("/",":")
    result = codecs.encode(result, sys.getfilesystemencoding(), "replace")
    return result
Beispiel #5
0
def make_dokuwiki_heading_id(mw_heading_name):
    """
    Convert a Mediawiki internal anchor heading link to the Dokuwiki anchor heading link id

    Equivalent function in dokuwiki is _headerToLink in inc/parser/xhtml.php
    which calls sectionID in inc/pageutils.php
    """
    result = names.clean_id(mw_heading_name, True)
    result = re.sub(r'[:.]', '', result)

    nums_stripped = result.lstrip("0123456789_-")
    if len(nums_stripped):
        return nums_stripped
    else:
        return "section"+re.sub(r"[^0-9]+", "", result)
Beispiel #6
0
def make_dokuwiki_heading_id(mw_heading_name):
    """
    Convert a Mediawiki internal anchor heading link to the Dokuwiki anchor heading link id

    Equivalent function in dokuwiki is _headerToLink in inc/parser/xhtml.php
    which calls sectionID in inc/pageutils.php
    """
    result = names.clean_id(mw_heading_name, True)
    result = re.sub(r'[:.]', '', result)

    nums_stripped = result.lstrip("0123456789_-")
    if len(nums_stripped):
        return nums_stripped
    else:
        return "section"+re.sub(r"[^0-9]+", "", result)
Beispiel #7
0
def make_dokuwiki_pagename(mediawiki_name):
    """
    Convert a canonical mediawiki pagename to a dokuwiki pagename

    Any namespacing that is in the form of a / is replaced with a :
    """
    result = mediawiki_name.replace(" ", "_")
    # We have pages that have ':' in them - replace with underscores
    result = result.replace(':', '_')
    result = names.clean_id(camel_to_underscore(result)).replace("/", ":")
    # Some of our mediawiki page names begin with a '/', which results in os.path.join assuming the page is an absolute path.
    if result[0] == ':':
        result = result.lstrip(':')
    # Fix any pages that began with a space, because that breaks dokuwiki
    result = result.replace(":_", ":")
    result = codecs.encode(result, sys.getfilesystemencoding(), "replace")
    return result