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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "slackify_markdown"
version = "0.2.1"
version = "0.2.2"
description = "Convert markdown to Slack-compatible formatting"
readme = "readme.md"
authors = [
Expand Down
7 changes: 3 additions & 4 deletions src/slackify_markdown/slackify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# Todo: Clean code before release.
class SlackifyMarkdown(RendererHTML):

_in_heading = False

SUPPORTED_TOKENS = [
"text",
"inline",
Expand Down Expand Up @@ -54,6 +52,7 @@ class SlackifyMarkdown(RendererHTML):
def __init__(self, markdown_text: str):
super().__init__()
self.markdown_text = markdown_text
self._in_heading = False

# this is not correctly done, we need to check in an deopth for children,
# the library offers allowed tokens/tags. Move to that instead of this :), todo.
Expand Down Expand Up @@ -114,7 +113,7 @@ def heading_open(
options: Dict[str, Any],
env: Dict[str, Any],
) -> str:
self.__class__._in_heading = True
self._in_heading = True
return "*"

def heading_close(
Expand All @@ -124,7 +123,7 @@ def heading_close(
options: Dict[str, Any],
env: Dict[str, Any],
) -> str:
self.__class__._in_heading = False
self._in_heading = False
return "*\n\n"

def strong_open(
Expand Down
6 changes: 6 additions & 0 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ def test_heading_with_bold():
assert slackify_markdown("### **Step 1**: Description here") == "*Step 1: Description here*\n\n"
assert slackify_markdown("### **Step 1**") == "*Step 1*\n\n"
assert slackify_markdown("# **Test**: text") == "*Test: text*\n\n"
assert slackify_markdown("### Normal and **bold**") == "*Normal and bold*\n\n"


def test_heading_with_italic():
assert slackify_markdown("### *emphasized*") == "*_emphasized_*\n\n"
assert slackify_markdown("### ***bold italic***") == "*_bold italic_*\n\n"


def test_bold():
Expand Down
Loading