md2linkedin 0.5.2__tar.gz → 0.6.0__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.
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/PKG-INFO +13 -13
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/README.md +12 -12
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/pyproject.toml +3 -7
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/pyproject.toml.orig +4 -6
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/src/md2linkedin/_converter.py +33 -15
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/src/md2linkedin/_unicode.py +45 -15
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/LICENSE.md +0 -0
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/src/md2linkedin/__init__.py +0 -0
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/src/md2linkedin/_cli.py +0 -0
- {md2linkedin-0.5.2 → md2linkedin-0.6.0}/src/md2linkedin/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: md2linkedin
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Convert Markdown to LinkedIn-friendly Unicode text
|
|
5
5
|
Keywords: markdown,linkedin,unicode,formatting,conversion
|
|
6
6
|
Author: Indrajeet Patil
|
|
@@ -48,8 +48,9 @@ platforms like LinkedIn that do not support Markdown natively.
|
|
|
48
48
|
uv add md2linkedin
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
> **Tip:** Run the CLI without installing it
|
|
52
|
-
> `uvx md2linkedin post.md`.
|
|
51
|
+
> **Tip:** Run the CLI without installing it through
|
|
52
|
+
> [`uvx`](https://docs.astral.sh/uv/guides/tools/): `uvx md2linkedin post.md`.
|
|
53
|
+
> Every CLI example below works the same way.
|
|
53
54
|
|
|
54
55
|
## Usage
|
|
55
56
|
|
|
@@ -131,23 +132,22 @@ md2linkedin post.md --no-monospace-code
|
|
|
131
132
|
- **HTML entities**: decoded (`&` → `&`, etc.)
|
|
132
133
|
- **Backslash escapes**: resolved (`\*` → `*`)
|
|
133
134
|
- **Windows line endings**: normalised automatically
|
|
134
|
-
- **
|
|
135
|
+
- **Accented letters**: styled like the letters around them (`**Grüße**` → 𝗚𝗿𝘂̈ß𝗲); `ß`, `ł` and other letters with no ASCII base stay plain
|
|
136
|
+
- **Emojis & other scripts**: pass through unchanged — no accidental corruption
|
|
135
137
|
|
|
136
138
|
## Limitations
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
Styling relies on Unicode Mathematical Alphanumeric Symbols, which has trade-offs:
|
|
139
141
|
|
|
140
|
-
- **Code blocks**:
|
|
141
|
-
- **Tables**:
|
|
142
|
-
- **Accessibility**:
|
|
143
|
-
- **Searchability**:
|
|
144
|
-
- **Markdown extensions**:
|
|
145
|
-
|
|
146
|
-
For more examples, check out the package documentation at:
|
|
147
|
-
<https://www.indrapatil.com/md2linkedin/>
|
|
142
|
+
- **Code blocks**: LinkedIn's proportional font does not keep monospace Unicode characters fixed-width, so indentation and column alignment often break.
|
|
143
|
+
- **Tables**: for the same reason, flattened table columns do not line up; rewrite wide tables as lists.
|
|
144
|
+
- **Accessibility**: screen readers often spell out each styled character (e.g. "mathematical sans-serif bold b") instead of reading whole words.
|
|
145
|
+
- **Searchability**: LinkedIn search may not index styled text, so people searching for those keywords might not find your post.
|
|
146
|
+
- **Markdown extensions**: only CommonMark plus tables, strikethrough, autolinks and `==highlight==` are read. Task-list checkboxes stay as literal `[ ]`/`[x]` and footnotes are flattened (`text[^1]` → `text^1`); see [What Gets Transformed](https://www.indrapatil.com/md2linkedin/advanced/#what-gets-transformed-and-what-doesnt).
|
|
148
147
|
|
|
149
148
|
## See Also
|
|
150
149
|
|
|
150
|
+
- [Documentation](https://www.indrapatil.com/md2linkedin/) — advanced usage, the full conversion table and the API reference.
|
|
151
151
|
- [md2linkedin Web App](https://019d695e-8448-ee38-5db3-7ca4acf2ce2c.share.connect.posit.cloud/) — an interactive web interface for `md2linkedin`, built by [Yann Cohen](https://github.com/iamYannC).
|
|
152
152
|
|
|
153
153
|
## License
|
|
@@ -15,8 +15,9 @@ platforms like LinkedIn that do not support Markdown natively.
|
|
|
15
15
|
uv add md2linkedin
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
> **Tip:** Run the CLI without installing it
|
|
19
|
-
> `uvx md2linkedin post.md`.
|
|
18
|
+
> **Tip:** Run the CLI without installing it through
|
|
19
|
+
> [`uvx`](https://docs.astral.sh/uv/guides/tools/): `uvx md2linkedin post.md`.
|
|
20
|
+
> Every CLI example below works the same way.
|
|
20
21
|
|
|
21
22
|
## Usage
|
|
22
23
|
|
|
@@ -98,23 +99,22 @@ md2linkedin post.md --no-monospace-code
|
|
|
98
99
|
- **HTML entities**: decoded (`&` → `&`, etc.)
|
|
99
100
|
- **Backslash escapes**: resolved (`\*` → `*`)
|
|
100
101
|
- **Windows line endings**: normalised automatically
|
|
101
|
-
- **
|
|
102
|
+
- **Accented letters**: styled like the letters around them (`**Grüße**` → 𝗚𝗿𝘂̈ß𝗲); `ß`, `ł` and other letters with no ASCII base stay plain
|
|
103
|
+
- **Emojis & other scripts**: pass through unchanged — no accidental corruption
|
|
102
104
|
|
|
103
105
|
## Limitations
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
Styling relies on Unicode Mathematical Alphanumeric Symbols, which has trade-offs:
|
|
106
108
|
|
|
107
|
-
- **Code blocks**:
|
|
108
|
-
- **Tables**:
|
|
109
|
-
- **Accessibility**:
|
|
110
|
-
- **Searchability**:
|
|
111
|
-
- **Markdown extensions**:
|
|
112
|
-
|
|
113
|
-
For more examples, check out the package documentation at:
|
|
114
|
-
<https://www.indrapatil.com/md2linkedin/>
|
|
109
|
+
- **Code blocks**: LinkedIn's proportional font does not keep monospace Unicode characters fixed-width, so indentation and column alignment often break.
|
|
110
|
+
- **Tables**: for the same reason, flattened table columns do not line up; rewrite wide tables as lists.
|
|
111
|
+
- **Accessibility**: screen readers often spell out each styled character (e.g. "mathematical sans-serif bold b") instead of reading whole words.
|
|
112
|
+
- **Searchability**: LinkedIn search may not index styled text, so people searching for those keywords might not find your post.
|
|
113
|
+
- **Markdown extensions**: only CommonMark plus tables, strikethrough, autolinks and `==highlight==` are read. Task-list checkboxes stay as literal `[ ]`/`[x]` and footnotes are flattened (`text[^1]` → `text^1`); see [What Gets Transformed](https://www.indrapatil.com/md2linkedin/advanced/#what-gets-transformed-and-what-doesnt).
|
|
115
114
|
|
|
116
115
|
## See Also
|
|
117
116
|
|
|
117
|
+
- [Documentation](https://www.indrapatil.com/md2linkedin/) — advanced usage, the full conversion table and the API reference.
|
|
118
118
|
- [md2linkedin Web App](https://019d695e-8448-ee38-5db3-7ca4acf2ce2c.share.connect.posit.cloud/) — an interactive web interface for `md2linkedin`, built by [Yann Cohen](https://github.com/iamYannC).
|
|
119
119
|
|
|
120
120
|
## License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "md2linkedin"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.6.0"
|
|
4
4
|
description = "Convert Markdown to LinkedIn-friendly Unicode text"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -58,7 +58,7 @@ dev = [
|
|
|
58
58
|
"pyrefly>=1.4.0",
|
|
59
59
|
"pytest>=9.1.1",
|
|
60
60
|
"pytest-codeblocks>=0.18.0",
|
|
61
|
-
"pytest-codspeed==5.0.
|
|
61
|
+
"pytest-codspeed==5.0.4",
|
|
62
62
|
"pytest-cov>=7.1.0",
|
|
63
63
|
"pytest-random-order>=1.2.0",
|
|
64
64
|
"ruff>=0.17.2",
|
|
@@ -134,10 +134,7 @@ skip_empty = true
|
|
|
134
134
|
|
|
135
135
|
[tool.mutmut]
|
|
136
136
|
source_paths = ["src/md2linkedin/"]
|
|
137
|
-
also_copy = [
|
|
138
|
-
"scripts/",
|
|
139
|
-
"README.md",
|
|
140
|
-
]
|
|
137
|
+
also_copy = ["README.md"]
|
|
141
138
|
pytest_add_cli_args_test_selection = ["tests/"]
|
|
142
139
|
mutate_only_covered_lines = true
|
|
143
140
|
|
|
@@ -164,5 +161,4 @@ strict-generic-narrowing = true
|
|
|
164
161
|
required-version = ">=0.13.0"
|
|
165
162
|
|
|
166
163
|
[tool.deptry]
|
|
167
|
-
extend_exclude = ["scripts"]
|
|
168
164
|
known_first_party = ["md2linkedin"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "md2linkedin"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.6.0"
|
|
4
4
|
description = "Convert Markdown to LinkedIn-friendly Unicode text"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -51,7 +51,7 @@ dev = [
|
|
|
51
51
|
"pyrefly>=1.4.0",
|
|
52
52
|
"pytest>=9.1.1",
|
|
53
53
|
"pytest-codeblocks>=0.18.0",
|
|
54
|
-
"pytest-codspeed==5.0.
|
|
54
|
+
"pytest-codspeed==5.0.4",
|
|
55
55
|
"pytest-cov>=7.1.0",
|
|
56
56
|
"pytest-random-order>=1.2.0",
|
|
57
57
|
"ruff>=0.17.2",
|
|
@@ -147,9 +147,8 @@ skip_empty = true
|
|
|
147
147
|
|
|
148
148
|
[tool.mutmut]
|
|
149
149
|
source_paths = ["src/md2linkedin/"]
|
|
150
|
-
#
|
|
151
|
-
|
|
152
|
-
also_copy = ["scripts/", "README.md"]
|
|
150
|
+
# tests/test_readme.py runs the examples in README.md.
|
|
151
|
+
also_copy = ["README.md"]
|
|
153
152
|
pytest_add_cli_args_test_selection = ["tests/"]
|
|
154
153
|
# Only mutate lines exercised by the test suite so mutmut concentrates on
|
|
155
154
|
# meaningful mutations that the tests should actually catch.
|
|
@@ -181,5 +180,4 @@ strict-generic-narrowing = true
|
|
|
181
180
|
required-version = ">=0.13.0"
|
|
182
181
|
|
|
183
182
|
[tool.deptry]
|
|
184
|
-
extend_exclude = ["scripts"]
|
|
185
183
|
known_first_party = ["md2linkedin"]
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
"""Markdown to LinkedIn-ready Unicode text conversion.
|
|
2
|
+
|
|
3
|
+
``comrak`` renders the Markdown as HTML, and ``Renderer`` walks the
|
|
4
|
+
``selectolax`` tree of that HTML, writing its text with the Unicode styles of
|
|
5
|
+
the enclosing tags applied.
|
|
6
|
+
"""
|
|
7
|
+
|
|
1
8
|
# Python 3.15+ (PEP 810) defers these imports until first use, so that
|
|
2
9
|
# ``import md2linkedin``, ``--help`` and ``--version`` skip loading the parser
|
|
3
10
|
# extensions. Earlier versions ignore this and import eagerly.
|
|
@@ -6,11 +13,12 @@ __lazy_modules__ = ["comrak", "selectolax.lexbor"]
|
|
|
6
13
|
import re
|
|
7
14
|
from dataclasses import dataclass
|
|
8
15
|
from pathlib import Path
|
|
16
|
+
from typing import Literal
|
|
9
17
|
|
|
10
18
|
import comrak
|
|
11
19
|
from selectolax.lexbor import LexborHTMLParser, LexborNode
|
|
12
20
|
|
|
13
|
-
from
|
|
21
|
+
from ._unicode import (
|
|
14
22
|
to_monospace,
|
|
15
23
|
to_sans_bold,
|
|
16
24
|
to_sans_bold_italic,
|
|
@@ -22,11 +30,21 @@ _ENCODING = "utf-8"
|
|
|
22
30
|
# selectolax spells a text node's tag this way.
|
|
23
31
|
_TEXT_TAG = "-text"
|
|
24
32
|
|
|
33
|
+
# The styles a tag can switch on for the text inside it; ``_emit_text`` applies
|
|
34
|
+
# them. Spelled as a type so that pushing or popping a misspelt style is a type
|
|
35
|
+
# error (``in`` checks are not narrowed, so keep those in step by hand).
|
|
36
|
+
type _Style = Literal["bold", "italic", "upper", "monospace"]
|
|
37
|
+
|
|
25
38
|
_HEADING_TAGS = frozenset({"h1", "h2", "h3", "h4", "h5", "h6"})
|
|
26
39
|
# Tags that render as their own paragraph, separated by a blank line.
|
|
27
40
|
_BLOCK_TAGS = frozenset({"p", "pre", "blockquote", "table"})
|
|
28
41
|
# Tags that only switch a style on for the text they wrap.
|
|
29
|
-
_STYLE_TAGS
|
|
42
|
+
_STYLE_TAGS: dict[str, _Style] = {
|
|
43
|
+
"strong": "bold",
|
|
44
|
+
"b": "bold",
|
|
45
|
+
"em": "italic",
|
|
46
|
+
"i": "italic",
|
|
47
|
+
}
|
|
30
48
|
_LIST_TAGS = frozenset({"ul", "ol"})
|
|
31
49
|
_CELL_TAGS = frozenset({"th", "td"})
|
|
32
50
|
# Tags whose children are rows and cells rather than prose, so the whitespace
|
|
@@ -91,12 +109,16 @@ class Renderer:
|
|
|
91
109
|
|
|
92
110
|
def __init__(self, *, preserve_links: bool, monospace_code: bool) -> None:
|
|
93
111
|
self.preserve_links: bool = preserve_links
|
|
94
|
-
|
|
112
|
+
# Code is just another style tag when it is to be monospaced, and plain
|
|
113
|
+
# text, like any tag without a style, when it is not.
|
|
114
|
+
self.style_tags: dict[str, _Style] = (
|
|
115
|
+
{**_STYLE_TAGS, "code": "monospace"} if monospace_code else _STYLE_TAGS
|
|
116
|
+
)
|
|
95
117
|
self.out: list[str] = []
|
|
96
118
|
# Newlines at the end of ``out``, tracked so that block separation
|
|
97
119
|
# does not have to re-join everything rendered so far.
|
|
98
120
|
self.trailing: int = 0
|
|
99
|
-
self.styles: list[
|
|
121
|
+
self.styles: list[_Style] = []
|
|
100
122
|
self.lists: list[_ListLevel] = []
|
|
101
123
|
self.links: list[_Link] = []
|
|
102
124
|
|
|
@@ -160,6 +182,11 @@ class Renderer:
|
|
|
160
182
|
# and ``_append`` drops it.
|
|
161
183
|
if text is None:
|
|
162
184
|
return
|
|
185
|
+
# Unicode has no monospace bold, italic or capitals, so monospace takes
|
|
186
|
+
# precedence over the other styles rather than being mapped over them.
|
|
187
|
+
if "monospace" in self.styles:
|
|
188
|
+
self._write(to_monospace(text))
|
|
189
|
+
return
|
|
163
190
|
styled = text
|
|
164
191
|
if "upper" in self.styles:
|
|
165
192
|
styled = styled.upper()
|
|
@@ -171,9 +198,6 @@ class Renderer:
|
|
|
171
198
|
elif "italic" in self.styles:
|
|
172
199
|
styled = to_sans_italic(styled)
|
|
173
200
|
|
|
174
|
-
if "monospace" in self.styles:
|
|
175
|
-
styled = to_monospace(styled)
|
|
176
|
-
|
|
177
201
|
self._write(styled)
|
|
178
202
|
|
|
179
203
|
# ── tags ──────────────────────────────────────────────────────────────────
|
|
@@ -203,12 +227,9 @@ class Renderer:
|
|
|
203
227
|
self._enter_inline(node, tag)
|
|
204
228
|
|
|
205
229
|
def _enter_inline(self, node: LexborNode, tag: str) -> None:
|
|
206
|
-
style =
|
|
230
|
+
style = self.style_tags.get(tag)
|
|
207
231
|
if style is not None:
|
|
208
232
|
self.styles.append(style)
|
|
209
|
-
elif tag == "code":
|
|
210
|
-
if self.monospace_code:
|
|
211
|
-
self.styles.append("monospace")
|
|
212
233
|
elif tag == "a":
|
|
213
234
|
self._start_link(node)
|
|
214
235
|
elif tag == "img":
|
|
@@ -231,12 +252,9 @@ class Renderer:
|
|
|
231
252
|
self._exit_inline(tag)
|
|
232
253
|
|
|
233
254
|
def _exit_inline(self, tag: str) -> None:
|
|
234
|
-
style =
|
|
255
|
+
style = self.style_tags.get(tag)
|
|
235
256
|
if style is not None:
|
|
236
257
|
self.styles.remove(style)
|
|
237
|
-
elif tag == "code":
|
|
238
|
-
if self.monospace_code:
|
|
239
|
-
self.styles.remove("monospace")
|
|
240
258
|
elif tag == "a":
|
|
241
259
|
self._end_link()
|
|
242
260
|
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Converts ASCII letters and digits to their Unicode Mathematical
|
|
4
4
|
Sans-Serif and Monospace equivalents, enabling bold, italic, bold-italic
|
|
5
|
-
and monospace styling in plain-text environments like LinkedIn.
|
|
5
|
+
and monospace styling in plain-text environments like LinkedIn. Accented
|
|
6
|
+
Latin letters become the styled base letter followed by combining marks.
|
|
6
7
|
"""
|
|
7
8
|
|
|
8
9
|
from __future__ import annotations
|
|
9
10
|
|
|
10
11
|
import string
|
|
12
|
+
import unicodedata
|
|
11
13
|
from typing import Literal
|
|
12
14
|
|
|
13
15
|
__all__ = [
|
|
@@ -35,25 +37,48 @@ _MONOSPACE_UPPER = 0x1D670 # 𝙰
|
|
|
35
37
|
_MONOSPACE_LOWER = 0x1D68A # 𝚊
|
|
36
38
|
_MONOSPACE_DIGIT = 0x1D7F6 # 𝟶
|
|
37
39
|
|
|
40
|
+
# Every precomposed Latin letter whose canonical decomposition starts with an
|
|
41
|
+
# ASCII letter lies in Latin-1 Supplement through Latin Extended-B or in Latin
|
|
42
|
+
# Extended Additional.
|
|
43
|
+
_ACCENTED_LATIN_RANGES = (range(0xC0, 0x250), range(0x1E00, 0x1F00))
|
|
44
|
+
|
|
38
45
|
|
|
39
46
|
# ── Translation tables ─────────────────────────────────────────────────────────
|
|
40
47
|
|
|
41
48
|
|
|
42
|
-
def _build_table(
|
|
49
|
+
def _build_table(
|
|
50
|
+
upper: int,
|
|
51
|
+
lower: int,
|
|
52
|
+
digit: int | None = None,
|
|
53
|
+
) -> dict[int, int | str]:
|
|
43
54
|
"""Build a :meth:`str.translate` table for one Unicode style block.
|
|
44
55
|
|
|
45
56
|
The table is derived from the codepoints of the block's styled ``A``,
|
|
46
57
|
``a`` and ``0``. *digit* is ``None`` for the italic blocks, which have no
|
|
47
58
|
digits. Characters absent from the table are left unchanged.
|
|
59
|
+
|
|
60
|
+
Unicode has no styled forms of accented letters, so each precomposed Latin
|
|
61
|
+
letter maps to its NFD form with the base letter styled: ``é`` becomes
|
|
62
|
+
styled ``e`` followed by U+0301 COMBINING ACUTE ACCENT, which renders as
|
|
63
|
+
a styled ``é``. Letters without a decomposition, such as ``ß`` and ``ł``,
|
|
64
|
+
stay plain. Only the Latin blocks are decomposed, so Hangul syllables and
|
|
65
|
+
other scripts whose NFD form starts with a non-ASCII character are never
|
|
66
|
+
split apart.
|
|
48
67
|
"""
|
|
49
68
|
blocks = [(string.ascii_uppercase, upper), (string.ascii_lowercase, lower)]
|
|
50
69
|
if digit is not None:
|
|
51
70
|
blocks.append((string.digits, digit))
|
|
52
|
-
|
|
71
|
+
table: dict[int, int | str] = {
|
|
53
72
|
ord(char): base + offset
|
|
54
73
|
for chars, base in blocks
|
|
55
74
|
for offset, char in enumerate(chars)
|
|
56
75
|
}
|
|
76
|
+
for codepoint in (cp for block in _ACCENTED_LATIN_RANGES for cp in block):
|
|
77
|
+
base, *marks = unicodedata.normalize("NFD", chr(codepoint))
|
|
78
|
+
styled = table.get(ord(base))
|
|
79
|
+
if isinstance(styled, int):
|
|
80
|
+
table[codepoint] = chr(styled) + "".join(marks)
|
|
81
|
+
return table
|
|
57
82
|
|
|
58
83
|
|
|
59
84
|
_SANS_BOLD_TABLE = _build_table(_SANS_BOLD_UPPER, _SANS_BOLD_LOWER, _SANS_BOLD_DIGIT)
|
|
@@ -72,8 +97,9 @@ def to_sans_bold(text: str) -> str:
|
|
|
72
97
|
"""Convert text to Unicode Mathematical Sans-Serif Bold.
|
|
73
98
|
|
|
74
99
|
ASCII uppercase letters, lowercase letters, and digits are mapped to
|
|
75
|
-
their bold sans-serif counterparts.
|
|
76
|
-
|
|
100
|
+
their bold sans-serif counterparts. Accented Latin letters become the
|
|
101
|
+
bold base letter followed by combining marks. All other characters
|
|
102
|
+
(spaces, punctuation, ``ß``, emojis) pass through unchanged.
|
|
77
103
|
|
|
78
104
|
Args:
|
|
79
105
|
text: The input string to convert.
|
|
@@ -86,8 +112,8 @@ def to_sans_bold(text: str) -> str:
|
|
|
86
112
|
>>> to_sans_bold("Hello, World! 123")
|
|
87
113
|
'𝗛𝗲𝗹𝗹𝗼, 𝗪𝗼𝗿𝗹𝗱! 𝟭𝟮𝟯'
|
|
88
114
|
|
|
89
|
-
>>> to_sans_bold("café")
|
|
90
|
-
|
|
115
|
+
>>> to_sans_bold("café") == "𝗰𝗮𝗳𝗲\u0301"
|
|
116
|
+
True
|
|
91
117
|
|
|
92
118
|
>>> to_sans_bold("")
|
|
93
119
|
''
|
|
@@ -100,8 +126,10 @@ def to_sans_italic(text: str) -> str:
|
|
|
100
126
|
"""Convert text to Unicode Mathematical Sans-Serif Italic.
|
|
101
127
|
|
|
102
128
|
ASCII uppercase and lowercase letters are mapped to their italic
|
|
103
|
-
sans-serif counterparts.
|
|
104
|
-
|
|
129
|
+
sans-serif counterparts. Accented Latin letters become the italic base
|
|
130
|
+
letter followed by combining marks. Digits and all other characters pass
|
|
131
|
+
through unchanged (there are no italic digit codepoints in this Unicode
|
|
132
|
+
block).
|
|
105
133
|
|
|
106
134
|
Args:
|
|
107
135
|
text: The input string to convert.
|
|
@@ -128,8 +156,9 @@ def to_sans_bold_italic(text: str) -> str:
|
|
|
128
156
|
"""Convert text to Unicode Mathematical Sans-Serif Bold Italic.
|
|
129
157
|
|
|
130
158
|
ASCII uppercase and lowercase letters are mapped to their bold-italic
|
|
131
|
-
sans-serif counterparts.
|
|
132
|
-
|
|
159
|
+
sans-serif counterparts. Accented Latin letters become the bold-italic
|
|
160
|
+
base letter followed by combining marks. Digits and all other characters
|
|
161
|
+
pass through unchanged.
|
|
133
162
|
|
|
134
163
|
Args:
|
|
135
164
|
text: The input string to convert.
|
|
@@ -153,8 +182,9 @@ def to_monospace(text: str) -> str:
|
|
|
153
182
|
"""Convert text to Unicode Mathematical Monospace.
|
|
154
183
|
|
|
155
184
|
ASCII uppercase letters, lowercase letters, and digits are mapped to
|
|
156
|
-
their monospace counterparts.
|
|
157
|
-
|
|
185
|
+
their monospace counterparts. Accented Latin letters become the
|
|
186
|
+
monospace base letter followed by combining marks. All other characters
|
|
187
|
+
(spaces, punctuation, ``ß``, emojis) pass through unchanged.
|
|
158
188
|
|
|
159
189
|
Args:
|
|
160
190
|
text: The input string to convert.
|
|
@@ -167,8 +197,8 @@ def to_monospace(text: str) -> str:
|
|
|
167
197
|
>>> to_monospace("Hello, World! 123")
|
|
168
198
|
'𝙷𝚎𝚕𝚕𝚘, 𝚆𝚘𝚛𝚕𝚍! 𝟷𝟸𝟹'
|
|
169
199
|
|
|
170
|
-
>>> to_monospace("café")
|
|
171
|
-
|
|
200
|
+
>>> to_monospace("café") == "𝚌𝚊𝚏𝚎\u0301"
|
|
201
|
+
True
|
|
172
202
|
|
|
173
203
|
>>> to_monospace("")
|
|
174
204
|
''
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|