OK, my good people…
I’ve rewritten the whole thing (here). It now supports all three types of pandoc tables (simple_tables, multiline_tables, and grid_tables but not pipe_tables), and therefore cells with multiple lines as well. I didn’t bother with alignment.
Why is this half-ed? Because @ExpandingMan was right:
Even if I populate my table with the actual values I want in the resulting document, and the resulting table contains actual data instead of differently sized tags (for Mustache.jl to replace), I get hit by including a link. So the actual link is typically much wider than how it gets rendered in the resulting document (where it turns into a hyperlink). So the table still doesn’t look close to how I want it. So I will be abandoning this markdown method and listen to wiser people than me…
But, for what it’s worth, the code is out there, fork it!
julia> using MDtables
julia> a = [string(round(rand(), rand(1:6))) for i in 1:3, j in 1:5]
3×5 Array{String,2}:
"0.9" "0.69741" "0.1" "0.55514" "0.9299"
"0.32" "0.354" "0.759" "0.4579" "0.4"
"0.873" "0.2069" "0.1" "0.292993" "0.86"
julia> a[1,2] = "row 1\nrow 2"
"row 1\nrow 2"
julia> open("a.md", "w") do o
print(o, print(GridTable, a))
end
results in this:
+--------+------+--------+--------+--------+
|0.86284 |row 1 |0.044129|0.946186|0.3 |
| |row 2 | | | |
+========+======+========+========+========+
|0.235 |0.249 |0.295207|0.081 |0.764316|
+--------+------+--------+--------+--------+
|0.418278|0.8516|0.82 |0.38 |0.27575 |
+--------+------+--------+--------+--------+