md2linkedin 0.5.0__tar.gz → 0.5.2__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.0 → md2linkedin-0.5.2}/PKG-INFO +9 -9
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/README.md +6 -7
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/pyproject.toml +14 -13
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/pyproject.toml.orig +17 -14
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/src/md2linkedin/__init__.py +2 -2
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/src/md2linkedin/_cli.py +16 -21
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/src/md2linkedin/_converter.py +21 -7
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/src/md2linkedin/_unicode.py +3 -3
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/LICENSE.md +0 -0
- {md2linkedin-0.5.0 → md2linkedin-0.5.2}/src/md2linkedin/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: md2linkedin
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: Convert Markdown to LinkedIn-friendly Unicode text
|
|
5
5
|
Keywords: markdown,linkedin,unicode,formatting,conversion
|
|
6
6
|
Author: Indrajeet Patil
|
|
@@ -15,13 +15,14 @@ Classifier: Programming Language :: Python
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
19
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
21
|
Classifier: Topic :: Text Processing :: Markup
|
|
21
22
|
Classifier: Topic :: Utilities
|
|
22
23
|
Requires-Dist: click>=8.5.0
|
|
23
24
|
Requires-Dist: comrak>=0.0.16
|
|
24
|
-
Requires-Dist: selectolax>=1.0.
|
|
25
|
+
Requires-Dist: selectolax>=1.0.2
|
|
25
26
|
Requires-Python: >=3.12
|
|
26
27
|
Project-URL: Homepage, https://github.com/IndrajeetPatil/md2linkedin
|
|
27
28
|
Project-URL: Documentation, https://www.indrapatil.com/md2linkedin/
|
|
@@ -117,15 +118,14 @@ md2linkedin post.md --no-monospace-code
|
|
|
117
118
|
- **Bold**: `**text**` or `__text__` → Unicode Sans-Serif Bold (𝗯𝗼𝗹𝗱)
|
|
118
119
|
- **Italic**: `*text*` or `_text_` → Unicode Sans-Serif Italic (𝘪𝘵𝘢𝘭𝘪𝘤)
|
|
119
120
|
- **Bold-italic**: `***text***` or `___text___` → Unicode Sans-Serif Bold Italic (𝙗𝙤𝙡𝙙-𝙞𝙩𝙖𝙡𝙞𝙘)
|
|
120
|
-
- **Headers**: `#`/`##`/etc. styled with bold Unicode; H1
|
|
121
|
-
- **Code spans**: backticks stripped
|
|
122
|
-
- **Fenced and indented code blocks**: fences and indent stripped, content rendered in Unicode Monospace by default; `--no-monospace-code` keeps plain text
|
|
121
|
+
- **Headers**: `#`/`##`/etc. styled with bold Unicode; H1 is also uppercased between `━` borders
|
|
122
|
+
- **Code spans and blocks**: backticks, fences and indent stripped; content rendered in Unicode Monospace (𝚌𝚘𝚍𝚎) by default, or kept plain with `--no-monospace-code`
|
|
123
123
|
- **Links**: stripped to display text by default; `--preserve-links` retains URLs
|
|
124
124
|
- **Images**: replaced by alt text
|
|
125
125
|
- **Bullet lists**: `-`/`*`/`+` → `•`; nested items get one marker per level (`‣`, `◦`, `▪`)
|
|
126
|
-
- **Ordered lists**:
|
|
126
|
+
- **Ordered lists**: numbered in sequence from the list's first number (`1.`, `1.` → `1.`, `2.`)
|
|
127
127
|
- **Tables**: header row in bold, cells joined by ` | `
|
|
128
|
-
- **Strikethrough**: `~~text~~` → `text`, markers dropped
|
|
128
|
+
- **Strikethrough and highlight**: `~~text~~` and `==text==` → `text`, markers dropped
|
|
129
129
|
- **Blockquotes**: leading `>` stripped at every level of nesting
|
|
130
130
|
- **HTML spans**: unwrapped, inner text preserved
|
|
131
131
|
- **HTML entities**: decoded (`&` → `&`, etc.)
|
|
@@ -137,11 +137,11 @@ md2linkedin post.md --no-monospace-code
|
|
|
137
137
|
|
|
138
138
|
Converting Markdown to LinkedIn-friendly text relies on Unicode Mathematical Alphanumeric Symbols to simulate styling. This approach has notable limitations:
|
|
139
139
|
|
|
140
|
-
- **Code
|
|
140
|
+
- **Code blocks**: Monospace Unicode characters do not enforce true fixed-width alignment on proportional fonts (like LinkedIn's default font). As a result, indentation and column alignment in code blocks will often break visually.
|
|
141
141
|
- **Tables**: Markdown tables are flattened to one line per row, with a bold header and cells joined by ` | `. Nothing keeps the columns aligned on LinkedIn's proportional font, so wide tables are better rewritten as lists.
|
|
142
142
|
- **Accessibility**: Screen readers often read Unicode mathematical characters aloud individually (e.g., "mathematical sans-serif bold b") instead of as complete words, making the content difficult for visually impaired users to understand.
|
|
143
143
|
- **Searchability**: Text styled with these Unicode characters may not be indexed properly by LinkedIn's search algorithm, meaning people searching for your keywords might not find your post.
|
|
144
|
-
- **Markdown extensions**:
|
|
144
|
+
- **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).
|
|
145
145
|
|
|
146
146
|
For more examples, check out the package documentation at:
|
|
147
147
|
<https://www.indrapatil.com/md2linkedin/>
|
|
@@ -85,15 +85,14 @@ md2linkedin post.md --no-monospace-code
|
|
|
85
85
|
- **Bold**: `**text**` or `__text__` → Unicode Sans-Serif Bold (𝗯𝗼𝗹𝗱)
|
|
86
86
|
- **Italic**: `*text*` or `_text_` → Unicode Sans-Serif Italic (𝘪𝘵𝘢𝘭𝘪𝘤)
|
|
87
87
|
- **Bold-italic**: `***text***` or `___text___` → Unicode Sans-Serif Bold Italic (𝙗𝙤𝙡𝙙-𝙞𝙩𝙖𝙡𝙞𝙘)
|
|
88
|
-
- **Headers**: `#`/`##`/etc. styled with bold Unicode; H1
|
|
89
|
-
- **Code spans**: backticks stripped
|
|
90
|
-
- **Fenced and indented code blocks**: fences and indent stripped, content rendered in Unicode Monospace by default; `--no-monospace-code` keeps plain text
|
|
88
|
+
- **Headers**: `#`/`##`/etc. styled with bold Unicode; H1 is also uppercased between `━` borders
|
|
89
|
+
- **Code spans and blocks**: backticks, fences and indent stripped; content rendered in Unicode Monospace (𝚌𝚘𝚍𝚎) by default, or kept plain with `--no-monospace-code`
|
|
91
90
|
- **Links**: stripped to display text by default; `--preserve-links` retains URLs
|
|
92
91
|
- **Images**: replaced by alt text
|
|
93
92
|
- **Bullet lists**: `-`/`*`/`+` → `•`; nested items get one marker per level (`‣`, `◦`, `▪`)
|
|
94
|
-
- **Ordered lists**:
|
|
93
|
+
- **Ordered lists**: numbered in sequence from the list's first number (`1.`, `1.` → `1.`, `2.`)
|
|
95
94
|
- **Tables**: header row in bold, cells joined by ` | `
|
|
96
|
-
- **Strikethrough**: `~~text~~` → `text`, markers dropped
|
|
95
|
+
- **Strikethrough and highlight**: `~~text~~` and `==text==` → `text`, markers dropped
|
|
97
96
|
- **Blockquotes**: leading `>` stripped at every level of nesting
|
|
98
97
|
- **HTML spans**: unwrapped, inner text preserved
|
|
99
98
|
- **HTML entities**: decoded (`&` → `&`, etc.)
|
|
@@ -105,11 +104,11 @@ md2linkedin post.md --no-monospace-code
|
|
|
105
104
|
|
|
106
105
|
Converting Markdown to LinkedIn-friendly text relies on Unicode Mathematical Alphanumeric Symbols to simulate styling. This approach has notable limitations:
|
|
107
106
|
|
|
108
|
-
- **Code
|
|
107
|
+
- **Code blocks**: Monospace Unicode characters do not enforce true fixed-width alignment on proportional fonts (like LinkedIn's default font). As a result, indentation and column alignment in code blocks will often break visually.
|
|
109
108
|
- **Tables**: Markdown tables are flattened to one line per row, with a bold header and cells joined by ` | `. Nothing keeps the columns aligned on LinkedIn's proportional font, so wide tables are better rewritten as lists.
|
|
110
109
|
- **Accessibility**: Screen readers often read Unicode mathematical characters aloud individually (e.g., "mathematical sans-serif bold b") instead of as complete words, making the content difficult for visually impaired users to understand.
|
|
111
110
|
- **Searchability**: Text styled with these Unicode characters may not be indexed properly by LinkedIn's search algorithm, meaning people searching for your keywords might not find your post.
|
|
112
|
-
- **Markdown extensions**:
|
|
111
|
+
- **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).
|
|
113
112
|
|
|
114
113
|
For more examples, check out the package documentation at:
|
|
115
114
|
<https://www.indrapatil.com/md2linkedin/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "md2linkedin"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.2"
|
|
4
4
|
description = "Convert Markdown to LinkedIn-friendly Unicode text"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -22,6 +22,7 @@ classifiers = [
|
|
|
22
22
|
"Programming Language :: Python :: 3.12",
|
|
23
23
|
"Programming Language :: Python :: 3.13",
|
|
24
24
|
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Programming Language :: Python :: 3.15",
|
|
25
26
|
"Programming Language :: Python :: 3 :: Only",
|
|
26
27
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
27
28
|
"Topic :: Text Processing :: Markup",
|
|
@@ -30,7 +31,7 @@ classifiers = [
|
|
|
30
31
|
dependencies = [
|
|
31
32
|
"click>=8.5.0",
|
|
32
33
|
"comrak>=0.0.16",
|
|
33
|
-
"selectolax>=1.0.
|
|
34
|
+
"selectolax>=1.0.2",
|
|
34
35
|
]
|
|
35
36
|
|
|
36
37
|
[[project.authors]]
|
|
@@ -49,25 +50,24 @@ Changelog = "https://github.com/IndrajeetPatil/md2linkedin/blob/main/CHANGELOG.m
|
|
|
49
50
|
|
|
50
51
|
[dependency-groups]
|
|
51
52
|
dev = [
|
|
52
|
-
"
|
|
53
|
-
"coverage>=7.16.2",
|
|
53
|
+
"coverage>=7.17.0",
|
|
54
54
|
"deptry>=0.25.1",
|
|
55
|
-
"mkdocstrings-python>=2.0.
|
|
55
|
+
"mkdocstrings-python>=2.0.10",
|
|
56
56
|
"mutmut>=3.8.0",
|
|
57
|
-
"prek>=0.5.
|
|
58
|
-
"pyrefly>=1.
|
|
57
|
+
"prek>=0.5.7",
|
|
58
|
+
"pyrefly>=1.4.0",
|
|
59
59
|
"pytest>=9.1.1",
|
|
60
60
|
"pytest-codeblocks>=0.18.0",
|
|
61
61
|
"pytest-codspeed==5.0.3",
|
|
62
62
|
"pytest-cov>=7.1.0",
|
|
63
63
|
"pytest-random-order>=1.2.0",
|
|
64
|
-
"ruff>=0.
|
|
65
|
-
"ty>=0.0.
|
|
66
|
-
"zensical>=0.0.
|
|
64
|
+
"ruff>=0.17.2",
|
|
65
|
+
"ty>=0.0.91",
|
|
66
|
+
"zensical>=0.0.72",
|
|
67
67
|
]
|
|
68
68
|
|
|
69
69
|
[build-system]
|
|
70
|
-
requires = ["uv_build>=0.
|
|
70
|
+
requires = ["uv_build>=0.13.0,<0.14"]
|
|
71
71
|
build-backend = "uv_build"
|
|
72
72
|
|
|
73
73
|
[tool.ruff]
|
|
@@ -78,7 +78,6 @@ unsafe-fixes = true
|
|
|
78
78
|
[tool.ruff.lint]
|
|
79
79
|
select = ["ALL"]
|
|
80
80
|
ignore = [
|
|
81
|
-
"missing-trailing-comma",
|
|
82
81
|
"incorrect-blank-line-before-class",
|
|
83
82
|
"multi-line-summary-second-line",
|
|
84
83
|
"CPY",
|
|
@@ -98,6 +97,8 @@ ignore = [
|
|
|
98
97
|
"ambiguous-unicode-character-string",
|
|
99
98
|
"magic-value-comparison",
|
|
100
99
|
"too-many-public-methods",
|
|
100
|
+
"suspicious-subprocess-import",
|
|
101
|
+
"subprocess-without-shell-equals-true",
|
|
101
102
|
]
|
|
102
103
|
|
|
103
104
|
[tool.ruff.format]
|
|
@@ -160,7 +161,7 @@ strict-equality-semantics = true
|
|
|
160
161
|
strict-generic-narrowing = true
|
|
161
162
|
|
|
162
163
|
[tool.uv]
|
|
163
|
-
required-version = ">=0.
|
|
164
|
+
required-version = ">=0.13.0"
|
|
164
165
|
|
|
165
166
|
[tool.deptry]
|
|
166
167
|
extend_exclude = ["scripts"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "md2linkedin"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.2"
|
|
4
4
|
description = "Convert Markdown to LinkedIn-friendly Unicode text"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -19,6 +19,7 @@ classifiers = [
|
|
|
19
19
|
"Programming Language :: Python :: 3.12",
|
|
20
20
|
"Programming Language :: Python :: 3.13",
|
|
21
21
|
"Programming Language :: Python :: 3.14",
|
|
22
|
+
"Programming Language :: Python :: 3.15",
|
|
22
23
|
"Programming Language :: Python :: 3 :: Only",
|
|
23
24
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
25
|
"Topic :: Text Processing :: Markup",
|
|
@@ -27,7 +28,7 @@ classifiers = [
|
|
|
27
28
|
dependencies = [
|
|
28
29
|
"click>=8.5.0",
|
|
29
30
|
"comrak>=0.0.16",
|
|
30
|
-
"selectolax>=1.0.
|
|
31
|
+
"selectolax>=1.0.2",
|
|
31
32
|
]
|
|
32
33
|
|
|
33
34
|
[project.scripts]
|
|
@@ -42,25 +43,24 @@ Changelog = "https://github.com/IndrajeetPatil/md2linkedin/blob/main/CHANGELOG.m
|
|
|
42
43
|
|
|
43
44
|
[dependency-groups]
|
|
44
45
|
dev = [
|
|
45
|
-
"
|
|
46
|
-
"coverage>=7.16.2",
|
|
46
|
+
"coverage>=7.17.0",
|
|
47
47
|
"deptry>=0.25.1",
|
|
48
|
-
"mkdocstrings-python>=2.0.
|
|
48
|
+
"mkdocstrings-python>=2.0.10",
|
|
49
49
|
"mutmut>=3.8.0",
|
|
50
|
-
"prek>=0.5.
|
|
51
|
-
"pyrefly>=1.
|
|
50
|
+
"prek>=0.5.7",
|
|
51
|
+
"pyrefly>=1.4.0",
|
|
52
52
|
"pytest>=9.1.1",
|
|
53
53
|
"pytest-codeblocks>=0.18.0",
|
|
54
54
|
"pytest-codspeed==5.0.3",
|
|
55
55
|
"pytest-cov>=7.1.0",
|
|
56
56
|
"pytest-random-order>=1.2.0",
|
|
57
|
-
"ruff>=0.
|
|
58
|
-
"ty>=0.0.
|
|
59
|
-
"zensical>=0.0.
|
|
57
|
+
"ruff>=0.17.2",
|
|
58
|
+
"ty>=0.0.91",
|
|
59
|
+
"zensical>=0.0.72",
|
|
60
60
|
]
|
|
61
61
|
|
|
62
62
|
[build-system]
|
|
63
|
-
requires = ["uv_build>=0.
|
|
63
|
+
requires = ["uv_build>=0.13.0,<0.14"]
|
|
64
64
|
build-backend = "uv_build"
|
|
65
65
|
|
|
66
66
|
[tool.ruff]
|
|
@@ -69,10 +69,10 @@ preview = true
|
|
|
69
69
|
unsafe-fixes = true
|
|
70
70
|
|
|
71
71
|
[tool.ruff.lint]
|
|
72
|
+
# Keep missing-trailing-comma enabled to preserve intentional multiline layouts.
|
|
73
|
+
# `make format` applies its fixes before the formatter can collapse those lines.
|
|
72
74
|
select = ["ALL"]
|
|
73
75
|
ignore = [
|
|
74
|
-
# Required for compatibility with Ruff's formatter.
|
|
75
|
-
"missing-trailing-comma",
|
|
76
76
|
# Mutually exclusive with D211 and D212, respectively.
|
|
77
77
|
"incorrect-blank-line-before-class",
|
|
78
78
|
"multi-line-summary-second-line",
|
|
@@ -108,6 +108,9 @@ ignore = [
|
|
|
108
108
|
"magic-value-comparison",
|
|
109
109
|
# large test classes are fine when grouping related cases
|
|
110
110
|
"too-many-public-methods",
|
|
111
|
+
# tests run fixed code in a fresh interpreter (sys.executable) to observe imports
|
|
112
|
+
"suspicious-subprocess-import",
|
|
113
|
+
"subprocess-without-shell-equals-true",
|
|
111
114
|
]
|
|
112
115
|
|
|
113
116
|
[tool.ruff.format]
|
|
@@ -175,7 +178,7 @@ strict-equality-semantics = true
|
|
|
175
178
|
strict-generic-narrowing = true
|
|
176
179
|
|
|
177
180
|
[tool.uv]
|
|
178
|
-
required-version = ">=0.
|
|
181
|
+
required-version = ">=0.13.0"
|
|
179
182
|
|
|
180
183
|
[tool.deptry]
|
|
181
184
|
extend_exclude = ["scripts"]
|
|
@@ -7,8 +7,8 @@ The package exposes two main entry points:
|
|
|
7
7
|
``.linkedin.txt`` output file.
|
|
8
8
|
|
|
9
9
|
Lower-level Unicode mapping utilities (:func:`to_sans_bold`,
|
|
10
|
-
:func:`to_sans_italic`, :func:`to_sans_bold_italic`, :func:`
|
|
11
|
-
are also public for programmatic use.
|
|
10
|
+
:func:`to_sans_italic`, :func:`to_sans_bold_italic`, :func:`to_monospace`,
|
|
11
|
+
:func:`apply_style`) are also public for programmatic use.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
from __future__ import annotations
|
|
@@ -54,7 +54,7 @@ def main(
|
|
|
54
54
|
preserve_links: bool,
|
|
55
55
|
no_monospace_code: bool,
|
|
56
56
|
) -> None:
|
|
57
|
-
|
|
57
|
+
"""Convert Markdown to LinkedIn-friendly Unicode text.
|
|
58
58
|
|
|
59
59
|
Reads from INPUT_FILE (or stdin when INPUT_FILE is omitted) and writes
|
|
60
60
|
LinkedIn-compatible plain text in which bold and italic formatting is
|
|
@@ -65,26 +65,22 @@ def main(
|
|
|
65
65
|
|
|
66
66
|
\b
|
|
67
67
|
Examples:
|
|
68
|
-
|
|
69
68
|
# Convert a file (output written to README.linkedin.txt)
|
|
70
69
|
md2linkedin README.md
|
|
71
|
-
|
|
72
70
|
# Specify the output path explicitly
|
|
73
71
|
md2linkedin README.md -o post.txt
|
|
74
|
-
|
|
75
72
|
# Pipe from stdin
|
|
76
73
|
echo "**Hello**, *world*!" | md2linkedin
|
|
77
|
-
|
|
78
74
|
# Keep link URLs in the output
|
|
79
75
|
md2linkedin README.md --preserve-links
|
|
80
|
-
|
|
81
76
|
# Disable monospace code rendering
|
|
82
77
|
md2linkedin README.md --no-monospace-code
|
|
83
78
|
|
|
79
|
+
\f
|
|
84
80
|
Raises:
|
|
85
81
|
click.UsageError: If neither an input file nor piped stdin is provided.
|
|
86
82
|
|
|
87
|
-
"""
|
|
83
|
+
""" # ruff: ignore[escape-sequence-in-docstring] (Click markers)
|
|
88
84
|
monospace_code = not no_monospace_code
|
|
89
85
|
if input_file is not None:
|
|
90
86
|
out_path = convert_file(
|
|
@@ -94,21 +90,20 @@ def main(
|
|
|
94
90
|
monospace_code=monospace_code,
|
|
95
91
|
)
|
|
96
92
|
click.echo(f"LinkedIn-formatted text written to: {out_path}")
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
raise click.UsageError(msg)
|
|
105
|
-
md_text = sys.stdin.read()
|
|
106
|
-
result = convert(
|
|
107
|
-
md_text,
|
|
108
|
-
preserve_links=preserve_links,
|
|
109
|
-
monospace_code=monospace_code,
|
|
93
|
+
return
|
|
94
|
+
|
|
95
|
+
if _stdin_is_tty():
|
|
96
|
+
msg = (
|
|
97
|
+
"No input file provided and stdin is a terminal. "
|
|
98
|
+
"Provide a file path or pipe content via stdin."
|
|
110
99
|
)
|
|
111
|
-
click.
|
|
100
|
+
raise click.UsageError(msg)
|
|
101
|
+
result = convert(
|
|
102
|
+
sys.stdin.read(),
|
|
103
|
+
preserve_links=preserve_links,
|
|
104
|
+
monospace_code=monospace_code,
|
|
105
|
+
)
|
|
106
|
+
click.echo(result, nl=False)
|
|
112
107
|
|
|
113
108
|
|
|
114
109
|
def _stdin_is_tty() -> bool:
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
# Python 3.15+ (PEP 810) defers these imports until first use, so that
|
|
2
|
+
# ``import md2linkedin``, ``--help`` and ``--version`` skip loading the parser
|
|
3
|
+
# extensions. Earlier versions ignore this and import eagerly.
|
|
4
|
+
__lazy_modules__ = ["comrak", "selectolax.lexbor"]
|
|
5
|
+
|
|
1
6
|
import re
|
|
2
7
|
from dataclasses import dataclass
|
|
3
8
|
from pathlib import Path
|
|
@@ -291,7 +296,8 @@ class Renderer:
|
|
|
291
296
|
return ""
|
|
292
297
|
level = self.lists[-1]
|
|
293
298
|
if level.ordered:
|
|
294
|
-
#
|
|
299
|
+
# Items are numbered on from the list's start value, whatever
|
|
300
|
+
# numbers the source used.
|
|
295
301
|
marker = f"{level.number}. "
|
|
296
302
|
level.number += 1
|
|
297
303
|
return marker
|
|
@@ -347,7 +353,7 @@ def convert(
|
|
|
347
353
|
preserve_links: bool = False,
|
|
348
354
|
monospace_code: bool = True,
|
|
349
355
|
) -> str:
|
|
350
|
-
|
|
356
|
+
"""Convert Markdown text to LinkedIn-compatible Unicode plain text.
|
|
351
357
|
|
|
352
358
|
Args:
|
|
353
359
|
text: The Markdown source string.
|
|
@@ -362,7 +368,7 @@ def convert(
|
|
|
362
368
|
A plain-text string suitable for pasting into LinkedIn.
|
|
363
369
|
|
|
364
370
|
"""
|
|
365
|
-
if not text
|
|
371
|
+
if not text.strip():
|
|
366
372
|
return ""
|
|
367
373
|
|
|
368
374
|
render_options = comrak.RenderOptions()
|
|
@@ -375,6 +381,9 @@ def convert(
|
|
|
375
381
|
extensions.strikethrough = True
|
|
376
382
|
extensions.table = True
|
|
377
383
|
extensions.autolink = True
|
|
384
|
+
# ``==text==`` becomes ``<mark>``, which the renderer unwraps like any
|
|
385
|
+
# other tag it has no style for, so the markers do not reach the output.
|
|
386
|
+
extensions.highlight = True
|
|
378
387
|
|
|
379
388
|
html = comrak.render_markdown(
|
|
380
389
|
text,
|
|
@@ -400,16 +409,21 @@ def convert_file(
|
|
|
400
409
|
preserve_links: bool = False,
|
|
401
410
|
monospace_code: bool = True,
|
|
402
411
|
) -> Path:
|
|
403
|
-
|
|
412
|
+
"""Convert a Markdown file and write the result to a ``.txt`` file.
|
|
404
413
|
|
|
405
414
|
Args:
|
|
406
415
|
input_path: Path to the Markdown source file.
|
|
407
|
-
output_path: Destination path for the converted output.
|
|
416
|
+
output_path: Destination path for the converted output. Defaults to
|
|
417
|
+
*input_path* with its last suffix replaced by ``.linkedin.txt``,
|
|
418
|
+
so ``notes.v2.md`` is written to ``notes.v2.linkedin.txt``.
|
|
408
419
|
preserve_links: Passed through to :func:`convert`.
|
|
409
420
|
monospace_code: Passed through to :func:`convert`.
|
|
410
421
|
|
|
411
422
|
Returns:
|
|
412
|
-
The
|
|
423
|
+
The path of the written output file.
|
|
424
|
+
|
|
425
|
+
Raises:
|
|
426
|
+
FileNotFoundError: If *input_path* does not exist.
|
|
413
427
|
|
|
414
428
|
"""
|
|
415
429
|
input_path = Path(input_path)
|
|
@@ -418,7 +432,7 @@ def convert_file(
|
|
|
418
432
|
raise FileNotFoundError(msg)
|
|
419
433
|
|
|
420
434
|
if output_path is None:
|
|
421
|
-
output_path = input_path.with_suffix("
|
|
435
|
+
output_path = input_path.with_suffix(".linkedin.txt")
|
|
422
436
|
output_path = Path(output_path)
|
|
423
437
|
|
|
424
438
|
md_text = input_path.read_text(encoding=_ENCODING)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"""Unicode Mathematical Sans-Serif character mapping functions.
|
|
1
|
+
"""Unicode Mathematical Sans-Serif and Monospace character mapping functions.
|
|
2
2
|
|
|
3
3
|
Converts ASCII letters and digits to their Unicode Mathematical
|
|
4
|
-
Sans-Serif equivalents, enabling bold, italic,
|
|
5
|
-
styling in plain-text environments like LinkedIn.
|
|
4
|
+
Sans-Serif and Monospace equivalents, enabling bold, italic, bold-italic
|
|
5
|
+
and monospace styling in plain-text environments like LinkedIn.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
File without changes
|
|
File without changes
|