aboutsummaryrefslogtreecommitdiff
path: root/svg.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-11-11 15:06:26 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-11-11 15:06:26 -0500
commitf7f20bab63522e169e464f041f47db45e4a5cfb2 (patch)
tree604152edd8f09c9d828bd34c28e83214eb7c2286 /svg.bqn
parent740a873f9eeb02ae120aa9d6090076cfcce15a05 (diff)
Minor performance improvements in Enc
Diffstat (limited to 'svg.bqn')
-rw-r--r--svg.bqn11
1 files changed, 4 insertions, 7 deletions
diff --git a/svg.bqn b/svg.bqn
index 2881a925..be859fec 100644
--- a/svg.bqn
+++ b/svg.bqn
@@ -6,16 +6,13 @@ Highlight ← {
(1¨ <⊸∾ ·AddT⌾⊑GetHighlights)⊸Modify 𝕩
}
-IsLines ← 1<≡
-DeNest ← {(3⌊≡)◶⟨!∘0,⥊<,⊢,∾𝕊¨⟩ ⥊𝕩}
-Indent ← " "⊸∾¨ DeNest
-
# Create a node from a tag name and interior text.
Enc ← {
+ DeNest ← {(3⌊≡)◶⟨!∘0,⥊<,⊢,∾𝕊¨⟩ ⥊𝕩}
open ← ∾⟨"<",𝕨,">"⟩
- close← ∾⟨"</", (⊑𝕨⊐" ")↑𝕨, ">"⟩
- l ← IsLines 𝕩
- ∾ open (Indent⍟l 𝕩){𝕨‿𝕗‿𝕩}○(⥊∘<⍟l) close
+ close← ∾⟨"</", (∧`𝕨≠' ')/𝕨, ">"⟩
+ l ← 1 < d←≡𝕩
+ ∾ open ({" "⊸∾¨(∾DeNest¨)⍟(3≤d)⥊𝕩}⍟l 𝕩){𝕨‿𝕗‿𝕩}○(⥊∘<⍟l) close
}
Void ← {∾⟨"<",𝕩,"/>"⟩}