diff --git a/README.md b/README.md index a994198..89623f5 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ An [Obsidian](https://obsidian.md) plugin that transforms selected text into Uni - **Unicode Italic** β€” converts letters to sans-serif italic (π˜ˆπ˜‰π˜Š / 𝘒𝘣𝘀) - **Unicode Bold Italic** β€” converts letters to sans-serif bold italic (𝘼𝘽𝘾 / π™–π™—π™˜) - **Remove Unicode Formatting** β€” converts any formatted Unicode characters back to plain ASCII +- **Convert List Bullets to Arrow** β€” replaces leading `* ` bullet markers with `β†’ ` on each selected line - **Convert List Bullets to Em Dash** β€” replaces leading `* ` bullet markers with `β€” ` on each selected line - Non-mapped characters (punctuation, spaces, emoji, etc.) are passed through unchanged @@ -20,6 +21,7 @@ An [Obsidian](https://obsidian.md) plugin that transforms selected text into Uni - **Format as Unicode Italic** - **Format as Unicode Bold Italic** - **Remove Unicode Formatting** β€” reverses any of the above back to plain ASCII + - **Convert List Bullets to Arrow** β€” replaces `* ` prefixes with `β†’ ` - **Convert List Bullets to Em Dash** β€” replaces `* ` prefixes with `β€” ` The selected text is replaced in place. @@ -52,7 +54,7 @@ npm run lint # ESLint check |------|---------| | `src/unicode-maps.ts` | Builds character lookup maps from Unicode code point ranges | | `src/formatter.ts` | `transformText(text, style)`, `cleanText(text)`, and `bulletToEmdash(text)` β€” text transformation functions | -| `src/commands.ts` | Registers the five editor commands with the Obsidian plugin API | +| `src/commands.ts` | Registers the six editor commands with the Obsidian plugin API | | `src/main.ts` | Plugin entry point β€” calls `registerCommands` on load | ### Unicode blocks used diff --git a/src/commands.ts b/src/commands.ts index 72313d4..95ac2fb 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,5 +1,5 @@ import { Plugin } from "obsidian"; -import { transformText, cleanText, bulletToEmdash, FormatStyle } from "./formatter"; +import { transformText, cleanText, bulletToEmdash, bulletToArrow, FormatStyle } from "./formatter"; function addFormatCommand(plugin: Plugin, style: FormatStyle, name: string) { plugin.addCommand({ @@ -28,6 +28,16 @@ export function registerCommands(plugin: Plugin): void { } }, }); + plugin.addCommand({ + id: "unicode-formatter:bullet-to-arrow", + name: "Convert List Bullets to Arrow", + editorCallback: (editor) => { + const selection = editor.getSelection(); + if (selection) { + editor.replaceSelection(bulletToArrow(selection)); + } + }, + }); plugin.addCommand({ id: "unicode-formatter:bullet-to-emdash", name: "Convert List Bullets to Em Dash", diff --git a/src/formatter.ts b/src/formatter.ts index e4e2b71..d6015b1 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -22,3 +22,9 @@ export function bulletToEmdash(text: string): string { line.startsWith("* ") ? "β€” " + line.slice(2) : line ).join("\n"); } + +export function bulletToArrow(text: string): string { + return text.split("\n").map(line => + line.startsWith("* ") ? "β†’ " + line.slice(2) : line + ).join("\n"); +}