Skip to content

Commit

Permalink
Patch 1 - Fix hash problem with no unescaped links (#1)
Browse files Browse the repository at this point in the history
* Update convert.py

Fixed problems:
1. Hashes are unescaped in links which are not returned back after processing.
2. Extra whitespace appeared after some processed links at the end of sentence in confluence.

* Update uploader.py - fix hash unscape problem

Fixed problems:
1. Hashes are unescaped in links which are not returned back after processing.
2. Extra whitespace appeared after some processed links at the end of sentence in confluence.

* Update changelog.md up to Version #0.6.21

Updated changelog.md

* Update changelog.md up to Version #0.6.21

* Update setup.py to bump a new version 0.6.21

Update setup.py to bump a new version 0.6.21
  • Loading branch information
textexpert authored Nov 25, 2024
1 parent ca85cc5 commit 0da11df
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.6.21

- Fixed unescaped hash in links which are not returned back after processing.
- Removed extra whitespace appeared after some processed links at the end of sentence in Confluence.

# 0.6.20

- Support for Confluence Cloud option to remove HTML formatting.
Expand Down Expand Up @@ -134,4 +139,4 @@

# 0.1.0

- Initial release.
- Initial release.
5 changes: 3 additions & 2 deletions foliant/backends/confluence/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ def _sub(match):
logger.debug(f'Restoring escaped confluence code with hash {filename}')
filepath = Path(escape_dir) / filename
with open(filepath) as f:
return f.read()
pattern = re.compile(r"\[confluence_escaped hash=\%(?P<hash>.+?)\%\]")
return f.read().rstrip(os.linesep)
logger.warning(f'confluence_unescape {escape_dir}')
pattern = re.compile(r"\[confluence_escaped[ \n\r]+hash=\%(?P<hash>.+?)\%\]")
return pattern.sub(_sub, source)


Expand Down
5 changes: 3 additions & 2 deletions foliant/backends/confluence/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ def _sub(match):
escaped_content = f.read()
result = self.post_process_escaped_content(escaped_content, attachment_manager)
# attachments.extend(new_attachments)
return result
return result.rstrip(os.linesep)
# attachments = []
escape_dir = self.cachedir / ESCAPE_DIR_NAME
pattern = re.compile(r"\[confluence_escaped hash=\%(?P<hash>.+?)\%\]")
self.logger.warning(f'PageUploader confluence_unescape {escape_dir}')
pattern = re.compile(r"\[confluence_escaped[ \n\r]+hash=\%(?P<hash>.+?)\%\]")
return pattern.sub(_sub, source)

def post_process_escaped_content(self, escaped_content: str, attachment_manager: AttachmentManager):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
description=SHORT_DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type='text/markdown',
version='0.6.20',
version='0.6.21',
author='Daniil Minukhin',
author_email='[email protected]',
url='https://github.com/foliant-docs/foliantcontrib.confluence',
Expand Down

0 comments on commit 0da11df

Please sign in to comment.