Skip to content

Commit

Permalink
Merge pull request #1 from sudoskys/dev
Browse files Browse the repository at this point in the history
:emoji: chore(pdm.lock): update content_hash for emoji package
  • Loading branch information
sudoskys authored Mar 17, 2024
2 parents 53f6bb4 + 9890e96 commit 425514b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
/.pdm-python
.idea/
13 changes: 12 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions playground/exp1.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Header
print("Hello, World!")
```

```print("Hello, Inline Muti!")```

- item
- nested item

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[project]
name = "telegramify-markdown"
version = "0.1.1"
version = "0.1.2"
description = "Convert Markdown to a format usable by Telegram."
authors = [
{ name = "sudoskys", email = "coldlando@hotmail.com" },
]
dependencies = [
"mistletoe>=1.3.0",
"pytelegrambotapi>=4.16.1",
"emoji>=2.10.1",
]
requires-python = ">=3.8"
readme = "README.md"
Expand Down
15 changes: 11 additions & 4 deletions src/telegramify_markdown/customize.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import emoji


class Symbol(object):
head_level_1 = "📌"
head_level_2 = "✏"
head_level_3 = "📚"
head_level_4 = "📒"
head_level_1 = emoji.emojize(":pushpin:")
# "📌"
head_level_2 = emoji.emojize(":pencil:")
# "✏"
head_level_3 = emoji.emojize(":books:")
# "📚"
head_level_4 = emoji.emojize(":bookmark:")
# "📒"
image = "🖼"
link = "🔗"

Expand Down
23 changes: 23 additions & 0 deletions src/telegramify_markdown/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ def render_heading(
line += " " + token.closing_sequence
return [formatting.mbold(line, escape=False)]

def render_fenced_code_block(
self, token: block_token.BlockCode, max_line_length: int
) -> Iterable[str]:
indentation = " " * token.indentation
yield indentation + token.delimiter + token.info_string
yield from self.prefix_lines(
token.content[:-1].split("\n"), indentation
)
yield indentation + token.delimiter

def render_inline_code(self, token: span_token.InlineCode) -> Iterable[Fragment]:
if len(token.delimiter) == 3:
return self.embed_span(
Fragment(token.delimiter + token.padding + "\n"),
token.children,
Fragment(token.padding + token.delimiter)
)
return self.embed_span(
Fragment(token.delimiter + token.padding),
token.children,
Fragment(token.padding + token.delimiter)
)

def render_block_code(
self, token: block_token.BlockCode, max_line_length: int
) -> Iterable[str]:
Expand Down

0 comments on commit 425514b

Please sign in to comment.