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
+11 -1
View File
@@ -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",
+6
View File
@@ -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");
}