@fsegurai/marked-extended-typographic v15.2.3
A library of extended typographic features for Marked.js.
@fsegurai/marked-extended-typographic is an extension for Marked.js that adds support for extended typographic characters to easily translate plain ASCII punctuation characters into "smart" typographic punctuation HTML entities.
Table of contents
Installation
To add @fsegurai/marked-extended-typographic along with Marked.js to your package.json use the following commands.
bun install @fsegurai/marked-extended-typographic marked@^15.0.0 --saveUsage
Basic Usage
Import @fsegurai/marked-extended-typographic and apply it to your Marked instance as shown below.
import { marked } from "marked";
import markedExtendedTypographic from "@fsegurai/marked-extended-typographic";
// or UMD script
// <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
// <script src="https://cdn.jsdelivr.net/npm/@fsegurai/marked-extended-typographic/lib/index.umd.js"></script>
marked.use(markedExtendedTypographic());
const exampleMarkdown = `
He said, -- \"A 'simple' sentence. . .\" --- unknown
(omega) - (alpha) - (beta)
Copyright (C^) 2024. All rights reserved.
`;
marked.parse(exampleMarkdown);Configuration Options
You can customize the typographic behavior with several options:
// Default behavior (recommended)
marked.use(markedExtendedTypographic());
// With specific configuration
marked.use(
markedExtendedTypographic({
quotes: true, // Enable smart quotes (default: true)
dashes: true, // Enable smart dashes (default: true)
ellipses: true, // Enable smart ellipses (default: true)
attribute: "2", // Typographic style attribute (default: '2')
outputUnicode: true, // Output Unicode characters instead of HTML entities (default: false)
customSymbols: {
// Add custom symbol replacements
"\\(lambda\\)": "λ",
"\\(tm\\)": "™",
},
}),
);attribute: Specifies the typographic style attribute. The default is2, which uses thelangattribute for language-specific typographic styles.0Disables typographic styles.1Enable quotes, backticks, dashes and ellipses2Same as '1' but with old-school dash behavior (-- for en-dash, --- for em-dash)3Same as '1' but with inverted old-school dash behavior (-- for em-dash, --- for en-dash)-1Special "stupefy" mode that converts typographic characters back to ASCII
Symbol References
The marked-extended-typographic extension supports a wide variety of special symbols that can be added to your markdown using simple text patterns.
Special Characters
| Markdown | Symbol | Description |
|---|---|---|
(<<) | « | Left-pointing double angle quotation mark |
(>>) | » | Right-pointing double angle quotation mark |
(<-) | ← | Left arrow |
(->) | → | Right arrow |
(<->) | ↔ | Left-right arrow |
(<=>) | ⇔ | Double arrow left-right |
(<==>) | ⇔ | Left double arrow |
(=>) | ⇒ | Implies/right double arrow |
(<==) | ⇐ | Left double arrow |
(==>) | ⇒ | Right double arrow |
(==) | ≡ | Identical to |
(<) | ≪ | Much less than |
(>) | ≫ | Much greater than |
(<=) | ≦ | Less than or equal to |
(>=) | ≧ | Greater than or equal to |
(<>) | ≷ | Neither less than nor greater than |
(><) | ≸ | Neither greater than nor less than |
(+-) | ± | Plus-minus sign |
(-+) | ∓ | Minus-plus sign |
(x) | × | Multiplication sign |
(/) | ÷ | Division sign |
(=>) | ⇒ | Right double arrow |
(<=) | ⇐ | Left double arrow |
(^up) | ↑ | Up arrow |
(^down) | ↓ | Down arrow |
(^left) | ← | Left arrow |
(^right) | → | Right arrow |
(^updown) | ↕ | Up-down arrow |
(^leftright) | ↔ | Left-right arrow |
(--) | — | Em dash |
(---) | – | En dash |
Logical and Mathematical Symbols
| Markdown | Symbol | Description |
|---|---|---|
(+) | ⊕ | Direct sum |
(-) | ⊖ | Direct difference |
(*) | ⊗ | Tensor product |
(\|) | ∣ | Divides |
(&) | ∧ | Logical and |
(\|\|) | ∨ | Logical or |
(!) | ¬ | Logical not |
(=) | ≠ | Not equal |
(~) | ≈ | Approximately equal |
(^) | ∧ | Logical and |
(%) | ‰ | Per mille |
(#) | № | Numero sign |
(@) | ⊕ | Circled plus |
($) | ¤ | Currency sign |
(sum) | ∑ | Summation symbol |
(prod) | ∏ | Product symbol |
(sqrt) | √ | Square root symbol |
(cbrt) | ∛ | Cube root symbol |
(inf) | ∞ | Infinity symbol |
(integral) | ∫ | Integral symbol |
(partial) | ∂ | Partial derivative |
(empty) | ∅ | Empty set symbol |
(in) | ∈ | Element of |
(notin) | ∉ | Not an element of |
(subset) | ⊂ | Subset of |
(subseteq) | ⊆ | Subset or equal to |
(nsubset) | ⊄ | Not a subset of |
(nsubseteq) | ⊈ | Not a subset or equal to |
(superset) | ⊃ | Superset of |
(nsuperset) | ⊅ | Not a superset of |
(union) | ∪ | Union symbol |
(intersection) | ∩ | Intersection symbol |
(forall) | ∀ | For all |
(exists) | ∃ | There exists |
(nexists) | ∄ | There does not exist |
Typographic Symbols
| Markdown | Symbol | Description |
|---|---|---|
(C^) or (c^) | © | Copyright |
(R^) or (r^) | ® | Registered trademark |
(TM^) or (tm^) | ™ | Trademark |
(P^) or (p^) | ℗ | Sound recording copyright |
(S^) or (s^) | § | Section |
(D^) or (d^) | † | Dagger |
(DD^) or (dd^) | ‡ | Double dagger |
(P*) or (p*) | ¶ | Paragraph |
(euro) | € | Euro |
(pound) | £ | Pound sterling |
(yen) | ¥ | Yen |
(cent) | ¢ | Cent |
(colon) | ₵ | Colon |
(degree) | ° | Degree |
(micro) | µ | Micro sign |
(middledot) | ⋅ | Middle dot |
(bullet) | • | Bullet |
(nbsp) | Non-breaking space | |
(endash) | – | En dash |
(emdash) | — | Em dash |
Greek Letters
| Markdown | Symbol | Markdown | Symbol | |
|---|---|---|---|---|
(alpha) or (Alpha) | α | (nu) or (Nu) | ν | |
(beta) or (Beta) | β | (xi) or (Xi) | ξ | |
(gamma) or (Gamma) | γ | (omicron) or (Omicron) | ο | |
(delta) or (Delta) | δ | (pi) or (Pi) | π | |
(epsilon) or (Epsilon) | ε | (rho) or (Rho) | ρ | |
(zeta) or (Zeta) | ζ | (sigma) or (Sigma) | σ | |
(eta) or (Eta) | η | (tau) or (Tau) | τ | |
(theta) or (Theta) | θ | (upsilon) or (Upsilon) | υ | |
(iota) or (Iota) | ι | (phi) or (Phi) | φ | |
(kappa) or (Kappa) | κ | (chi) or (Chi) | χ | |
(lambda) or (Lambda) | λ | (psi) or (Psi) | ψ | |
(mu) or (Mu) | μ | (omega) or (Omega) | ω | |
(nabla) or (Nabla) | ∇ | (theta) or (Theta) | θ |
Emoji Symbols
Emoji Symbols
| Markdown | Symbol | Description |
|---|---|---|
(check) | ✅ | Check mark |
(cross) | ❌ | Cross mark |
(warning) | ⚠️ | Warning sign |
(info) | ℹ️ | Information symbol |
(star) | ⭐ | Black star |
(phone) | ☎️ | Telephone symbol |
(mail) | ✉️ | Envelope |
(music) | 🎵 | Musical note |
(sunny) | ☀️ | Sun |
(cloud) | ☁️ | Cloud |
(umbrella) | ☂️ | Umbrella |
(snowflake) | ❄️ | Snowflake |
(recycle) | ♻️ | Recycling symbol |
(heart) | ❤️ | Heart |
(brokenheart) | 💔 | Broken heart |
(fire) | 🔥 | Fire |
(water) | 💧 | Water droplet |
(flag) | 🚩 | Flag |
(thumbsup) | 👍 | Thumbs up sign |
(thumbsdown) | 👎 | Thumbs down sign |
(clap) | 👏 | Clapping hands |
(wave) | 👋 | Waving hand |
(smile) | 😊 | Smiling face |
(sad) | 😢 | Crying face |
(angry) | 😠 | Angry face |
(laugh) | 😂 | Laughing face |
(wink) | 😉 | Winking face |
(kiss) | 😘 | Kissing face |
(surprised) | 😲 | Surprised face |
(clock) | 🕒 | Clock face |
(calendar) | 📅 | Calendar |
(gear) | ⚙ | Gear |
(link) | 🔗 | Link symbol |
(lock) | 🔒 | Lock |
(unlock) | 🔓 | Unlock |
Available Extensions
| Extension | Package | Version | Description |
|---|---|---|---|
| Accordion | @fsegurai/marked-extended-accordion | Add collapsible accordion sections to your markdown | |
| Alert | @fsegurai/marked-extended-alert | Create styled alert boxes for important information | |
| Footnote | @fsegurai/marked-extended-footnote | Add footnotes with automatic numbering | |
| Lists | @fsegurai/marked-extended-lists | Enhanced list formatting options | |
| Spoiler | @fsegurai/marked-extended-spoiler | Hide content behind spoiler tags | |
| Tables | @fsegurai/marked-extended-tables | Advanced table formatting with cell spanning | |
| Tabs | @fsegurai/marked-extended-tabs | Create tabbed content sections | |
| Timeline | @fsegurai/marked-extended-timeline | Display content in an interactive timeline format | |
| Typographic | @fsegurai/marked-extended-typographic | Improve typography with smart quotes, dashes, and more |
Demo Application
To see all extensions in action, check out the [DEMO].
To set up the demo locally, follow the next steps:
git clone https://github.com/fsegurai/marked-extensions.git
bun install
bun startThis will serve the application locally at http://[::1]:8000.
License
Licensed under MIT.