chatgpt-md-converter 0.3.5__tar.gz → 0.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/PKG-INFO +2 -2
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/extractors.py +45 -12
- chatgpt_md_converter-0.3.7/chatgpt_md_converter/html_splitter.py +114 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter.egg-info/PKG-INFO +2 -2
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter.egg-info/SOURCES.txt +3 -1
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/setup.py +2 -2
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/tests/test_parser.py +185 -0
- chatgpt_md_converter-0.3.7/tests/test_splitter.py +436 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/LICENSE +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/__init__.py +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/converters.py +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/formatters.py +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/helpers.py +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/telegram_formatter.py +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter.egg-info/dependency_links.txt +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter.egg-info/top_level.txt +0 -0
- {chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/setup.cfg +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chatgpt_md_converter
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.7
|
|
4
4
|
Summary: A package for converting markdown to HTML for chat Telegram bots
|
|
5
|
-
Home-page: https://github.com/
|
|
5
|
+
Home-page: https://github.com/botfather-dev/formatter-chatgpt-telegram
|
|
6
6
|
Author: Kostiantyn Kriuchkov
|
|
7
7
|
Author-email: latand666@gmail.com
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
{chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/extractors.py
RENAMED
|
@@ -2,16 +2,43 @@ import re
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def ensure_closing_delimiters(text: str) -> str:
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
"""Append missing closing backtick delimiters."""
|
|
6
|
+
|
|
7
|
+
code_block_re = re.compile(
|
|
8
|
+
r"(?P<fence>`{3,})(?P<lang>\w+)?\n?[\s\S]*?(?<=\n)?(?P=fence)",
|
|
9
|
+
flags=re.DOTALL,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
# Remove complete code blocks from consideration so inner backticks
|
|
13
|
+
# don't affect delimiter balancing.
|
|
14
|
+
cleaned = code_block_re.sub("", text)
|
|
15
|
+
|
|
16
|
+
# Detect unclosed fences by tracking opening fence lengths.
|
|
17
|
+
stack = []
|
|
18
|
+
for line in cleaned.splitlines():
|
|
19
|
+
m = re.match(r"^(?P<fence>`{3,})(?P<lang>\w+)?$", line.strip())
|
|
20
|
+
if not m:
|
|
21
|
+
continue
|
|
22
|
+
fence = m.group("fence")
|
|
23
|
+
if stack and fence == stack[-1]:
|
|
24
|
+
stack.pop()
|
|
25
|
+
else:
|
|
26
|
+
stack.append(fence)
|
|
27
|
+
|
|
28
|
+
if stack:
|
|
29
|
+
text += "\n" + stack[-1]
|
|
30
|
+
|
|
31
|
+
cleaned_inline = code_block_re.sub("", text)
|
|
32
|
+
|
|
33
|
+
# Balance triple backticks that are not part of a complete fence.
|
|
34
|
+
if cleaned_inline.count("```") % 2 != 0:
|
|
11
35
|
text += "```"
|
|
12
|
-
|
|
13
|
-
|
|
36
|
+
|
|
37
|
+
# Balance single backticks outside fenced blocks.
|
|
38
|
+
cleaned_inline = code_block_re.sub("", text)
|
|
39
|
+
if cleaned_inline.count("`") % 2 != 0:
|
|
14
40
|
text += "`"
|
|
41
|
+
|
|
15
42
|
return text
|
|
16
43
|
|
|
17
44
|
|
|
@@ -25,8 +52,8 @@ def extract_and_convert_code_blocks(text: str):
|
|
|
25
52
|
code_blocks = {}
|
|
26
53
|
|
|
27
54
|
def replacer(match):
|
|
28
|
-
language = match.group(
|
|
29
|
-
code_content = match.group(
|
|
55
|
+
language = match.group("lang") if match.group("lang") else ""
|
|
56
|
+
code_content = match.group("code")
|
|
30
57
|
|
|
31
58
|
# Properly escape HTML entities in code content
|
|
32
59
|
escaped_content = (
|
|
@@ -44,8 +71,14 @@ def extract_and_convert_code_blocks(text: str):
|
|
|
44
71
|
return (placeholder, html_code_block)
|
|
45
72
|
|
|
46
73
|
modified_text = text
|
|
47
|
-
|
|
48
|
-
|
|
74
|
+
code_block_pattern = re.compile(
|
|
75
|
+
r"(?P<fence>`{3,})(?P<lang>\w+)?\n?(?P<code>[\s\S]*?)(?<=\n)?(?P=fence)",
|
|
76
|
+
flags=re.DOTALL,
|
|
77
|
+
)
|
|
78
|
+
for match in code_block_pattern.finditer(text):
|
|
79
|
+
placeholder, html_code_block = replacer(
|
|
80
|
+
match
|
|
81
|
+
)
|
|
49
82
|
code_blocks[placeholder] = html_code_block
|
|
50
83
|
modified_text = modified_text.replace(match.group(0), placeholder, 1)
|
|
51
84
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from html.parser import HTMLParser
|
|
3
|
+
|
|
4
|
+
MAX_LENGTH = 4096
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class HTMLTagTracker(HTMLParser):
|
|
8
|
+
def __init__(self):
|
|
9
|
+
super().__init__()
|
|
10
|
+
self.open_tags = []
|
|
11
|
+
|
|
12
|
+
def handle_starttag(self, tag, attrs):
|
|
13
|
+
# saving tags
|
|
14
|
+
if tag in ("b", "i", "u", "s", "code", "pre", "a", "span", "blockquote"):
|
|
15
|
+
self.open_tags.append((tag, attrs))
|
|
16
|
+
|
|
17
|
+
def handle_endtag(self, tag):
|
|
18
|
+
for i in range(len(self.open_tags) - 1, -1, -1):
|
|
19
|
+
if self.open_tags[i][0] == tag:
|
|
20
|
+
del self.open_tags[i]
|
|
21
|
+
break
|
|
22
|
+
|
|
23
|
+
def get_open_tags_html(self):
|
|
24
|
+
parts = []
|
|
25
|
+
for tag, attrs in self.open_tags:
|
|
26
|
+
attr_str = ""
|
|
27
|
+
if attrs:
|
|
28
|
+
attr_str = " " + " ".join(f'{k}="{v}"' for k, v in attrs)
|
|
29
|
+
parts.append(f"<{tag}{attr_str}>")
|
|
30
|
+
return "".join(parts)
|
|
31
|
+
|
|
32
|
+
def get_closing_tags_html(self):
|
|
33
|
+
return "".join(f"</{tag}>" for tag, _ in reversed(self.open_tags))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def split_pre_block(pre_block: str) -> list[str]:
|
|
37
|
+
# language-aware: <pre><code class="language-python">...</code></pre>
|
|
38
|
+
match = re.match(r"<pre><code(.*?)>(.*)</code></pre>", pre_block, re.DOTALL)
|
|
39
|
+
if match:
|
|
40
|
+
attr, content = match.groups()
|
|
41
|
+
lines = content.splitlines(keepends=True)
|
|
42
|
+
chunks, buf = [], ""
|
|
43
|
+
for line in lines:
|
|
44
|
+
if len(buf) + len(line) + len('<pre><code></code></pre>') > MAX_LENGTH:
|
|
45
|
+
chunks.append(f"<pre><code{attr}>{buf}</code></pre>")
|
|
46
|
+
buf = ""
|
|
47
|
+
buf += line
|
|
48
|
+
if buf:
|
|
49
|
+
chunks.append(f"<pre><code{attr}>{buf}</code></pre>")
|
|
50
|
+
return chunks
|
|
51
|
+
else:
|
|
52
|
+
# regular <pre>...</pre>
|
|
53
|
+
inner = pre_block[5:-6]
|
|
54
|
+
lines = inner.splitlines(keepends=True)
|
|
55
|
+
chunks, buf = [], ""
|
|
56
|
+
for line in lines:
|
|
57
|
+
if len(buf) + len(line) + len('<pre></pre>') > MAX_LENGTH:
|
|
58
|
+
chunks.append(f"<pre>{buf}</pre>")
|
|
59
|
+
buf = ""
|
|
60
|
+
buf += line
|
|
61
|
+
if buf:
|
|
62
|
+
chunks.append(f"<pre>{buf}</pre>")
|
|
63
|
+
return chunks
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def split_html_for_telegram(text: str) -> list[str]:
|
|
67
|
+
chunks = []
|
|
68
|
+
pattern = re.compile(r"(<pre>.*?</pre>|<pre><code.*?</code></pre>)", re.DOTALL)
|
|
69
|
+
parts = pattern.split(text)
|
|
70
|
+
|
|
71
|
+
for part in parts:
|
|
72
|
+
if not part:
|
|
73
|
+
continue
|
|
74
|
+
if part.startswith("<pre>") or part.startswith("<pre><code"):
|
|
75
|
+
pre_chunks = split_pre_block(part)
|
|
76
|
+
chunks.extend(pre_chunks)
|
|
77
|
+
else:
|
|
78
|
+
# breaking down regular HTML
|
|
79
|
+
tracker = HTMLTagTracker()
|
|
80
|
+
current = ""
|
|
81
|
+
blocks = re.split(r"(\n\s*\n|<br\s*/?>|\n)", part)
|
|
82
|
+
for block in blocks:
|
|
83
|
+
prospective = current + block
|
|
84
|
+
if len(prospective) > MAX_LENGTH:
|
|
85
|
+
tracker.feed(current)
|
|
86
|
+
open_tags = tracker.get_open_tags_html()
|
|
87
|
+
close_tags = tracker.get_closing_tags_html()
|
|
88
|
+
chunks.append(open_tags + current + close_tags)
|
|
89
|
+
current = block
|
|
90
|
+
tracker = HTMLTagTracker()
|
|
91
|
+
else:
|
|
92
|
+
current = prospective
|
|
93
|
+
if current.strip():
|
|
94
|
+
tracker.feed(current)
|
|
95
|
+
open_tags = tracker.get_open_tags_html()
|
|
96
|
+
close_tags = tracker.get_closing_tags_html()
|
|
97
|
+
chunks.append(open_tags + current + close_tags)
|
|
98
|
+
|
|
99
|
+
# post-unification: combine chunks if they don't exceed the limit in total
|
|
100
|
+
merged_chunks = []
|
|
101
|
+
buf = ""
|
|
102
|
+
for chunk in chunks:
|
|
103
|
+
# chunk = chunk.lstrip("\n") # removing leading line breaks
|
|
104
|
+
|
|
105
|
+
if len(buf) + len(chunk) <= MAX_LENGTH:
|
|
106
|
+
buf += chunk
|
|
107
|
+
else:
|
|
108
|
+
if buf:
|
|
109
|
+
merged_chunks.append(buf)
|
|
110
|
+
buf = chunk
|
|
111
|
+
if buf:
|
|
112
|
+
merged_chunks.append(buf)
|
|
113
|
+
|
|
114
|
+
return merged_chunks
|
{chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter.egg-info/PKG-INFO
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chatgpt_md_converter
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.7
|
|
4
4
|
Summary: A package for converting markdown to HTML for chat Telegram bots
|
|
5
|
-
Home-page: https://github.com/
|
|
5
|
+
Home-page: https://github.com/botfather-dev/formatter-chatgpt-telegram
|
|
6
6
|
Author: Kostiantyn Kriuchkov
|
|
7
7
|
Author-email: latand666@gmail.com
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
{chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter.egg-info/SOURCES.txt
RENAMED
|
@@ -5,9 +5,11 @@ chatgpt_md_converter/converters.py
|
|
|
5
5
|
chatgpt_md_converter/extractors.py
|
|
6
6
|
chatgpt_md_converter/formatters.py
|
|
7
7
|
chatgpt_md_converter/helpers.py
|
|
8
|
+
chatgpt_md_converter/html_splitter.py
|
|
8
9
|
chatgpt_md_converter/telegram_formatter.py
|
|
9
10
|
chatgpt_md_converter.egg-info/PKG-INFO
|
|
10
11
|
chatgpt_md_converter.egg-info/SOURCES.txt
|
|
11
12
|
chatgpt_md_converter.egg-info/dependency_links.txt
|
|
12
13
|
chatgpt_md_converter.egg-info/top_level.txt
|
|
13
|
-
tests/test_parser.py
|
|
14
|
+
tests/test_parser.py
|
|
15
|
+
tests/test_splitter.py
|
|
@@ -2,13 +2,13 @@ from setuptools import setup
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="chatgpt_md_converter",
|
|
5
|
-
version="0.3.
|
|
5
|
+
version="0.3.7",
|
|
6
6
|
author="Kostiantyn Kriuchkov",
|
|
7
7
|
author_email="latand666@gmail.com",
|
|
8
8
|
description="A package for converting markdown to HTML for chat Telegram bots",
|
|
9
9
|
long_description=open("README.MD").read(),
|
|
10
10
|
long_description_content_type="text/markdown",
|
|
11
|
-
url="https://github.com/
|
|
11
|
+
url="https://github.com/botfather-dev/formatter-chatgpt-telegram",
|
|
12
12
|
classifiers=[
|
|
13
13
|
"Programming Language :: Python :: 3",
|
|
14
14
|
"License :: OSI Approved :: MIT License",
|
|
@@ -730,3 +730,188 @@ def test_ukrainian_text_with_inline_code():
|
|
|
730
730
|
expected_output = """звісно, майстре тестування. ой та зрозуміло <code><LAUGH></code> що ти тут тестуєш."""
|
|
731
731
|
output = telegram_format(input_text)
|
|
732
732
|
assert output == expected_output, f"Output was: {output}"
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
def test_nested_code_fence_quadruple():
|
|
736
|
+
input_text = """````markdown
|
|
737
|
+
```python
|
|
738
|
+
def hello_world():
|
|
739
|
+
print("Hello, World!")
|
|
740
|
+
```
|
|
741
|
+
````"""
|
|
742
|
+
expected_output = (
|
|
743
|
+
"<pre><code class=\"language-markdown\">```python\n"
|
|
744
|
+
"def hello_world():\n print(\"Hello, World!\")\n```\n</code></pre>"
|
|
745
|
+
)
|
|
746
|
+
output = telegram_format(input_text)
|
|
747
|
+
def show_output():
|
|
748
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
749
|
+
print(f"output was: \n\n{output}")
|
|
750
|
+
assert output == expected_output, show_output()
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
def test_nested_code_fence_quadruple_no_lang():
|
|
754
|
+
input_text = """````
|
|
755
|
+
```python
|
|
756
|
+
print('hi')
|
|
757
|
+
```
|
|
758
|
+
````"""
|
|
759
|
+
expected_output = (
|
|
760
|
+
"<pre><code>```python\nprint('hi')\n```\n</code></pre>"
|
|
761
|
+
)
|
|
762
|
+
output = telegram_format(input_text)
|
|
763
|
+
def show_output():
|
|
764
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
765
|
+
print(f"output was: \n\n{output}")
|
|
766
|
+
assert output == expected_output, show_output()
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
def test_nested_code_fence_five_backticks():
|
|
770
|
+
input_text = """`````markdown
|
|
771
|
+
````python
|
|
772
|
+
print(1)
|
|
773
|
+
````
|
|
774
|
+
`````"""
|
|
775
|
+
expected_output = (
|
|
776
|
+
"<pre><code class=\"language-markdown\">````python\nprint(1)\n````\n</code></pre>"
|
|
777
|
+
)
|
|
778
|
+
output = telegram_format(input_text)
|
|
779
|
+
def show_output():
|
|
780
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
781
|
+
print(f"output was: \n\n{output}")
|
|
782
|
+
assert output == expected_output, show_output()
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
def test_nested_code_fence_five_backticks_with_inner_triple():
|
|
786
|
+
input_text = """`````markdown
|
|
787
|
+
````python
|
|
788
|
+
print("hello world ```")
|
|
789
|
+
````
|
|
790
|
+
`````"""
|
|
791
|
+
expected_output = (
|
|
792
|
+
"<pre><code class=\"language-markdown\">````python\n"
|
|
793
|
+
"print(\"hello world ```\")\n````\n</code></pre>"
|
|
794
|
+
)
|
|
795
|
+
output = telegram_format(input_text)
|
|
796
|
+
def show_output():
|
|
797
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
798
|
+
print(f"output was: \n\n{output}")
|
|
799
|
+
assert output == expected_output, show_output()
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
def test_nested_code_fence_six_backticks():
|
|
803
|
+
input_text = """``````markdown
|
|
804
|
+
`````python
|
|
805
|
+
print('hi')
|
|
806
|
+
`````
|
|
807
|
+
``````"""
|
|
808
|
+
expected_output = """<pre><code class=\"language-markdown\">`````python
|
|
809
|
+
print('hi')
|
|
810
|
+
`````
|
|
811
|
+
</code></pre>"""
|
|
812
|
+
output = telegram_format(input_text)
|
|
813
|
+
def show_output():
|
|
814
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
815
|
+
print(f"output was: \n\n{output}")
|
|
816
|
+
assert output == expected_output, show_output()
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
def test_nested_code_fence_plain_text():
|
|
820
|
+
input_text = """
|
|
821
|
+
````markdown
|
|
822
|
+
```
|
|
823
|
+
hello
|
|
824
|
+
```
|
|
825
|
+
````"""
|
|
826
|
+
expected_output = """<pre><code class=\"language-markdown\">```
|
|
827
|
+
hello
|
|
828
|
+
```
|
|
829
|
+
</code></pre>"""
|
|
830
|
+
output = telegram_format(input_text)
|
|
831
|
+
def show_output():
|
|
832
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
833
|
+
print(f"output was: \n\n{output}")
|
|
834
|
+
assert output == expected_output, show_output()
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
def test_expensive_nested_code_five_fence_plain_text():
|
|
841
|
+
input_text = """
|
|
842
|
+
`````markdown
|
|
843
|
+
````
|
|
844
|
+
```python
|
|
845
|
+
print("hello world ```")
|
|
846
|
+
```
|
|
847
|
+
`````"""
|
|
848
|
+
|
|
849
|
+
expected_output = """<pre><code class=\"language-markdown\">````
|
|
850
|
+
```python
|
|
851
|
+
print("hello world ```")
|
|
852
|
+
```
|
|
853
|
+
</code></pre>"""
|
|
854
|
+
output = telegram_format(input_text)
|
|
855
|
+
def show_output():
|
|
856
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
857
|
+
print(f"output was: \n\n{output}")
|
|
858
|
+
assert output == expected_output, show_output()
|
|
859
|
+
|
|
860
|
+
def test_another_expensive_nested_code_five_fence_plain_text():
|
|
861
|
+
input_text = """`````markdown
|
|
862
|
+
````python
|
|
863
|
+
print("hello world ```"')
|
|
864
|
+
```
|
|
865
|
+
`````"""
|
|
866
|
+
|
|
867
|
+
expected_output = """<pre><code class=\"language-markdown\">````python
|
|
868
|
+
print("hello world ```"')
|
|
869
|
+
```
|
|
870
|
+
</code></pre>"""
|
|
871
|
+
output = telegram_format(input_text)
|
|
872
|
+
def show_output():
|
|
873
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
874
|
+
print(f"output was: \n\n{output}")
|
|
875
|
+
assert output == expected_output, show_output()
|
|
876
|
+
|
|
877
|
+
def test_hard_level_nested_code_five_fence_plain_text():
|
|
878
|
+
input_text = """`````markdown
|
|
879
|
+
````python
|
|
880
|
+
print("hello world ```"')
|
|
881
|
+
````
|
|
882
|
+
`````
|
|
883
|
+
```python
|
|
884
|
+
print("Some another text")""" # That's where closing the second block of python code is missing.
|
|
885
|
+
|
|
886
|
+
expected_output = """<pre><code class="language-markdown">````python
|
|
887
|
+
print("hello world ```"')
|
|
888
|
+
````
|
|
889
|
+
</code></pre>
|
|
890
|
+
<pre><code class="language-python">print("Some another text")
|
|
891
|
+
</code></pre>""" # But the code block is still closed correctly.
|
|
892
|
+
|
|
893
|
+
output = telegram_format(input_text)
|
|
894
|
+
def show_output():
|
|
895
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
896
|
+
print(f"output was: \n\n{output}")
|
|
897
|
+
assert output == expected_output, show_output()
|
|
898
|
+
|
|
899
|
+
def test_hard_level_nested_code_five_fence_plain_text_2():
|
|
900
|
+
input_text = """`````markdown
|
|
901
|
+
````python
|
|
902
|
+
print("hello world ```"')
|
|
903
|
+
`````
|
|
904
|
+
```python
|
|
905
|
+
print("Some another text")""" # That's where closing the second block of python code is missing.
|
|
906
|
+
|
|
907
|
+
expected_output = """<pre><code class="language-markdown">````python
|
|
908
|
+
print("hello world ```"')
|
|
909
|
+
</code></pre>
|
|
910
|
+
<pre><code class="language-python">print("Some another text")
|
|
911
|
+
</code></pre>""" # But the code block is still closed correctly.
|
|
912
|
+
|
|
913
|
+
output = telegram_format(input_text)
|
|
914
|
+
def show_output():
|
|
915
|
+
print(f"Expected was: \n\n{expected_output}\n\n")
|
|
916
|
+
print(f"output was: \n\n{output}")
|
|
917
|
+
assert output == expected_output, show_output()
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
from chatgpt_md_converter.html_splitter import split_html_for_telegram
|
|
2
|
+
|
|
3
|
+
input_text ="""
|
|
4
|
+
Absolutely! Here’s a Markdown-formatted message exceeding 5,000 characters, exploring <b>The History and Impact of Computer Programming</b>. (You can verify the character count using any online tool.)
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<b>The History and Impact of Computer Programming</b>
|
|
9
|
+
|
|
10
|
+
<i>“The computer was born to solve problems that did not exist before.”</i>
|
|
11
|
+
— Bill Gates
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<b>Table of Contents</b>
|
|
16
|
+
|
|
17
|
+
1. <a href="#introduction">Introduction</a>
|
|
18
|
+
2. <a href="#ancient-beginnings-from-algorithms-to-machines">Ancient Beginnings: From Algorithms to Machines</a>
|
|
19
|
+
• <a href="#al-khwarizmi-and-the-algorithm">Al-Khwarizmi and the Algorithm</a>
|
|
20
|
+
• <a href="#the-analytical-engine">The Analytical Engine</a>
|
|
21
|
+
• <a href="#punch-cards-and-the-jacquard-loom">Punch Cards and the Jacquard Loom</a>
|
|
22
|
+
3. <a href="#20th-century-the-birth-of-modern-programming">20th Century: The Birth of Modern Programming</a>
|
|
23
|
+
• <a href="#eniac-and-early-programmers">ENIAC and Early Programmers</a>
|
|
24
|
+
• <a href="#assembly-language-and-early-high-level-languages">Assembly Language and Early High-level Languages</a>
|
|
25
|
+
• <a href="#cobol-fortran-and-the-expansion">COBOL, FORTRAN, and the Expansion</a>
|
|
26
|
+
4. <a href="#modern-era-languages-paradigms-and-the-internet">Modern Era: Languages, Paradigms, and the Internet</a>
|
|
27
|
+
• <a href="#object-oriented-programming">Object-Oriented Programming</a>
|
|
28
|
+
• <a href="#internet-and-open-source">Internet and Open Source</a>
|
|
29
|
+
• <a href="#mobile-and-cloud-computing">Mobile and Cloud Computing</a>
|
|
30
|
+
5. <a href="#programmings-societal-impact">Programming’s Societal Impact</a>
|
|
31
|
+
6. <a href="#ethics-challenges-and-the-future">Ethics, Challenges, and the Future</a>
|
|
32
|
+
7. <a href="#conclusion">Conclusion</a>
|
|
33
|
+
8. <a href="#useful-resources">Useful Resources</a>
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<b>Introduction</b>
|
|
38
|
+
|
|
39
|
+
Computer programming is the science and art of giving computers instructions to perform specific tasks. Today, it's impossible to imagine a world without software: from banking systems and mobile applications to traffic lights and airplanes, programming is everywhere.
|
|
40
|
+
|
|
41
|
+
But how did programming begin, and what has it become today? This document explores the journey of programming, from ancient mathematical roots to the future of artificial intelligence.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
<b>Ancient Beginnings: From Algorithms to Machines</b>
|
|
46
|
+
|
|
47
|
+
<b>Al-Khwarizmi and the Algorithm</b>
|
|
48
|
+
|
|
49
|
+
The term "<b>algorithm</b>" (the foundation of programming) comes from Abu Abdullah Muhammad ibn Musa Al-Khwarizmi, a 9th-century Persian mathematician. His works on systematic procedures laid the groundwork for computational thinking.
|
|
50
|
+
|
|
51
|
+
<b>The Analytical Engine</b>
|
|
52
|
+
|
|
53
|
+
In the 19th century, <b>Charles Babbage</b> designed the Analytical Engine, a mechanical general-purpose computer. Though never built in his lifetime, it could—in theory—read instructions from punched cards.
|
|
54
|
+
|
|
55
|
+
<b>Ada Lovelace</b>, Babbage's collaborator, is often called the first computer programmer. She wrote notes describing algorithms (in essence, programs) for the Analytical Engine to compute Bernoulli numbers.
|
|
56
|
+
|
|
57
|
+
<blockquote>"That brain of mine is something more than merely mortal; as time will show."
|
|
58
|
+
– Ada Lovelace</blockquote>
|
|
59
|
+
|
|
60
|
+
<b>Punch Cards and the Jacquard Loom</b>
|
|
61
|
+
|
|
62
|
+
The concept of programming a machine with punched cards predates computers. <b>Joseph Marie Jacquard</b> invented a loom in 1804 that used punched cards to control patterns in woven fabric—an early example of machine automation.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
<b>20th Century: The Birth of Modern Programming</b>
|
|
67
|
+
|
|
68
|
+
<b>ENIAC and Early Programmers</b>
|
|
69
|
+
|
|
70
|
+
ENIAC (Electronic Numerical Integrator and Computer), completed in 1945, is often cited as the first electronic general-purpose computer.
|
|
71
|
+
|
|
72
|
+
Early programming was entirely manual and physically laborious—think patch cables and switches!
|
|
73
|
+
|
|
74
|
+
Notably, many of the earliest programmers were women, such as <b>Kathleen McNulty</b>, <b>Jean Jennings</b>, and <b>Grace Hopper</b>.
|
|
75
|
+
|
|
76
|
+
<b>Assembly Language and Early High-level Languages</b>
|
|
77
|
+
|
|
78
|
+
The problem of complexity led to <b>assembly languages</b>, where mnemonics like <code>MOV</code> and <code>ADD</code> replaced binary codes. Programming became more accessible, but code was still hardware-specific.
|
|
79
|
+
|
|
80
|
+
The 1950s saw the creation of:
|
|
81
|
+
|
|
82
|
+
• <b>FORTRAN</b> (FORmula TRANslation) for scientific computation
|
|
83
|
+
• <b>COBOL</b> (COmmon Business-Oriented Language) for business applications
|
|
84
|
+
|
|
85
|
+
<b>Code Example: Hello World in COBOL</b>
|
|
86
|
+
<pre><code class="language-cobol">IDENTIFICATION DIVISION.
|
|
87
|
+
PROGRAM-ID. HELLO-WORLD.
|
|
88
|
+
PROCEDURE DIVISION.
|
|
89
|
+
DISPLAY "Hello, World!".
|
|
90
|
+
STOP RUN.
|
|
91
|
+
</code></pre>
|
|
92
|
+
|
|
93
|
+
<b>COBOL, FORTRAN, and the Expansion</b>
|
|
94
|
+
|
|
95
|
+
With the advent of high-level languages, programming became less about circuitry and more about solving problems. Standardized languages allowed code to run on multiple machines.
|
|
96
|
+
|
|
97
|
+
Other languages soon emerged:
|
|
98
|
+
|
|
99
|
+
• <b>LISP</b> (for AI research)
|
|
100
|
+
• <b>ALGOL</b> (basis for many future languages)
|
|
101
|
+
• <b>BASIC</b> (for beginners and education)
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
<b>Modern Era: Languages, Paradigms, and the Internet</b>
|
|
106
|
+
|
|
107
|
+
<b>Object-Oriented Programming</b>
|
|
108
|
+
|
|
109
|
+
The 1970s and 1980s introduced <b>object-oriented programming</b> (OOP), where data and behavior are bundled together. The most influential languages here include:
|
|
110
|
+
|
|
111
|
+
• <b>Smalltalk</b>: pioneered OOP concepts
|
|
112
|
+
• <b>C++</b>: combined OOP with the efficiency of C
|
|
113
|
+
• <b>Java</b>: “Write Once, Run Anywhere” with the Java Virtual Machine
|
|
114
|
+
|
|
115
|
+
<b>Code Example: Simple Class in Java</b>
|
|
116
|
+
<pre><code class="language-java">public class HelloWorld {
|
|
117
|
+
public static void main(String[] args) {
|
|
118
|
+
System.out.println("Hello, World!");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</code></pre>
|
|
122
|
+
|
|
123
|
+
<b>Internet and Open Source</b>
|
|
124
|
+
|
|
125
|
+
The rise of the World Wide Web transformed programming. JavaScript, PHP, and Python became staples for Internet-connected software.
|
|
126
|
+
|
|
127
|
+
<b>Open source</b> projects like Linux, Apache, and MySQL changed collaboration forever—developers worldwide could contribute to shared codebases.
|
|
128
|
+
|
|
129
|
+
| Year | Technology | Impact |
|
|
130
|
+
|------|-------------|-----------------------------------------|
|
|
131
|
+
| 1991 | Linux | Free, open-source operating systems |
|
|
132
|
+
| 1995 | JavaScript | Interactive web applications |
|
|
133
|
+
| 2001 | Wikipedia | Collaborative knowledge base |
|
|
134
|
+
|
|
135
|
+
<b>Mobile and Cloud Computing</b>
|
|
136
|
+
|
|
137
|
+
Smartphones spawned new languages and frameworks (Swift, Kotlin, React Native).
|
|
138
|
+
|
|
139
|
+
<b>Cloud computing</b> and <b>APIs</b> mean programs can collaborate on a global scale, in real-time.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
<b>Programming’s Societal Impact</b>
|
|
144
|
+
|
|
145
|
+
Programming is reshaping society in profound ways:
|
|
146
|
+
|
|
147
|
+
• <b>Healthcare</b>: Medical imaging, diagnostics, record management
|
|
148
|
+
• <b>Finance</b>: Online banking, stock trading algorithms
|
|
149
|
+
• <b>Entertainment</b>: Gaming, music streaming, social networks
|
|
150
|
+
• <b>Education</b>: E-learning, interactive simulations, content platforms
|
|
151
|
+
• <b>Transportation</b>: Navigation, ride-sharing apps, autonomous vehicles
|
|
152
|
+
• <b>Science</b>: Processing large datasets, running complex simulations
|
|
153
|
+
|
|
154
|
+
<blockquote>“Software is eating the world.”
|
|
155
|
+
– Marc Andreessen</blockquote>
|
|
156
|
+
|
|
157
|
+
<b>Programming Jobs In Demand</b>
|
|
158
|
+
|
|
159
|
+
<pre><code class="language-mermaid">pie
|
|
160
|
+
title Programming Job Market (2024)
|
|
161
|
+
"Web Development" : 31
|
|
162
|
+
"Data Science" : 22
|
|
163
|
+
"Mobile Development" : 12
|
|
164
|
+
"Embedded Systems" : 8
|
|
165
|
+
"Cybersecurity" : 9
|
|
166
|
+
"Other": 18
|
|
167
|
+
</code></pre>
|
|
168
|
+
|
|
169
|
+
<b>Note:</b> Mermaid diagrams require compatible renderers (e.g., GitHub, Obsidian).
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
<b>Ethics, Challenges, and the Future</b>
|
|
174
|
+
|
|
175
|
+
With great power comes responsibility. Programmers face new challenges:
|
|
176
|
+
|
|
177
|
+
• <b>Bias in Algorithms:</b> Unintentional biases in data can lead to unfair outcomes (e.g., in hiring software or criminal justice prediction).
|
|
178
|
+
• <b>Privacy:</b> Handling personal data securely is more critical than ever.
|
|
179
|
+
• <b>Safety:</b> In fields like self-driving cars or medical devices, software bugs can have real-world consequences.
|
|
180
|
+
• <b>Sustainability:</b> Software should be efficient, minimizing environmental impact in data centers.
|
|
181
|
+
|
|
182
|
+
<b>Emerging Trends:</b>
|
|
183
|
+
|
|
184
|
+
• <b>Artificial Intelligence:</b> Programs that learn, adapt, and sometimes surprise their creators.
|
|
185
|
+
• <b>Quantum Computing:</b> New paradigms for solving currently intractable problems.
|
|
186
|
+
• <b>No-Code/Low-Code:</b> Empowering more people to harness computational power.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
<b>Conclusion</b>
|
|
191
|
+
|
|
192
|
+
From mechanical looms to neural networks, programming continues to redefine what’s possible. It’s not just for professional engineers: millions of people use programming as a tool for art, science, business, and personal growth.
|
|
193
|
+
|
|
194
|
+
<b>Everyone can learn to code.</b> It might change your life—or even the world.
|
|
195
|
+
|
|
196
|
+
<blockquote>"Any sufficiently advanced technology is indistinguishable from magic."
|
|
197
|
+
— Arthur C. Clarke</blockquote>
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
<b>Useful Resources</b>
|
|
202
|
+
|
|
203
|
+
• <a href="https://www-cs-faculty.stanford.edu/~knuth/taocp.html">The Art of Computer Programming (Donald Knuth)</a>
|
|
204
|
+
• <a href="https://www.khanacademy.org/computing/computer-programming">Khan Academy Computer Programming</a>
|
|
205
|
+
• <a href="https://www.w3schools.com/">W3Schools Online Tutorials</a>
|
|
206
|
+
• <a href="https://www.freecodecamp.org/">freeCodeCamp</a>
|
|
207
|
+
• <a href="https://stackoverflow.com/">Stack Overflow</a>
|
|
208
|
+
• <a href="https://guides.github.com/">GitHub Guides</a>
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
<i>Thank you for reading! If you’re inspired to begin your coding journey, there has never been a better time to start.</i>
|
|
213
|
+
|
|
214
|
+
---"""
|
|
215
|
+
|
|
216
|
+
valid_chunk_1 = """
|
|
217
|
+
Absolutely! Here’s a Markdown-formatted message exceeding 5,000 characters, exploring <b>The History and Impact of Computer Programming</b>. (You can verify the character count using any online tool.)
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
<b>The History and Impact of Computer Programming</b>
|
|
222
|
+
|
|
223
|
+
<i>“The computer was born to solve problems that did not exist before.”</i>
|
|
224
|
+
— Bill Gates
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
<b>Table of Contents</b>
|
|
229
|
+
|
|
230
|
+
1. <a href="#introduction">Introduction</a>
|
|
231
|
+
2. <a href="#ancient-beginnings-from-algorithms-to-machines">Ancient Beginnings: From Algorithms to Machines</a>
|
|
232
|
+
• <a href="#al-khwarizmi-and-the-algorithm">Al-Khwarizmi and the Algorithm</a>
|
|
233
|
+
• <a href="#the-analytical-engine">The Analytical Engine</a>
|
|
234
|
+
• <a href="#punch-cards-and-the-jacquard-loom">Punch Cards and the Jacquard Loom</a>
|
|
235
|
+
3. <a href="#20th-century-the-birth-of-modern-programming">20th Century: The Birth of Modern Programming</a>
|
|
236
|
+
• <a href="#eniac-and-early-programmers">ENIAC and Early Programmers</a>
|
|
237
|
+
• <a href="#assembly-language-and-early-high-level-languages">Assembly Language and Early High-level Languages</a>
|
|
238
|
+
• <a href="#cobol-fortran-and-the-expansion">COBOL, FORTRAN, and the Expansion</a>
|
|
239
|
+
4. <a href="#modern-era-languages-paradigms-and-the-internet">Modern Era: Languages, Paradigms, and the Internet</a>
|
|
240
|
+
• <a href="#object-oriented-programming">Object-Oriented Programming</a>
|
|
241
|
+
• <a href="#internet-and-open-source">Internet and Open Source</a>
|
|
242
|
+
• <a href="#mobile-and-cloud-computing">Mobile and Cloud Computing</a>
|
|
243
|
+
5. <a href="#programmings-societal-impact">Programming’s Societal Impact</a>
|
|
244
|
+
6. <a href="#ethics-challenges-and-the-future">Ethics, Challenges, and the Future</a>
|
|
245
|
+
7. <a href="#conclusion">Conclusion</a>
|
|
246
|
+
8. <a href="#useful-resources">Useful Resources</a>
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
<b>Introduction</b>
|
|
251
|
+
|
|
252
|
+
Computer programming is the science and art of giving computers instructions to perform specific tasks. Today, it's impossible to imagine a world without software: from banking systems and mobile applications to traffic lights and airplanes, programming is everywhere.
|
|
253
|
+
|
|
254
|
+
But how did programming begin, and what has it become today? This document explores the journey of programming, from ancient mathematical roots to the future of artificial intelligence.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
<b>Ancient Beginnings: From Algorithms to Machines</b>
|
|
259
|
+
|
|
260
|
+
<b>Al-Khwarizmi and the Algorithm</b>
|
|
261
|
+
|
|
262
|
+
The term "<b>algorithm</b>" (the foundation of programming) comes from Abu Abdullah Muhammad ibn Musa Al-Khwarizmi, a 9th-century Persian mathematician. His works on systematic procedures laid the groundwork for computational thinking.
|
|
263
|
+
|
|
264
|
+
<b>The Analytical Engine</b>
|
|
265
|
+
|
|
266
|
+
In the 19th century, <b>Charles Babbage</b> designed the Analytical Engine, a mechanical general-purpose computer. Though never built in his lifetime, it could—in theory—read instructions from punched cards.
|
|
267
|
+
|
|
268
|
+
<b>Ada Lovelace</b>, Babbage's collaborator, is often called the first computer programmer. She wrote notes describing algorithms (in essence, programs) for the Analytical Engine to compute Bernoulli numbers.
|
|
269
|
+
|
|
270
|
+
<blockquote>"That brain of mine is something more than merely mortal; as time will show."
|
|
271
|
+
– Ada Lovelace</blockquote>
|
|
272
|
+
|
|
273
|
+
<b>Punch Cards and the Jacquard Loom</b>
|
|
274
|
+
|
|
275
|
+
The concept of programming a machine with punched cards predates computers. <b>Joseph Marie Jacquard</b> invented a loom in 1804 that used punched cards to control patterns in woven fabric—an early example of machine automation.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
<b>20th Century: The Birth of Modern Programming</b>
|
|
280
|
+
|
|
281
|
+
<b>ENIAC and Early Programmers</b>
|
|
282
|
+
|
|
283
|
+
ENIAC (Electronic Numerical Integrator and Computer), completed in 1945, is often cited as the first electronic general-purpose computer.
|
|
284
|
+
|
|
285
|
+
Early programming was entirely manual and physically laborious—think patch cables and switches!
|
|
286
|
+
|
|
287
|
+
Notably, many of the earliest programmers were women, such as <b>Kathleen McNulty</b>, <b>Jean Jennings</b>, and <b>Grace Hopper</b>.
|
|
288
|
+
|
|
289
|
+
<b>Assembly Language and Early High-level Languages</b>
|
|
290
|
+
|
|
291
|
+
"""
|
|
292
|
+
|
|
293
|
+
valid_chunk_2 = """The problem of complexity led to <b>assembly languages</b>, where mnemonics like <code>MOV</code> and <code>ADD</code> replaced binary codes. Programming became more accessible, but code was still hardware-specific.
|
|
294
|
+
|
|
295
|
+
The 1950s saw the creation of:
|
|
296
|
+
|
|
297
|
+
• <b>FORTRAN</b> (FORmula TRANslation) for scientific computation
|
|
298
|
+
• <b>COBOL</b> (COmmon Business-Oriented Language) for business applications
|
|
299
|
+
|
|
300
|
+
<b>Code Example: Hello World in COBOL</b>
|
|
301
|
+
<pre><code class="language-cobol">IDENTIFICATION DIVISION.
|
|
302
|
+
PROGRAM-ID. HELLO-WORLD.
|
|
303
|
+
PROCEDURE DIVISION.
|
|
304
|
+
DISPLAY "Hello, World!".
|
|
305
|
+
STOP RUN.
|
|
306
|
+
</code></pre>
|
|
307
|
+
|
|
308
|
+
<b>COBOL, FORTRAN, and the Expansion</b>
|
|
309
|
+
|
|
310
|
+
With the advent of high-level languages, programming became less about circuitry and more about solving problems. Standardized languages allowed code to run on multiple machines.
|
|
311
|
+
|
|
312
|
+
Other languages soon emerged:
|
|
313
|
+
|
|
314
|
+
• <b>LISP</b> (for AI research)
|
|
315
|
+
• <b>ALGOL</b> (basis for many future languages)
|
|
316
|
+
• <b>BASIC</b> (for beginners and education)
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
<b>Modern Era: Languages, Paradigms, and the Internet</b>
|
|
321
|
+
|
|
322
|
+
<b>Object-Oriented Programming</b>
|
|
323
|
+
|
|
324
|
+
The 1970s and 1980s introduced <b>object-oriented programming</b> (OOP), where data and behavior are bundled together. The most influential languages here include:
|
|
325
|
+
|
|
326
|
+
• <b>Smalltalk</b>: pioneered OOP concepts
|
|
327
|
+
• <b>C++</b>: combined OOP with the efficiency of C
|
|
328
|
+
• <b>Java</b>: “Write Once, Run Anywhere” with the Java Virtual Machine
|
|
329
|
+
|
|
330
|
+
<b>Code Example: Simple Class in Java</b>
|
|
331
|
+
<pre><code class="language-java">public class HelloWorld {
|
|
332
|
+
public static void main(String[] args) {
|
|
333
|
+
System.out.println("Hello, World!");
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
</code></pre>
|
|
337
|
+
|
|
338
|
+
<b>Internet and Open Source</b>
|
|
339
|
+
|
|
340
|
+
The rise of the World Wide Web transformed programming. JavaScript, PHP, and Python became staples for Internet-connected software.
|
|
341
|
+
|
|
342
|
+
<b>Open source</b> projects like Linux, Apache, and MySQL changed collaboration forever—developers worldwide could contribute to shared codebases.
|
|
343
|
+
|
|
344
|
+
| Year | Technology | Impact |
|
|
345
|
+
|------|-------------|-----------------------------------------|
|
|
346
|
+
| 1991 | Linux | Free, open-source operating systems |
|
|
347
|
+
| 1995 | JavaScript | Interactive web applications |
|
|
348
|
+
| 2001 | Wikipedia | Collaborative knowledge base |
|
|
349
|
+
|
|
350
|
+
<b>Mobile and Cloud Computing</b>
|
|
351
|
+
|
|
352
|
+
Smartphones spawned new languages and frameworks (Swift, Kotlin, React Native).
|
|
353
|
+
|
|
354
|
+
<b>Cloud computing</b> and <b>APIs</b> mean programs can collaborate on a global scale, in real-time.
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
<b>Programming’s Societal Impact</b>
|
|
359
|
+
|
|
360
|
+
Programming is reshaping society in profound ways:
|
|
361
|
+
|
|
362
|
+
• <b>Healthcare</b>: Medical imaging, diagnostics, record management
|
|
363
|
+
• <b>Finance</b>: Online banking, stock trading algorithms
|
|
364
|
+
• <b>Entertainment</b>: Gaming, music streaming, social networks
|
|
365
|
+
• <b>Education</b>: E-learning, interactive simulations, content platforms
|
|
366
|
+
• <b>Transportation</b>: Navigation, ride-sharing apps, autonomous vehicles
|
|
367
|
+
• <b>Science</b>: Processing large datasets, running complex simulations
|
|
368
|
+
|
|
369
|
+
<blockquote>“Software is eating the world.”
|
|
370
|
+
– Marc Andreessen</blockquote>
|
|
371
|
+
|
|
372
|
+
<b>Programming Jobs In Demand</b>
|
|
373
|
+
|
|
374
|
+
<pre><code class="language-mermaid">pie
|
|
375
|
+
title Programming Job Market (2024)
|
|
376
|
+
"Web Development" : 31
|
|
377
|
+
"Data Science" : 22
|
|
378
|
+
"Mobile Development" : 12
|
|
379
|
+
"Embedded Systems" : 8
|
|
380
|
+
"Cybersecurity" : 9
|
|
381
|
+
"Other": 18
|
|
382
|
+
</code></pre>"""
|
|
383
|
+
|
|
384
|
+
valid_chunk_3 = """
|
|
385
|
+
|
|
386
|
+
<b>Note:</b> Mermaid diagrams require compatible renderers (e.g., GitHub, Obsidian).
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
<b>Ethics, Challenges, and the Future</b>
|
|
391
|
+
|
|
392
|
+
With great power comes responsibility. Programmers face new challenges:
|
|
393
|
+
|
|
394
|
+
• <b>Bias in Algorithms:</b> Unintentional biases in data can lead to unfair outcomes (e.g., in hiring software or criminal justice prediction).
|
|
395
|
+
• <b>Privacy:</b> Handling personal data securely is more critical than ever.
|
|
396
|
+
• <b>Safety:</b> In fields like self-driving cars or medical devices, software bugs can have real-world consequences.
|
|
397
|
+
• <b>Sustainability:</b> Software should be efficient, minimizing environmental impact in data centers.
|
|
398
|
+
|
|
399
|
+
<b>Emerging Trends:</b>
|
|
400
|
+
|
|
401
|
+
• <b>Artificial Intelligence:</b> Programs that learn, adapt, and sometimes surprise their creators.
|
|
402
|
+
• <b>Quantum Computing:</b> New paradigms for solving currently intractable problems.
|
|
403
|
+
• <b>No-Code/Low-Code:</b> Empowering more people to harness computational power.
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
<b>Conclusion</b>
|
|
408
|
+
|
|
409
|
+
From mechanical looms to neural networks, programming continues to redefine what’s possible. It’s not just for professional engineers: millions of people use programming as a tool for art, science, business, and personal growth.
|
|
410
|
+
|
|
411
|
+
<b>Everyone can learn to code.</b> It might change your life—or even the world.
|
|
412
|
+
|
|
413
|
+
<blockquote>"Any sufficiently advanced technology is indistinguishable from magic."
|
|
414
|
+
— Arthur C. Clarke</blockquote>
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
<b>Useful Resources</b>
|
|
419
|
+
|
|
420
|
+
• <a href="https://www-cs-faculty.stanford.edu/~knuth/taocp.html">The Art of Computer Programming (Donald Knuth)</a>
|
|
421
|
+
• <a href="https://www.khanacademy.org/computing/computer-programming">Khan Academy Computer Programming</a>
|
|
422
|
+
• <a href="https://www.w3schools.com/">W3Schools Online Tutorials</a>
|
|
423
|
+
• <a href="https://www.freecodecamp.org/">freeCodeCamp</a>
|
|
424
|
+
• <a href="https://stackoverflow.com/">Stack Overflow</a>
|
|
425
|
+
• <a href="https://guides.github.com/">GitHub Guides</a>
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
<i>Thank you for reading! If you’re inspired to begin your coding journey, there has never been a better time to start.</i>
|
|
430
|
+
|
|
431
|
+
---"""
|
|
432
|
+
|
|
433
|
+
def test_splitter_test():
|
|
434
|
+
chunks = split_html_for_telegram(input_text)
|
|
435
|
+
valid_chunks = [valid_chunk_1, valid_chunk_2, valid_chunk_3]
|
|
436
|
+
assert chunks == valid_chunks
|
|
File without changes
|
|
File without changes
|
{chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/converters.py
RENAMED
|
File without changes
|
{chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/formatters.py
RENAMED
|
File without changes
|
|
File without changes
|
{chatgpt_md_converter-0.3.5 → chatgpt_md_converter-0.3.7}/chatgpt_md_converter/telegram_formatter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|