Skip to content

Instantly share code, notes, and snippets.

@JenniferMack
Created April 2, 2015 05:11
Show Gist options
  • Save JenniferMack/aea0f244344f56ccb6f9 to your computer and use it in GitHub Desktop.
Save JenniferMack/aea0f244344f56ccb6f9 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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