Created
June 13, 2024 07:20
-
-
Save leonid-shevtsov/9b70fdba9e9ece5acc7dcf593c8746df to your computer and use it in GitHub Desktop.
Convert a list of lines into Obsidian Canvas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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