Add "Convert List Bullets to Arrow" command

Adds bulletToArrow() to formatter.ts and registers the new
unicode-formatter:bullet-to-arrow command. Updates README accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 15:22:25 +01:00
parent 5befb3a0bc
commit 1fab274fd6
3 changed files with 20 additions and 2 deletions
+3 -1
View File
@@ -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 Italic** — converts letters to sans-serif italic (𝘈𝘉𝘊 / 𝘢𝘣𝘤)
- **Unicode Bold Italic** — converts letters to sans-serif bold italic (𝘼𝘽𝘾 / 𝙖𝙗𝙘) - **Unicode Bold Italic** — converts letters to sans-serif bold italic (𝘼𝘽𝘾 / 𝙖𝙗𝙘)
- **Remove Unicode Formatting** — converts any formatted Unicode characters back to plain ASCII - **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 - **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 - 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 Italic**
- **Format as Unicode Bold Italic** - **Format as Unicode Bold Italic**
- **Remove Unicode Formatting** — reverses any of the above back to plain ASCII - **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 `— ` - **Convert List Bullets to Em Dash** — replaces `* ` prefixes with `— `
The selected text is replaced in place. 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/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/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 | | `src/main.ts` | Plugin entry point — calls `registerCommands` on load |
### Unicode blocks used ### Unicode blocks used
+11 -1
View File
@@ -1,5 +1,5 @@
import { Plugin } from "obsidian"; 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) { function addFormatCommand(plugin: Plugin, style: FormatStyle, name: string) {
plugin.addCommand({ 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({ plugin.addCommand({
id: "unicode-formatter:bullet-to-emdash", id: "unicode-formatter:bullet-to-emdash",
name: "Convert List Bullets to Em Dash", name: "Convert List Bullets to Em Dash",
+6
View File
@@ -22,3 +22,9 @@ export function bulletToEmdash(text: string): string {
line.startsWith("* ") ? "— " + line.slice(2) : line line.startsWith("* ") ? "— " + line.slice(2) : line
).join("\n"); ).join("\n");
} }
export function bulletToArrow(text: string): string {
return text.split("\n").map(line =>
line.startsWith("* ") ? "→ " + line.slice(2) : line
).join("\n");
}