diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-10-04 13:50:02 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-10-04 13:50:02 -0400 |
| commit | 2b4c0501f9c0bf3275b907eedf54b574adbc3e97 (patch) | |
| tree | 4722b1adef129016a2481a7898d2b48d03edc17a | |
| parent | 112f295cc96e6d35a51151d234a0c93982a66f48 (diff) | |
Add capability to evaluate code in <!--SVG...--> comments
| -rw-r--r-- | md.bqn | 18 | ||||
| -rw-r--r-- | svg.bqn | 2 |
2 files changed, 16 insertions, 4 deletions
@@ -171,12 +171,19 @@ tryURL ← siteURL∾"try.html#code=" repoURL ← "https://github.com/mlochbaum/BQN" blobURL ← repoURL∾"/blob/master/" +# Environments +_getCodeExec ← {𝕗⋄⍎} +_getSvgExec ← {𝕗⋄⟨•path∾"svg.bqn","⍎"⟩ •EX •path∾"dzref"} + ################################ Markdown ← {filename𝕊𝕩: extensions ← filename ≢ 0 path ← extensions◶""‿(⊢/˜·∨`⌾⌽'/'⊸=) filename + CodeExec ← @_getCodeExec + SvgExec ← @_getSvgExec + ###### # First we classify each line based on the type of block it can start. ClassifyLine ← (0<≠)◶(0‿0)‿{ @@ -237,7 +244,6 @@ Markdown ← {filename𝕊𝕩: mod ← ⟨em,e∾c∾r,ei∾ci∾ri⟩ Modify code 𝕩 Link⊸∾⍟addRslt "pre" Html "code" Html⍟(¬extensions) mod } - codeExec ← {⍎} # Headings start with #, and require 1-6 #s followed by a space. # Any trailing #s are ignored. @@ -311,11 +317,15 @@ Markdown ← {filename𝕊𝕩: # Lazy rule: if it starts with < and contains >, it's probably HTML IsHtmlBlock ← ("<!--"≡4↑⊢)◶('>'∨´∘=⊢)‿2 useRepl←0 ⋄ GetRepl ← {𝕩⋄ useRepl↩1 ⋄ repl} - ProcComment ← ("<!--REPL-->"∾lf)⊸≢◶GetRepl‿⊢ - ProcHtmlBlock ← <⟜2◶ProcComment‿{ + ProcComment ← ⟨"<!--REPL-->"⟩⊸≢◶⟨ + GetRepl + ("<!--SVG"≡⊑∘⊢)◶JoinLines‿(SvgExec∘JoinLines 1↓¯1↓⊢) + ⟩ + ProcHtml ← { codeMask ← "<code>" (6⥊0)⊸»⊸(>○(⌈`(1+↕∘≠)⊸×))○(⍷⟜𝕩 ∾ 0⥊˜1-˜≠) "</code>" (1¨ <⊸∾ codeMask⊸GetMultiHighlights)⊸Modify 𝕩 - }⍟extensions⟜JoinLines + }⟜JoinLines + ProcHtmlBlock ← extensions◶JoinLines‿(<⟜2◶ProcComment‿ProcHtml) lineChars‿lineClas‿procFns ← <˘⍉>⟨ "" ‿ (!∘0) ‿ ProcParagraph diff --git a/svg.bqn b/svg.bqn new file mode 100644 index 00000000..728cc76e --- /dev/null +++ b/svg.bqn @@ -0,0 +1,2 @@ +# Utilities for creating SVG diagrams as strings +# (There aren't any yet; go to the next commit) |
