API Reference
High-level API
Convert Markdown text to LinkedIn-compatible Unicode plain text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The Markdown source string. |
required |
preserve_links
|
bool
|
When |
False
|
monospace_code
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
str
|
A plain-text string suitable for pasting into LinkedIn. |
Source code in src/md2linkedin/_converter.py
Convert a Markdown file and write the result to a .txt file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_path
|
str | Path
|
Path to the Markdown source file. |
required |
output_path
|
str | Path | None
|
Destination path for the converted output. Defaults to
input_path with its last suffix replaced by |
None
|
preserve_links
|
bool
|
Passed through to :func: |
False
|
monospace_code
|
bool
|
Passed through to :func: |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
The path of the written output file. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If input_path does not exist. |
Source code in src/md2linkedin/_converter.py
Unicode Mapping
Apply a Unicode sans-serif style to text.
A convenience dispatcher that routes to the appropriate mapping function based on the requested style. Useful when the style is determined dynamically at runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input string to convert. |
required |
style
|
Literal['bold', 'italic', 'bold_italic']
|
One of |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new string with the requested Unicode style applied. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If style is not one of the three accepted values. |
Examples:
Source code in src/md2linkedin/_unicode.py
Convert text to Unicode Mathematical Monospace.
ASCII uppercase letters, lowercase letters, and digits are mapped to their monospace counterparts. All other characters (spaces, punctuation, non-ASCII) pass through unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input string to convert. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new string with ASCII alphanumerics replaced by monospace |
str
|
Unicode equivalents. |
Examples:
Source code in src/md2linkedin/_unicode.py
Convert text to Unicode Mathematical Sans-Serif Bold.
ASCII uppercase letters, lowercase letters, and digits are mapped to their bold sans-serif counterparts. All other characters (spaces, punctuation, non-ASCII) pass through unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input string to convert. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new string with ASCII alphanumerics replaced by bold sans-serif |
str
|
Unicode equivalents. |
Examples:
Source code in src/md2linkedin/_unicode.py
Convert text to Unicode Mathematical Sans-Serif Italic.
ASCII uppercase and lowercase letters are mapped to their italic sans-serif counterparts. Digits and all other characters pass through unchanged (there are no italic digit codepoints in this Unicode block).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input string to convert. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new string with ASCII letters replaced by italic sans-serif |
str
|
Unicode equivalents. |
Examples:
Source code in src/md2linkedin/_unicode.py
Convert text to Unicode Mathematical Sans-Serif Bold Italic.
ASCII uppercase and lowercase letters are mapped to their bold-italic sans-serif counterparts. Digits and all other characters pass through unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input string to convert. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A new string with ASCII letters replaced by bold-italic sans-serif |
str
|
Unicode equivalents. |
Examples: