Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions confluence-mdx/bin/converter/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@

try:
import emoji
EMOJI_AVAILABLE = True
except ImportError:
EMOJI_AVAILABLE = False
raise SystemExit(
"Required package 'emoji' is not installed.\n"
"Run: pip install 'emoji>=2.8.0'"
)


# Type definitions for page_v1 structure
Expand Down
25 changes: 7 additions & 18 deletions confluence-mdx/bin/converter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import converter.context as ctx
from converter.context import (
PAGES_BY_TITLE,
CONFLUENCE_COLOR_TO_BADGE_COLOR, EMOJI_AVAILABLE,
CONFLUENCE_COLOR_TO_BADGE_COLOR,
confluence_url, parse_confluence_url, convert_confluence_url,
get_page_v1, get_attachments, set_page_v1, set_attachments,
relative_path_to_titled_page, resolve_external_link,
Expand Down Expand Up @@ -333,24 +333,13 @@ def convert_recursively(self, node):
self.markdown_lines.append(fallback)
elif shortname:
# Convert shortname to actual emoji
if EMOJI_AVAILABLE:
# Use emoji library to convert shortname to actual emoji
emoji_char = emoji.emojize(shortname, language='alias')
if emoji_char != shortname:
# Conversion successful (converted to actual emoji)
self.markdown_lines.append(emoji_char)
else:
# Conversion failed (use fallback or shortname as-is)
if fallback:
self.markdown_lines.append(fallback)
else:
self.markdown_lines.append(shortname)
emoji_char = emoji.emojize(shortname, language='alias')
if emoji_char != shortname:
self.markdown_lines.append(emoji_char)
elif fallback:
self.markdown_lines.append(fallback)
else:
# emoji library not available, use fallback or shortname
if fallback:
self.markdown_lines.append(fallback)
else:
self.markdown_lines.append(shortname)
self.markdown_lines.append(shortname)
elif fallback:
# No shortname but fallback is available
self.markdown_lines.append(fallback)
Expand Down
Loading