From 08be7d1b030ddae97bcf3c05e9d4aed81ae685d5 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 16 Jul 2020 17:27:44 -0400 Subject: Start improving ProcInline code handling --- doc/md.bqn | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/md.bqn b/doc/md.bqn index 376c371b..8a33cc71 100644 --- a/doc/md.bqn +++ b/doc/md.bqn @@ -120,17 +120,6 @@ Markdown ← { "p" Html ProcInline ¯1 ↓ JoinLines ((Lead ' '⊸=)+"\#"≡2⊸↑)⊸↓¨ 𝕩 } - # Inline elements - ProcInline ← { - s←"`*"=⌜𝕩 - d←(⊢-2|⊢)∘≠⊸↑¨<∘/˘s - c←⊏s⋄r←¯1⌽l←≠`c⋄cs←l∧c - code←Highlight⍟doHighlight¨(1-˜(l∧r)×+`cs)⊔𝕩 - inc←¬l∨∨´<˘s - tags←∾d≠⊸⥊¨⟨""‿"",""‿""⟩ - ((/inc)∾(≠¨tags∾code)/(∾d)∾/cs) ⍋⊸⊏ (inc/𝕩)∾∾tags∾code - }⍟doHighlight - lineChars‿lineClas‿procFns ← <˘⍉>⟨ "" ‿ (!∘0) ‿ ProcParagraph "#" ‿ LenHeading ‿ ProcHeading @@ -140,6 +129,31 @@ Markdown ← { # "|" ‿ IsTable ‿ ProcTable ⟩ + ###### + # Inline elements + ProcInline ← { + puncChars ← "!""#$%&'()*+,-./:;<=>?@[\]^_`{|}~" + # Characters that start or end inline elements + # (we don't do fancy processing for these yet) + delimiters ← "`*_" + # The corresponding tags + dTags ← {("<"∾⊢∾𝕩∾">"˜)¨""‿"/"}¨ 1‿2/"code"‿"em" + + ProcCodeSpan ← { + 𝕩 ↩ ' '¨⌾((𝕩=lf)⊸/) 𝕩 + 𝕩 ↩ (1↓¯1↓⊢)⍟((⊢<○(∧´)⊑∾⊑∘⌽) ' '⊸=) 𝕩 + Highlight⍟doHighlight 𝕩 + } + + dMasks ← 𝕩⊸=¨ delimiters + dInds ← (⊢-2|⊢)∘≠⊸↑∘/¨ dMasks + c←⊑dMasks⋄r←¯1⌽l←≠`c⋄cs←l∧c + code←ProcCodeSpan¨(1-˜(l∧r)×+`cs)⊔𝕩 + inc←¬l∨∨´dMasks + tags ← ∾ dInds ≠⊸⥊¨ dTags + ((/inc)∾(≠¨tags∾code)/(∾dInds)∾/cs) ⍋⊸⊏ (inc/𝕩)∾∾tags∾code + } + ###### # Create the block structure using line classifications. lengths ← ≠¨ 𝕩 # Length of each line -- cgit v1.2.3