Skip to content

Instantly share code, notes, and snippets.

@leonid-shevtsov
Created June 13, 2024 07:20
Show Gist options
  • Save leonid-shevtsov/9b70fdba9e9ece5acc7dcf593c8746df to your computer and use it in GitHub Desktop.
Save leonid-shevtsov/9b70fdba9e9ece5acc7dcf593c8746df to your computer and use it in GitHub Desktop.
Convert a list of lines into Obsidian Canvas
# ruby lines_to_canvas.rb <items.txt >items.canvas
require 'random/formatter'
require 'json'
nodegap = 10
nodewidth = 300
nodeheight = 60
list = STDIN.readlines
# https://jsoncanvas.org/spec/1.0/
nodes = list.map.with_index do |line, index|
{
id: Random.uuid,
type: 'text',
x: 0,
y: index * (nodeheight + nodegap),
width: nodewidth,
height: nodeheight,
text: line.strip
}
end
puts({nodes:,edges:[],center:{x:0,y:0}}.to_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment