I think this is already working for tab indented code, and actually now that I try it works for space indented (4) code too. Maybe the code you were pasting was 2 space indented? Try converting to 4 spaces and I think it will work.
I use a script that adds strikethrough and a @done(YYYY-MM-DD) “tag”. I think it’s posted on the Bike Extensions wiki, though I did use ChatGPT to translate that thing to AppleScript. Anyway, the original script doesn’t seem to apply any specific attribute to the row, just formats the text and appends the @done tag.
I have now replaced that script to toggle the “done” attribute and append the @done tag, which does as expected. But because there might be “native” tags coming in the future, I want to make sure the script doesn’t cause filtering problems down the road. Because ChatGPT built it after a few trials and errors, it might also be needlessly complex.
Any suggestions/words of caution?
tell application "Bike"
tell front document
set selectedRow to selection row
-- Get the current content of the selected row
set currentContent to name of selectedRow
-- Check for the presence of a data-done attribute
set hasDoneAttribute to false
set doneAttributeValue to ""
repeat with attr in attributes of selectedRow
if name of attr is "data-done" then
set hasDoneAttribute to true
set doneAttributeValue to value of attr
exit repeat
end if
end repeat
if hasDoneAttribute then
-- If a data-done attribute is present, remove it
delete attribute "data-done" of selectedRow
-- Only attempt to remove the @done tag if the attribute's value is long enough to contain a date
if (length of doneAttributeValue) ≥ 10 then
set tagToRemove to " @done(" & text 1 thru 10 of doneAttributeValue & ")"
if currentContent contains tagToRemove then
set name of selectedRow to text 1 thru -((length of tagToRemove) + 1) of currentContent
end if
end if
else
-- Get the current date in the desired format
set currentDate to do shell script "date '+%Y-%m-%d'"
set currentTimestamp to do shell script "date -u '+%Y-%m-%dT%H:%M:%SZ'"
-- Add the "data-done" attribute with the current timestamp value
make new attribute with properties {name:"data-done", value:currentTimestamp} at selectedRow
-- Append the "@done(YYYY-MM-DD)" tag to the content
set doneTag to " @done(" & currentDate & ")"
set name of selectedRow to currentContent & doneTag
end if
end tell
end tell
Currently when I toggle the done status through outline-spacebar, it visually only applies strikethrough and toggles the checkbox in the task box. I understand that it also applies a done attribute in the back end. I want that AND add a @done(YYYY-MM-DD) at the end of the row text, which currently Bike does not do out of the box.
I want to future-proof this workflow so I won’t have issues later with tag filtering if visible @done tags are added by Bike devs.
PS: I did notice the script I posted only works on the current date. Let’s ignore that issue for now, I just want to know what to look out for.
I think the script looks good, the attribute and date format both match what Bike’s using internally, so that’s the important part. Eventually I expect Bike to add tags. And when it does that I expect it to render a tag with a date for data-done. At that point the @done() will become bit redundant, but won’t hurt anything.
Update Maybe to make things a bit clearer… when future Bike renders a tag, I don’t expect that tag to be part of the text content. It won’t be a syntax highlighted tag that’s part of the row content such as @done(value)… instead it will be rendered as a separate UI element, kinda how the numbers in numbered rows are now rendered separate from the text content.
I’m not sure, but it seems to be relatively flexible. Chinese and Hebrew characters seem OK. As do dashes and underscores. Generally I think it should work.
( I’m not aware of one that has been written since row types were introduced, so I guess you may have tried something that targeted earlier versions of Bike)
If you can describe the use case, and the problem that it aims to solve, we may be able to draft something.
It makes sense to me that the markdown script (unless very recent) doesn’t do anything special with row types yet.
I don’t see how that should make things crash…
Can you give me the exact series of steps to reproduce the crash. I have tried cmd+k, change row type, followed by Esc and that seems to work fine for me.
I think @complexpoint and I were confused when you said “markdown script”.
I think maybe instead you mean the markdown inspired patterns that are used by the “smart row types” feature in Bike 1.13. For example when you (@brienjohn) say “markdown script” you mean typing "1. " to get an ordered list I think. While @complexpoint and I were thinking you mean’t running an AppleScript that did some conversion between a Bike outline and Markdown formatted text.
Still trying to get to the bottom of the crash you mention. I see it in the video that you shared with me, but I can’t reproduce it. If anyone else has seen a crash when:
Select some body text
Use show formatting pallet
Change type to heading
Close formatting pallet (and see crash)
Please let me know. I’m still not able to reproduce such a crash, and I really need to be able to reproduce the crash to be able to fix it.