Skip to content

Commit

Permalink
fix: broken relative links in combined
Browse files Browse the repository at this point in the history
chore: remove auto deploy from travis

fixes #42
  • Loading branch information
zhaoterryy committed Feb 16, 2019
1 parent d2d4035 commit 875a33d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
10 changes: 1 addition & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ python:
- 3.4
- 3.5
- 3.6
- 3.7

script: true

Expand All @@ -11,15 +12,6 @@ branches:
- master
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/ # version tags

deploy:
provider: pypi
distributions: sdist bdist_wheel
user: $PYPI_USER
password: $PYPI_PASSWORD
on:
tags: true
python: 3.6

notifications:
email:
on_success: never
1 change: 0 additions & 1 deletion mkdocs_pdf_export_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from mkdocs.plugins import BasePlugin
from mkdocs import utils


class PdfExportPlugin(BasePlugin):

DEFAULT_MEDIA_TYPE = 'print'
Expand Down
12 changes: 9 additions & 3 deletions mkdocs_pdf_export_plugin/preprocessor/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@ def transform_href(href: str, rel_url: str):
elif num_hashtags is 1:
section, ext = tuple(os.path.splitext(tail))
id = str.split(ext, '#')[1]

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)

elif num_hashtags > 1:
raise RuntimeError('Why are there so many hashtags in {}!?!?'.format(href))


return '#{}/{}:{}'.format(head, section, id)
Expand All @@ -96,7 +99,10 @@ def transform_id(id: str, rel_url: str):
head, tail = os.path.split(rel_url)
section, _ = os.path.splitext(tail)

return '{}/{}:{}'.format(head, section, id)
if len(head) > 0:
head += '/'

return '{}{}:{}'.format(head, section, id)

def inject_body_id(url: str):
section, _ = os.path.splitext(url)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='mkdocs-pdf-export-plugin',
version='0.5.2',
version='0.5.3',
description='An MkDocs plugin to export content pages as PDF files',
long_description='The pdf-export plugin will export all markdown pages in your MkDocs repository as PDF files'
'using WeasyPrint. The exported documents support many advanced features missing in most other'
Expand Down

0 comments on commit 875a33d

Please sign in to comment.