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:
+11
-1
@@ -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",
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user