Action

Small Caps

Posted by David Blue, Last update about 1 month ago

Convert the current text selection to ꜱᴍᴀʟʟ ᴄᴀᴘꜱ case.

Steps

  • script

    // Get the currently selected text.
    let selection = editor.getSelectedText();
    
    // If there is no selection, exit.
    if (!selection) {
      context.cancel();
    }
    
    // Convert the selection to small caps.
    let smallCapsText = selection.toLowerCase().replace(/[a-z]/g, function(char) {
      switch (char) {
        case 'a': return 'ᴀ';
        case 'b': return 'ʙ';
        case 'c': return 'ᴄ';
        case 'd': return 'ᴅ';
        case 'e': return 'ᴇ';
        case 'f': return 'ꜰ';
        case 'g': return 'ɢ';
        case 'h': return 'ʜ';
        case 'i': return 'ɪ';
        case 'j': return 'ᴊ';
        case 'k': return 'ᴋ';
        case 'l': return 'ʟ';
        case 'm': return 'ᴍ';
        case 'n': return 'ɴ';
        case 'o': return 'ᴏ';
        case 'p': return 'ᴘ';
        case 'q': return 'ǫ';
        case 'r': return 'ʀ';
        case 's': return 'ꜱ';
        case 't': return 'ᴛ';
        case 'u': return 'ᴜ';
        case 'v': return 'ᴠ';
        case 'w': return 'ᴡ';
        case 'x': return 'x';
        case 'y': return 'ʏ';
        case 'z': return 'ᴢ';
        default: return char;
      }
    });
    
    // Replace the selection with the small caps text.
    editor.setSelectedText(smallCapsText);

Options

  • After Success Nothing
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.