MIC-03-3 Starting to write a Pandoc writer for Bike

Today, I am focused on creating a first cut of a pandoc writer for Bike. I will start by having a writer emit the simple output of a valid but empty Bike document. The next step would be to have the writer flatten a pandoc AST into a single list of plain text Bike nodes. I defer dealing with the rich text and hierarchical structures until I have the simple writer in place. Dealing with rich text and containment of elements requires me to better grok the pandoc AST, particularly what can contain which other element. I will use pandoc (Python library) and panflute interactively in a Jupyter notebook to facilitate that grokking. I aim for good coverage of pandoc AST examples by writing pandoc markdown, which I then convert to pandoc JSON (note the documentation on pandoc markdown.

Ideally, my pandoc Bike reader and writer will enable lossless roundtripping of Bike conversion. In other words, if I use the reader to convert a bike document to pandoc JSON and then use my pandoc Bike writer to convert the JSON to a Bike document, the resulting Bike document should essentially be the same the original document.

A question to answer as I dive into the pandoc writer for Bike: how to handle parts of the pandoc AST that I don\'t know how to translate into Bike elements but would nonetheless like to park in some placeholding structure?

MIC-03-2 My Bike outline automatically converted to markdown for Obsidian

I\'m pleased that I reached a programming milestone. Now whenever I save my main Bike outline (overall.bike), my CLI for interacting with Bike (and Bike outlines) is fired off (specifically, bike.py pandoc). I use Hammerspoon to look for changes in the enclosing directory for overall.bike and then I have some logic to check for telltale changes in overall.bike. I was stuck for a while: It turns out that the tricky part is detecting reliably whether there is data on stdin. My solution is good enough for now, but I will probably revisit it.

MIC-03-1 Writing and programming all day: so close

I've been writing all day, with a fluency that I've not had in a long while. What I've written isn't ready for sharing with the public, however. I've also made some good progress in getting my script to run but I'm stuck on an issue that might take 10 more minutes to solve -- or hours. I'm surprised that I'm serenely accepting however long it ends up taking. What choice do I have?

MIC-02-5 Small progress during a busy end of week

I set the stage for command groups in bike.py with [my latest change to bike.py](added sel2pb command to bike.py · rdhyee/python-learning@a161fe9).

It seems that Keyboard Maestro doesn't allow for watching for changes in files that already exist. Maybe, more likely, I've just not been able to figure out how. I have some progress using hammerspoon though. Here's a relevant part of my init.lua:


function list_true_flags(flags)
  local true_flags = " "
  for key, value in pairs(flags) do
    if value then
      true_flags = true_flags .. key .. " | "
    end
  end
  return true_flags
end

function fileModifiedCallback(paths, flagTables)
  for i, file in ipairs(paths) do
    if file == "/Volumes/ryvault1/MacHD/Users/raymondyee/obsidian/MainRY/bike/overall.bike" then
      local flags = flagTables[i]
      print(i, file)
      print_true_flags(flags)

      local timestamp = os.date("%Y-%m-%d %H:%M:%S")
      -- local message = timestamp .. " overall.bike changed\n"

      local logFile = io.open("/tmp/hschange.log", "a")
      logFile:write(timestamp .. list_true_flags(flags) .. "\n")
      logFile:close()
    end
  end
end

watcher = hs.pathwatcher.new("/Volumes/ryvault1/MacHD/Users/raymondyee/obsidian/MainRY/bike", fileModifiedCallback)
watcher:start()

MIC-02-3 Sick day

I woke up with a sore throat this morning: oh oh. I'm glad that I took my Sweetie's advice to take an afternoon nap. I'm feeling slightly better but should continue to rest today. I did make some tiny progress by using click to add parameters to python-learning/bike/bike.py at 62005c488359f587f1863457c5eba24bd0863688 · rdhyee/python-learning. I can now use Keyboard Maestro to launch bike.py and change the base heading level through a prompt. I hope to be programming with energy tomorrow. 🙂

MIC 02-2 Refining bike.py with more options and a better understanding of Pandoc

bike.py (python-learning/bike/bike.py at f1bf45be1e886bf66c3dad97d3b0694a847528b3 · rdhyee/python-learning) is my working script for converting the currently selected rows in Bike (and their enclosed rows) to Obsidian flavored markdown, copying that markdown to the clipboard, and also writing it to a ScratchPad note in my Obsidian vault.

I am working on more fully integrating bike.py into my workflow before polishing the script to make it more useful to others and easier to maintain.

On my programming to-do list today and tomorrow are:

  • relearn Click and try out Typer so that I can add arguments and options to bike.py to change bike.py from a single purpose script to a script that will ultimately handle all aspects of automating the Bike program.
  • grok the containment hierarchy of the Pandoc AST -- what elements are allowed where in the tree hierarchy, specifically, whether I can wrap list items into anything other than a list-like container. I will study Document structure - Pandoc (Python Library) and use the Python pandoc library to help me grok the Pandoc metamodel.

MIC 02-1 A few thoughts about writing

Because I'm forcing myself to write in public during MyInfoCamp, I've been reflecting on how I write. I’m currently seeking a productive mix of "linear" and "nonlinear" writing. By linear writing, I mean, putting one word after another, and finishing one sentence before moving to writing my next sentence. (for some people, that means writing, plain and simple). By contrast, "nonlinear writing" is how I usually write: spitting out a collection of words and phrases as they come to mind, letting myself flit among ideas. I like to write in an outliner (such as Bike) because the outliner makes arranging the phrases into a hierarchy much easier than Microsoft Word. I have many notes scattered through my computer with lots of unrefined ideas, the side effects of my nonlinear writing process.

During the last week, I decided to shift more of my energy to writing linearly. I love the refreshing change, which seems to help me to deal with one of my perennial problems: too much "work in progress" (WIP). As the Kanban project methodology teaches, it's crucial to limit WIP; otherwise, it becomes very difficult to finish anything, because your efforts become diffuse, scattered over too many thoughts and incomplete sentences.

I wonder what writing "experts" (those who teach others how to write) would say about my distinction between linear and nonlinear writing. I find it hard to believe that I am happening upon some novel insight (even if it is novel for me.)

A key issue to dig into: when is it best to translate words into phrases into sentences? I now think that I could benefit from doing the translation earlier in my writing process.

One thing is clear: it's a mistake for me to give into the temptation of delegating to a LLM the task for translating words and phrases into coherent sentences of a first draft. That translation process is the heart of what makes writing the fraternal twin of thinking.

MIC-01-5 Working with pandoc format+extensions strings

Today, I dug into pandoc formats. I learned that there are two subfamilies of markdown formats. There are extensions that are associated with any given format. Some are enabled by default and some are turned off by default. I wrote code to compute the \"canonical\" and \"expanded\" versions of those pandoc format strings: rdhyee_utils/rdhyee_utils/pandoc at master · rdhyee/rdhyee_utils

MIC-01-4 Pandoc, tell me about yourself

I want to develop a mutually supportive habit of programming and writing together.  I feel torn right now because writing and coding feel like competitors for my focus and time.  I know that writing and programming are not enemies -- that I know -- but it will take patience and practice to harmonize (dare I say, synergize) them.

Over the past several months, I've made progress on programming MyInfoNet that pleases me. For better or worse, I've not spent much effort in communicating with others about the work I've been doing. While I jot copious notes to myself, I haven't forced myself to turn those notes into coherent prose.

Today, I've been focused on understanding how to use pandoc to handle Obsidian Flavored Markdown. Markdown is a popular lightweight markup language that has many "variants", "flavors", or "dialects".  I started experimenting with asking pandoc itself to tell me about the formats it supports and extensions that are supported for a given format (specifically markdown).