Skip to content

Commit

Permalink
Fix page links with whitespace
Browse files Browse the repository at this point in the history
Fix page links with preceding or trailing whitespace

Fixes #2256
  • Loading branch information
jaap-karssenberg committed May 30, 2023
1 parent 04b93c6 commit f4a33c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zim/gui/pageview/__init__.py
Expand Up @@ -1241,7 +1241,8 @@ def get_link_data(self, iter, raw=False):
else:
# Copy text content as href
start, end = self.get_tag_bounds(iter, tag)
link['href'] = start.get_text(end)
link['href'] = start.get_text(end).strip()
# assume starting or trailing whitespace is an editing artefact
return link
else:
return None
Expand Down
2 changes: 2 additions & 0 deletions zim/notebook/page.py
Expand Up @@ -360,6 +360,8 @@ def new_from_wiki_link(klass, href: str) -> 'Href':
@note: This method HRef class assumes the logic of our wiki links.
For other formats, a separate constructor may be needed.
'''
href = href.strip()

if href.startswith(':'):
rel = HREF_REL_ABSOLUTE
elif href.startswith('+'):
Expand Down

0 comments on commit f4a33c7

Please sign in to comment.