aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-07-16 17:27:44 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-07-16 17:27:44 -0400
commit08be7d1b030ddae97bcf3c05e9d4aed81ae685d5 (patch)
tree46eb6deb76e1c8e2c79e2bf720a0aa743845bcae
parentd8b307c7eb1c7d17a4581012f9d0551440d87be9 (diff)
Start improving ProcInline code handling
-rw-r--r--doc/md.bqn36
1 files changed, 25 insertions, 11 deletions
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≠⊸⥊¨⟨"<code>"‿"</code>","<em>"‿"</em>"⟩
- ((/inc)∾(≠¨tags∾code)/(∾d)∾/cs) ⍋⊸⊏ (inc/𝕩)∾∾tags∾code
- }⍟doHighlight
-
lineChars‿lineClas‿procFns ← <˘⍉>⟨
"" ‿ (!∘0) ‿ ProcParagraph
"#" ‿ LenHeading ‿ ProcHeading
@@ -141,6 +130,31 @@ Markdown ← {
######
+ # 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
blanks ← (Lead ' '⊸=)¨ 𝕩 # Number of leading blanks