diff --git a/manifest.json b/manifest.json index 16b58df..71c0b96 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "id": "unicode-text-formatter", + "id": "obsidian-unicode-formatter", "name": "Unicode Text Formatter", "version": "1.0.0", "minAppVersion": "0.15.0", diff --git a/package.json b/package.json index 17268d7..1f0cbab 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "obsidian-sample-plugin", - "version": "1.0.0", - "description": "This is a sample plugin for Obsidian (https://obsidian.md)", +"name": "obsidian-unicode-formatter", +"version": "1.0.0", +"description": "Format selected text as Unicode Sans-Serif Bold, Italic, or Bold-Italic for LinkedIn and Facebook posts.", "main": "main.js", "type": "module", "scripts": { diff --git a/src/formatter.ts b/src/formatter.ts index abb2198..c57a4cb 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -14,7 +14,14 @@ export function transformText(text: string, style: FormatStyle): string { } export function cleanText(text: string): string { - return [...text].map(ch => UNICODE_TO_ASCII_MAP.get(ch) ?? ch).join(""); + return text.split("\n").map(line => { + if (line.startsWith("— ")) line = line.slice(2); + else if (line.startsWith("→ ")) line = line.slice(2); + + line = line.replace(/^\(\d+\) /, "").replace(/^\d+\/ /, ""); + + return [...line].map(ch => UNICODE_TO_ASCII_MAP.get(ch) ?? ch).join(""); + }).join("\n"); } export function bulletToEmdash(text: string): string { @@ -79,7 +86,7 @@ export function markdownToLinkedIn(text: string): string { continue; } - if (line.startsWith("- ")) { + if (line.startsWith("- ") || line.startsWith("* ")) { if (!inListContext) { for (let i = 0; i < pendingBlanks; i++) output.push(""); }