Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple table maker that outputs MarkdownXL for Ulysses.
#! /usr/bin/env ruby
table = "~~\n~~ <table>\n"
ARGF.each_line do |line|
table << "~~ <tr>\n"
row = table =~ /th/ ? "td" : "th"
line.chomp.split('|').each {|cell| table << "~~ <#{row}>#{cell}</#{row}>\n" }
table << "~~ </tr>\n"
end
puts "%% +---------------------------+"
puts table + "~~ </table>\n~~\n"
puts "%% +---------------------------+"
@JenniferMack

This comment has been minimized.

Copy link
Owner Author

JenniferMack commented Apr 2, 2015

A table maker for Ulysses.

$ md-tables.rb
one|two three|four
five|six seven|eight
nine|ten|eleven twelve
^D
%% +---------------------------+
~~
~~ <table>
~~  <tr>
~~   <th>one</th>
~~   <th>two three</th>
~~   <th>four</th>
~~  </tr>
~~  <tr>
~~   <td>five</td>
~~   <td>six seven</td>
~~   <td>eight</td>
~~  </tr>
~~  <tr>
~~   <td>nine</td>
~~   <td>ten</td>
~~   <td>eleven twelve</td>
~~  </tr>
~~ </table>
~~
%% +---------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.