Pre-processor application working with `mk` command line, erroring on 1st char via GUI

Viewed 17

I can successfully preview a given .bike file with the following preprocessor (<a> links pointing to graphic files pre-processed to <img> elements) if I pipe to mk at the command line:

/opt/homebrew/bin/jaq --from xml --to xml 'walk(
  if type == "object" and .t == "a" then
    if (.a.href? and (.a.href | test("\\.(png|jpe?g|svg|gif|webp|avif|bmp|tiff?|hei[cf]|ico)$"; "i"))) then

      ([.c[]? | select(type == "string")] | join("")) as $alt_text |

      .t = "img" |
      .a.src = .a.href |
      .a.alt = $alt_text |

      del(.a.href, .c)
    else
      .
    end
  else
    .
  end
)' notes2026-06-22.bike | mk

and in the Marked 3 GUI, as a run command action trigged on .bike extension, this appears to work (with notes2026-06-22.bike | mk deleted from the end, to assume standard input and output), when a .bike file is already loaded, and we click the run command test button which has the tooltip (Apply rules and reload all preview windows).

BUT, if we then close the .bike file, and try to preview it anew through File > Open for example, the result is a Command Error message:

Error: failed to parse: unknown token at 1:1

The relevant log section refers to difficulty accessing a bookmark for the jaq command.

ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] About to resolve symlinks for: /opt/homebrew/bin/jaq
ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] Resolved executable path: /opt/homebrew/Cellar/jaq/3.0.0/bin/jaq (from /opt/homebrew/bin/jaq)
ℹ️: 2026/06/22 11:53:00:330 am | No bookmark found for /opt/homebrew/bin/jaq, will request access
ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] hasWorkingBookmark: 0, executableAccessible: 0
⚠️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] Could not start accessing bookmark for /opt/homebrew/bin/jaq
ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] Executing external binary through shell (no bookmark): /bin/zsh -c "'/opt/homebrew/Cellar/jaq/3.0.0/bin/jaq' '--from' 'xml' '--to' 'xml' 'walk(   if type == "object" and .t == "a" then     if (.a.href? and (.a.href | test("\\.(png|jpe?g|svg|gif|webp|avif|bmp|tiff?|hei[cf]|ico)$"; "i"))) then        ([.c[]? | select(type == "string")] | join("")) as $alt_text |        .t = "img" |       .a.src = .a.href |       .a.alt = $alt_text |        del(.a.href, .c)     else       .     end   else     .   end )'"
ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] Working directory: /Users/robintrew/DayNotes
ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] About to launch task with path: /bin/zsh
ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] Executable verified (1361216 bytes on disk), stdin length: 2885
ℹ️: 2026/06/22 11:53:00:330 am | 🔵 [runCommand] Launching NSTask with path: /bin/zsh
ℹ️: 2026/06/22 11:53:00:394 am | 🔵 [runCommand] NSTask finished, exit status: 5, stdout: 0 bytes, stderr: 45 bytes

Any thoughts ?

2 Answers

I'm looking at ways I can work around this for you on my end, but in the meantime, you might try creating a jq file with the jaq script and calling it with -f from the Run Command. Might run into permissions issues, but it should request access as needed. Let me know if that helps at all.

creating a jq file with the jaq script and calling it with -f from the Run Command

Thanks, good thought.

With -f and a path to a .jq file the pattern still seems the same:

  1. If the streaming preview has already been set up from the command line, then the Run Command reload button works, and the log shows the graphic files in the Watch setup, but
  2. if we try to start a new preview from within the Marked GUI, with File > Open for example, we still get the message:
Error: failed to parse: unknown token at 1:1

(Presumably not a response to the XML declaration in line 1 of the Bike file ?)

<?xml version="1.0" encoding="UTF-8"?>

In the log, things go wrong at:

ℹ️: 2026/06/22 2:36:41:266 pm | Processing document [2026-06-22 1:36:41 pm +0000]
🔺: 2026/06/22 2:36:41:266 pm | ERROR No document (null)

FWIW at the command line I'm using this, without a problem:

bikemk() {
  if [ -z "$1" ]; then
    echo "Usage: bikemk <path-to-file.bike>"
    return 1
  fi

  /opt/homebrew/bin/jaq --from xml --to xml 'walk(
    if type == "object" and .t == "a" then
      if (.a.href? and (.a.href | test("\\.(png|jpe?g|svg|gif|webp|avif|bmp|tiff?|hei[cf]|ico)$"; "i"))) then
        ([.c[]? | select(type == "string")] | join("")) as $alt_text |
        .t = "img" |
        .a.src = .a.href |
        .a.alt = $alt_text |
        del(.a.href, .c)
      else
        .
      end
    else
      .
    end
  )' "$1" | mk
}

You probably know this, but just in case – in Marked 3.0.39 (1172) we no longer get an error message, but the pre-processing, which still works at the command line, fails silently. The main log reports zero bytes to stdout, and the pre-processor log shows

*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]

(This happens both with -f followed by filepath to .jq file, and with inline jq source)