Space Script - Using * instead of _ for italics

I made some adjustments to cursor placement, so that the command can also be used before writing any text.

```space-script
silverbullet.registerCommand({
  name: "Text: Italic",
  key: "Ctrl-i"
}, async () => {
  const selection = await editor.getSelection();
  const from = selection.from;
  const to = selection.to;
  if (from === to) {
    await editor.dispatch({
      changes: [
        { from: from, to: to, insert: "**" }
      ],
      selection: { anchor: from + 1 }
    });
  } else {
    await editor.dispatch({
      changes: [
        { from: from, to: from, insert: "*" },
        { from: to, to: to, insert: "*" },
      ]
    });
  }
});

I’m also looking forward to watching the video on Space Lua and using that feature! Outside of using SilverBullet, I recently switched from pdfTeX to the LuaTeX engine, but I haven’t written Lua code yet.

2 Likes