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

BUG: Point in Link breaks PDF-Generation #70

Open
alexander-matthiesen opened this issue Jan 22, 2020 · 0 comments
Open

BUG: Point in Link breaks PDF-Generation #70

alexander-matthiesen opened this issue Jan 22, 2020 · 0 comments

Comments

@alexander-matthiesen
Copy link

Hey, the PDF-Generation will break if a link has a point in it.

For example:
(Test)[index.md#4.-New-Section]

This can be avoided by adding the following codechange in transform-py.

# normalize href to #foo/bar/section:id
def transform_href(href: str, rel_url: str):
    head, tail = os.path.split(href)
    num_hashtags = tail.count('#')

    if tail.startswith('#'):
        head, section = os.path.split(rel_url)
        section = os.path.splitext(section)[0]
        id = tail[1:]
    elif num_hashtags is 1:
        section, ext = tuple(os.path.splitext(tail))

        try:
            id = str.split(ext, '#')[1]
        except:
            return href
        
        if head == '..':
            href = normalize_href(href, rel_url)
            return '#{}:{}'.format(href, id)

    elif num_hashtags is 0:
        if not is_doc(href):
            return href

        href = normalize_href(href, rel_url)
        return '#{}:'.format(href)

    if head != '':
        head += '/'

    return '#{}{}:{}'.format(head, section, id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant