Bike 2.0 (Preview 251-252)

252:

  • Improved attribute handling when read/write .bike files
  • Fixed {"bikemd": true} frontmatter in Plain Text file opens content as .bikemd

251:

  • Added JSON metadata to all supported formats
  • Added Escape Markdown syntax (that you type) in .bikemd
  • Added encoding of unordered rows with + list marker in .bikemd
  • Added ID tracking for internal links in in .bikemd
  • Updated AppleScript command to evaluate scripts
  • Updated to no longer prefix attributes with data- at runtime
  • Updated AppleScript select row behavior to match Bike 1.x
  • Fixed focus mode paragraph
  • Fixed Learn and Ignore Word
  • Fixed paste into empty document
  • Fixed invalid characters no longer breaking file load
  • Fixed problems in save dialog when changing file formats
  • Fixed cases where autocorrect was doing the wrong thing
  • Fixed API bug that could include extra rows when removing or moving rows
  • Removed Outline metadata APIs — a more flexible option will be added soon

Download:

2 Likes

I “think” the .bikemd format has all the needed features to give it parity for standard .bike files, bugs and suggestions still welcome.

The markdown format has the same capabilities as the standard format, but it does have different defaults (ie default format always saves “id”, “created”, and “modified”, while bikemd does not. Instead it only saves ids for rows that are internally linked too. I expect to eventually make which attributes are saved configurable in all formats through the JSON metadata/frontmatter that’s now part of each format.

Also in the name of making the Markdown format better I have removed the data- naming scheme from the runtime row attributes. That means when attributes are saved to the markdown format they won’t be quite so verbose. This change also effects API’s and outline paths. For example in outline paths “done” rows are now matches with .@done instead of the old .@data-done.

Another breaking change is the AppleScript command to evaluate javascript in Bike’s app context. Previously you would pass in javascript text and 1)That script was evaluated and 2) That script was expected to define a function named “run” which was then called with any passed inputs. I’ve updated the documentation here with new evaluate command examples.

I had mentioned release note:

  • Allowed opening Plain Text as bikemd by including { "bikemd": true } front-matter

And it was working, but just found bug. So that’s waiting for next release now.

1 Like

In a .bike this involves typing the JSON a literal in-line ?

On attributes – these are still to serialised (in .bike files) with a data- prefix, as in data-created and data-modified ?


I notice that a .bike XML file which comes in with an unprefixed attribute like

testing="alphabeta"

  1. Preserves that attribute on saving (though it doesn’t seem to be included, at least at present, on Edit > Copy in the com.hogbaysoftware.bike.xml pasteboard item
  2. Aquires a data- prefix during serialisation, but that event is, at the moment, accompanied by the creation of data-data- prefixed duplicates of creation and modification date attributes.

So, for example, with (presumably unexpected) data-data-created and data-data-modified

<?xml version="1.0" encoding="UTF-8"?>
<html>
  <head>
    <meta charset="utf-8"/>
  </head>
  <body>
    <ul id="Cix3W5tMtftJdfBwo_MCC" data-created="0001-01-01T00:00:00Z" data-modified="0001-01-01T00:00:00Z" data-data-created="0001-01-01T00:00:00Z" data-data-modified="0001-01-01T00:00:00Z" data-testing="alphabeta">
      <li id="4ea36oglXdki-gHMBZCoA" data-created="2025-10-23T09:03:55Z" data-modified="2025-10-23T09:03:58Z">
        <p>Here is a sample text</p>
      </li>
    </ul>
  </body>
</html>

In a script element like this (for .bike and .opml):

<?xml version="1.0" encoding="UTF-8"?>
<html>
  <head>
    <meta charset="utf-8"/>
    <script id="outline-metadata" type="text/json">
      {"ignore-words":["teh"]}
    </script>
  </head>
  ...

Ah, shoot, and thanks. I need to look into this. The intention is that data-created is read into the runtime as created and then serialized back out as data-created. The other intention is id is special cased as not prefixed with data-. I hadn’t thought about round tripping other non data prefixed attributes. Will think.

1 Like

I “think” build 252 fixes the .bike format attribute problems. Please let me know if you notice anymore oddities.

The general rule for row level attributes should be:

  1. Any attribute that is not defined in XHTML 1.0 will be encoded with a leading data- prefixed to the attribute name.
  2. When reading all found data- prefixes are stripped.

I’m not as careful with text attributes, they are just encoded as found, should probably fix that, or relax all the data- encoding in row level elements, but for now leaving as is.

1 Like

Thanks for the updates, markdown formatting is much cleaner now!

First observation:

  • Create and save a new bike (.md) file in Bike
  • Edit and save same .md file outside of Bike
  • Open the .md in Bike 2
    • Result: Rich text formatting breaks



Is this an expected behavior? I mean should we edit markdown files outside of Bike or not? Or will this change in the future?

This applies to true markdown files; bike markdown files does not have this issue

If I follow correctly, this is intended.

The reason is that you are using .md extension, not .bikemd extension. When using .md Bike will just treat as a plain text file. This is because Bike only understands a specific set of Markdown syntax, if it tried to open any old Markdown file into Bike’s rich text editor it would loose information on save.

Workaround!

Add this front matter to the file:

---
{"bikemd":true}
---

When Bike sees that then it ignores file extension and will treat the file as .bikemd. I hope that works and makes sense. Let me know if not.

1 Like

ah yes, thanks for reminding me about this.

  • Fixed {"bikemd": true} frontmatter in Plain Text file opens content as .bikemd

I tried this but it didn’t work. Steps:

  • save file as .md in Bike 2
  • edit the file in markdown editor to add {"bikemd":true} to the frontmatter and save
  • open the file in Bike 2 again

I still have broken formatting. Am I doing something wrong?

I’m on Bike 252, and my current frontmatter:

---
{"root-id":"mImjXbSNVD5HDGPgtDGrq"}
{"bikemd":true}
---

Ok, i found the issue; I think it was my mistake.

Frontmatter should look like this:

---
{"bikemd":true,"root-id":"ApPuIXraKSiUrg1BZqy0y"}
---
1 Like

I’m going to change things also so that when Bike saves a new Bike Markdown document while using a non .bikemd file extension, it will add that frontmatter automatically.

2 Likes

Amazing work and app!

I’ve been trying to find a way to have Vim keybindings into your app, especially for the outline mode. Do you think that this is doable with the extensions feature you mention that is available starting on version 2 of the app?

If that’s the case, I might try to create the extension for this!

Thanks!

I think it should be possible, though I’m not all that familiar with details of what VIM keybindings require. The extension API does have what I think is a pretty good system for adding keybindings.

You can set different keybindings for text or outline mode. Return true to consume the key event, false to allow other processing.

And let me know when you run into any problems!

I have a working extension that implements basic Vim functionality on Bike 2. How should I publish it?

Ah, nice. How was implementation, did you run into any pain points?

I don’t know yet, suggestions welcome.

Even after Bike 2.0 is final I expect the extension system to be in “preview”. I think it will be good to have it tested only by more adventurous users for a while before making extensions too easy to find and install. In particular I don’t expect to build in any extension browser or management system into Bike right away.

Given that I currently see the bike-extension-kit repo as the entry point into Bike extensions. Maybe the simplest thing would be to list all “published” extensions in the README?

I’m open to other suggestions, or send me a link and I’ll add what you have.

1 Like

Perhaps a default, in the meanwhile, might be a link to a Github repo
and its README.md ?

Yes, I would encourage that. Pull requests linking back to any extension you want to share (also short description) are welcome.

1 Like

Late answer, but a complete one: the vim extension is now published.

What it does today, on Bike 2 (tested on builds 293 and 311): hjkl over rows (with h/l folding), counts, gg/G, dd / yy / p / P with a register that keeps subtrees, types and attributes, cc, o/O, zo/zc/za/zR/zM, L/H to focus in/out, a row-wise visual mode (v, motions extend, y/d/c/p/>/<), and u, Control-r, /, n, N, >>, << wired to Bike’s own commands. Insert mode is just Bike’s text mode; the mode is derived from the selection type, so Escape handled by Bike keeps the extension in sync. The README has the full keymap and the non-goals (no in-row character motions, no . repeat, no macros/marks/ex commands).

Pain points, since you asked — two batches.

Back in December, against preview 251/252:

  1. Multi-key sequences had to be hand-rolled with a pending buffer and timers, and it was flaky enough that I dropped to single keys (yy → y, dd → d, gg → g). KeySequence with spaces fixes this completely; y y, d g g, z shift-r all just work now, and the timer code is gone.
  2. No way to observe or set the editor mode, so the extension kept its own mode and drifted from Bike’s the moment the user pressed Bike’s Escape. Deriving it from selection.type (+ observeSelection) makes that state disappear.
  3. No subtree copy, hence a recursive cloner with a depth guard. Half solved: insertRows([row]) and new Outline(rows) copy a row’s text/type/attributes but drop its children, so the register is still rebuilt level by level (insertRows per parent). A RowSource that copies subtrees — or a children field on RowTemplate — would remove the last hand-rolled bit.
  4. h/l ended up as hoist because I had not found expand/collapse/isCollapsed. Now they fold, and focusIn/focusOut are on L/H.
  5. Counts were abandoned; with named commands they are ten tiny hidden commands (vim:.count-N) and a global pending count.

Against build 293 with kit v0.64.0 (I have not rechecked these on 311):

  1. bike-ext test: a command reached through bike.commands.performCommand from a test file dies with OutlineEditor/JSOutlineEditor.swift:369: Fatal error: JSContext not available as soon as it runs an editor.transaction/outline.transaction or calls showStatusMessage — even with a timeout, and even on bike.frontmostOutlineEditor. Calling the same handler function directly from the test works, and so does the same command from a keybinding or bike evaluate script. I ended up exposing the handlers on the AppExtensionContext for the tests. The tutorial’s performCommand("tutorial:archive-done", { editor }) example would hit the same thing, I think, since it runs a transaction.
  2. Assigning row.text = AttributedString.fromMarkdown(...) crashes the app (setter path); row.text.replace is fine. If the setter is not meant to exist, the .d.ts could mark text readonly.
  3. Key spelling: ctrl-r is accepted silently but never listed or fired; control-r works. Either the alias from the doc comment is missing or the failure should throw like alt-x does.
  4. Small ones: bike-ext test refuses to run while Bike is open (fine), but after a crash the next test run hangs on macOS’s “reopen windows?” dialog behind other windows; console output from tests does not reach the terminal, only assertion messages do; and Outline.transaction inside a describe body is fine while any editor method there is not (the test document’s editor is not ready until the run loop turns).

The two main workarounds (the test hook and the row-by-row register copy) are commented in the source, so they are easy to delete once the API changes.

For anyone who wanted this, the two older requests were Vim-style bindings and Vim-Like Keybindings with Apple Script . As far as I can tell this is the first third-party entry in the registry, so I’d appreciate a look at the PR.

3 Likes

Thanks and just letting you know this is on my todo list. Had a cold the last few days, but feeling better today.

1 Like

I think the latest 312 release fixes most of these.

Crashes you hit

  • “JSContext not available” from performCommand in tests. When bike-ext test ran, Bike loaded a second copy of your extension, and the installed copy’s commands stayed registered. performCommand could call the stale copy, whose script context had gone away, and that was a hard crash. The test runner now unloads the replaced copy, and a missing context now throws a JS error instead of crashing Bike. You should be able to drop the context['vim'].perform test hook and call bike.commands.performCommand directly.
  • row.text = AttributedString.fromMarkdown(...) crashing. The crash happened when the assigned text was already attached to a row: another row’s text, or the same fromMarkdown value assigned to a second row. The setter now copies the value, so row.text = … is safe however you use it.

bike-ext test

  • After a crash, the next test run no longer stalls behind the “reopen windows?” dialog.
  • console.log output from tests and extensions now prints in the terminal during test runs.
  • Editor readiness: I ran your suite on my current build with your three await tick() calls removed, and all 61 tests passed. So that workaround shouldn’t be needed anymore.
  • bike-ext submit now validates against the registry’s schema correctly, so you won’t have to add the entry by hand next time.

Copying branches

Passing rows to new Outline(...) or insertRows(...) now keeps their nesting when a row’s parent is also in the list. That makes row.descendantsWithSelf a branch copy, and your level-by-level copyRows becomes:

new Outline(cover.flatMap((row) => row.descendantsWithSelf))

This is still a bit odd, but makes copy branch possible without your own walk.

Multiple windows

state.ts keys visual mode and the mode indicator by editor.outline.root.id, but that id is 0 for every outline. With two windows open, visual mode carries over when you switch windows, and the second window can miss its -- INSERT -- / -- VISUAL -- label. There’s a new editor.id for this. Each window pane gets a unique id that stays the same while it’s open, so key your per-editor state by editor.id instead.

Key handlers

The bigger addition is a way to see raw key presses, so modal extensions don’t have to squeeze vim into fixed key sequences:

bike.keybindings.addKeyHandler({
  keymap: 'block-mode', // or 'text-mode'
  handle({ key, editor, selection }) {
    // key is spelled like keybindings: 'j', 'shift-g', 'control-r', 'escape'
    return false // return true to consume the key
  },
})

Handlers get first refusal on every key: they run before the keymap’s keybindings and before menu shortcuts. Each press reaches a handler once. They’re skipped during IME composition and while a keybinding sequence is part-typed.

With this you can parse vim input yourself, the way CodeMirror’s vim mode does. That makes counts in the middle of a command (d3j), registers, . repeat and insert-mode keys like ctrl-w possible. It would also replace the ten vim:.count-N commands and the global pending count.

Thanks for all the feedback.