Files
obsidian-unicode-formatter/src/unicode-maps.ts
T
schihei fd74c0987e Implement Unicode text formatter plugin
- Add unicode-maps.ts with BOLD_MAP, ITALIC_MAP, BOLD_ITALIC_MAP from Unicode Sans-Serif ranges
- Add formatter.ts with transformText(text, style) using the maps
- Add commands.ts registering three editorCallback commands (bold, italic, bold-italic)
- Replace sample plugin boilerplate in main.ts with UnicodeFormatterPlugin wired to registerCommands
- Update manifest.json with correct id, name, and description
- Delete unused settings.ts boilerplate

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 19:21:16 +01:00

27 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function buildMap(
upperStart: number,
lowerStart: number,
digitStart?: number
): Record<string, string> {
const map: Record<string, string> = {};
for (let i = 0; i < 26; i++) {
map[String.fromCharCode(65 + i)] = String.fromCodePoint(upperStart + i);
map[String.fromCharCode(97 + i)] = String.fromCodePoint(lowerStart + i);
}
if (digitStart !== undefined) {
for (let i = 0; i < 10; i++) {
map[String.fromCharCode(48 + i)] = String.fromCodePoint(digitStart + i);
}
}
return map;
}
// Sans-Serif Bold: U+1D5D4U+1D5ED (upper), U+1D5EEU+1D607 (lower), U+1D7ECU+1D7F5 (digits)
export const BOLD_MAP: Record<string, string> = buildMap(0x1D5D4, 0x1D5EE, 0x1D7EC);
// Sans-Serif Italic: U+1D608U+1D621 (upper), U+1D622U+1D63B (lower)
export const ITALIC_MAP: Record<string, string> = buildMap(0x1D608, 0x1D622);
// Sans-Serif Bold-Italic: U+1D63CU+1D655 (upper), U+1D656U+1D66F (lower)
export const BOLD_ITALIC_MAP: Record<string, string> = buildMap(0x1D63C, 0x1D656);