From eada33d25b959649e632f4a25635505adcbe222e Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 17 Jul 2020 17:23:57 -0400 Subject: Highlight within code tags in html blocks (not robust) --- doc/md.bqn | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/md.bqn b/doc/md.bqn index 4f19be7f..b303fb30 100644 --- a/doc/md.bqn +++ b/doc/md.bqn @@ -182,7 +182,10 @@ Markdown ← {𝕊𝕩:1𝕊𝕩; extensions𝕊𝕩: # HTML blocks # Lazy rule: if it starts with < and contains >, it's probably HTML IsHtmlBlock ← ⊑ ">"⊸∊ - ProcHtmlBlock ← JoinLines∘⊢ + ProcHtmlBlock ← { + codeMask ← "" ¯6⊸⌽⊸(>○(⌈`(1+↕∘≠)⊸×))○(⍷⟜𝕩 ∾ 0⥊˜1-˜≠) "" + (1¨ <⊸∾ codeMask⊸GetMultiHighlights)⊸Modify 𝕩 + }⍟extensions⟜JoinLines lineChars‿lineClas‿procFns ← <˘⍉>⟨ "" ‿ (!∘0) ‿ ProcParagraph @@ -226,11 +229,8 @@ Markdown ← {𝕊𝕩:1𝕊𝕩; extensions𝕊𝕩: 𝕩 ↩ ' '¨⌾((codeMask∧𝕩=lf)⊸/) 𝕩 # If span has both a leading and a trailing space, they are removed. remSpace ← I2M ⥊ ((1<-˜´˘)∧·∧´˘' '=⊏⟜𝕩)⊸/ -⟜0‿1˘ codeBounds - codeMaskl ← 1⊸⌽⊸∨ codeMask - fillMask ← ¬ codeMaskl / codeMask - allCode ← ' '¨⌾(fillMask⊸/) codeMaskl / 𝕩 - ⟨code,codePos⟩ ← extensions◶(2⥊<⟨⟩)‿GetHighlights allCode - codePos +↩ fillMask ((1-˜⍋⟜codePos) ⊏ -˜)○/ codeMaskl>codeMask + codeMask ∧↩ ¬ remSpace + ⟨code,codePos⟩ ← codeMask extensions◶(2⥊<⟨⟩)‿GetMultiHighlights 𝕩 include ← ¬ remSpace ∨ ≠` I2M ⥊ ctInds codeBounds ↩ ⥊ -⟜1‿0˘ codeBounds unused ← actual ∧ include ∧ ¬ codeMask @@ -374,6 +374,13 @@ GetHighlights ← { bc←bd/col (⥊(0 𝕨⟩ +} head ← ""∾lf ConvertFile ← head ∾ Markdown∘•LNS -- cgit v1.2.3