aboutsummaryrefslogtreecommitdiff
path: root/md.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-24 14:08:54 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-24 14:08:54 -0400
commitb2806d7af02e46069c5604baab70592f3e6096bc (patch)
tree5d4adcb13e1168ae6ee0c5d0e695c7705bdc1c6b /md.bqn
parent9bccc26a0c3231d7cc9adc37c1a850ef44fd436a (diff)
Support table column alignment in md.bqn
Diffstat (limited to 'md.bqn')
-rw-r--r--md.bqn13
1 files changed, 8 insertions, 5 deletions
diff --git a/md.bqn b/md.bqn
index 428992d0..45fdada0 100644
--- a/md.bqn
+++ b/md.bqn
@@ -254,14 +254,17 @@ Markdown ← {filename𝕊𝕩:
r ← b > » '\' = 𝕩 # Non-escaped bars
1 -˜ (¬r∨«b>r) × o + +` r
}
+ alignments ← (" align="""∾∾⟜"""")⍟(0<≠)¨ ""‿"right"‿"left"‿"center"
ProcTable ← {
rows ← (Trim¨ CutTableRow⊸⊔)¨ 𝕩
- inc ← ¬ rule ← ∧´∘∾¨'-'=rows
- rows ↩ ProcInline¨¨⌾(inc⊸/) rows
+ incl ← ¬ rule ← (∧´∾∊"-:"˙)¨ rows
+ align ← alignments ⊏˜ (+˜⊸+´0‿¯1⊏⊢)¨ ':' = ⊑ rule / rows
+ rows ↩ ProcInline¨¨⌾(incl⊸/) rows
rows ↩ (⊏rows) (⊢ ∾ ⟨""⟩ /˜ 0⌈-○≠)¨ rows
- rowType ← inc / +` rule # Head or body
- DoRow ← { lf ∾ JoinLines 𝕨⊸Html¨ 𝕩 }
- rows ↩ (rowType ⊏ "th"‿"td") DoRow¨ inc/rows
+ rowType ← incl / +` rule # Head or body
+ tags ← rowType ⊏ "th"‿"td"
+ DoRow ← { lf ∾ JoinLines 𝕨 Html¨ 𝕩 }
+ rows ↩ (<˘ tags ∾⌜ align) DoRow¨ incl/rows
rowGroups ← ¯1 ↓ rowType ⊔○(∾⟜2) "tr"⊸Html¨ rows
sections ← "thead"‿"tbody" Html⟜(lf ∾ JoinLines)¨ rowGroups
"table" Html lf ∾ JoinLines (0 < ≠¨rowGroups) / sections