From bbaa6992f3af5cad543c583d511b7c70e489eb16 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 1 Oct 2020 22:41:48 -0400 Subject: Fix some edge cases in markdown link detection --- md.bqn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/md.bqn b/md.bqn index de6d9203..64e7e245 100644 --- a/md.bqn +++ b/md.bqn @@ -346,16 +346,16 @@ Markdown ← {filename𝕊𝕩: # Links ghPath ← "https://github.com/mlochbaum/BQN/blob/master/"∾path ReplaceMDSub ← { ¯2 ("md"≡↑)◶(ghPath⊸∾)‿("README"•_r_"index"∘↓∾"html"˙)⍟(':'∧´∘≠⊢) 𝕩 } - ReplaceMD ← { ReplaceMDSub⍟(0<≠)⌾((⊑𝕩⊐"#")⊸↑) 𝕩 } - ProcLink ← { ∾⟨"",ProcInline 𝕨,""⟩ } + ReplaceMD ← extensions◶⥊‿{ ReplaceMDSub⍟(0<≠)⌾((⊑𝕩⊐"#")⊸↑) 𝕩 } + ProcLink ← { ∾⟨"",ProcInline 𝕨,""⟩ } # Find matched-depth [] and () pairs, then join adjacent ones brak ← (unused ∧ 𝕩⊸=)¨ 2‿2⥊"[]()" depth ← (+`-0⌊⊢)∘(-´)˘ brak - FindPairs ← ∘‿2 ⥊ 1⊸⊏ /˜ 2⊸⊏ ≠ (¯∞⊸»⊸=(∧+⊢)∞⊸«⊸=)∘⊏ + FindPairs ← ∘‿2 ⥊ 1⊸⊏ /˜ 2⊸⊏ (≠∧0≤⊢) ((1-˜+˜+»)∞⊸«⊸=)∘⊏ pairs ← depth <∘(FindPairs⍟(0<≠))∘⍉∘(∧(⊏˜≍˘⊢)⟜∾∾˘·/≠¨∘⊢)˘ /¨brak JoinPairs ← { e←1+1⊏˘𝕨 ⋄ b←⊏˘𝕩 ⋄ m←(≠b)>i←b⊐e - (m/𝕨) ∾˘ (m/i)⊏𝕩 + (m/𝕨) (0<≠∘⊢)◶(0‿4⥊0)‿(∾˘) (m/i)⊏𝕩 } lInds ← ∧○(0<≠)◶(0‿4⥊0)‿JoinPairs´ pairs linkPos ← ⊏˘ lInds -- cgit v1.2.3