Scaling My Partner’s Poetry (Part 1)

The preface here is that my girlfriend is a prolific poet. She has written 2 or 3 poems each day for the better part of a year. Her Instagram has grown to about 2,000 followers rather quickly.

Her poems were all stored in Google Docs and hard for me to access programmatically. I’d often say things like, “Yeah but if I could access your poems I could do XYZ with a couple hours and my favorite programming language.”

My first idea for scaling was to have auto-generated Instagram images that were tailored to her style. That program morphed into what is now, an exploratory side project to try out Vue.js (frontend) + Rails API (backend). I stopped working on it because version 2 would have to function like a paired down to be useful.

In Part 2 I add the Instagram URL to the Markdown poem file.

Escaping Google Docs Format

To make her poetry scalable my first step was to leave the Google Docs proprietary format using Google Takeout. This converted them to .txt files which are easier to manage.

Next, I used Bulk Rename Utility to change the extensions of the .txt files to .md (Markdown).

Adding Front Matter Programmatically

I wanted to add Front Matter to the Markdown files to ensure the metadata about the poem stays with the poem itself. Somewhere along the process the Created and Last modified file attributes were overwritten. I could have retraced my steps and tried to prevent it, but I still had a previously made CSV file containing the dates. I decided to use that instead of backtracking.

I made the following script (Ruby language) to prepend frontmatter to about 900 or so poems. I grabbed the title_magic function from here, and the file_prepend function from here.

# frozen_string_literal: true

# add_frontmatter.rb

require 'find'
require 'fileutils'
require 'date'
require 'csv'

$data = []
CSV.foreach('dates.csv', headers: true) { |row| $data << row.to_hash }

def start
poems = Dir.glob(File.join(Dir.home, 'Drive', 'Poetry', '**', '*.md'))
poems.each { |poem| add_frontmatter(poem) }

def add_frontmatter(poem)

string_to_prepend = '---' + "\n"
'title: ' + poem_title(poem) + "\n"
'date: ' + poem_date(poem) + "\n"
'tags: \[\]' + "\n"
'---' + "\n"
file_prepend(poem, string_to_prepend)

def poem_title(poem)
title_magic(File.basename(poem, '.md').gsub('_', ' '))

def poem_date(poem)
original_date = $ do |data|
File.join(Dir.home, 'Drive', data['path']) == poem

if original_date.empty?
elsif original_date.count == 1

def file_prepend(file, str)
new_contents = '', 'r') do |fd|
contents =
new_contents = str << contents
end, 'w') do |fd|

def title_magic(sentence)
stop_words = %w[a an and the or for of nor] { |word, index| stop_words.include?(word) && index > 0 ? word : word.capitalize }.join(' ')


Leave a Reply

Your email address will not be published. Required fields are marked *