From 8846e63a6f1fe51ee9a68dc511cc6fcdbf54efa6 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 3 Oct 2020 16:32:29 -0400 Subject: Verify html link line at the top of markdown files when converting --- md.bqn | 53 ++++++++++++++++++++++++++++++++++------------------- spec/inferred.md | 2 ++ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/md.bqn b/md.bqn index a5fe9021..cae918ab 100644 --- a/md.bqn +++ b/md.bqn @@ -153,6 +153,24 @@ Base64 ← { (v⊏b64)∾(3|-l)⥊'=' } +# HTML and JS for demo REPL used in main README +repl ← 1↓" +
+
+
+ + +
+
""B Q N""
+
" +loadRepl ← "" + +# Various URLs +siteURL ← "https://mlochbaum.github.io/BQN/" +tryURL ← siteURL∾"try.html#code=" +repoURL ← "https://github.com/mlochbaum/BQN" +blobURL ← repoURL∾"/blob/master/" + ################################ Markdown ← {filename𝕊𝕩: @@ -213,8 +231,7 @@ Markdown ← {filename𝕊𝕩: } 𝕩 Link ← { - try←"https://mlochbaum.github.io/BQN/try.html#code=" - c ← try ∾ "&run" ∾˜ Base64 ¯1 ↓ JoinLines 4↓¨𝕩 + c ← tryURL ∾ "&run" ∾˜ Base64 ¯1 ↓ JoinLines 4↓¨𝕩 ("a class=""replLink"" title=""Open in the REPL"" target=""_blank"" href="∾""""(∾∾⊣)c) Html "↗️" } mod ← ⟨em,e∾c∾r,ei∾ci∾ri⟩ Modify code @@ -294,17 +311,8 @@ Markdown ← {filename𝕊𝕩: # Lazy rule: if it starts with < and contains >, it's probably HTML IsHtmlBlock ← ⊑ ">"⊸∊ useRepl ← 0 - loadRepl ← "" ProcHtmlBlock ← (""∾lf)⊸≢◶{𝕩⋄ - useRepl ↩ 1 -"
-
-
- - -
-
""B Q N""
-
" + useRepl ↩ 1 ⋄ repl }‿{ codeMask ← "" (6⥊0)⊸»⊸(>○(⌈`(1+↕∘≠)⊸×))○(⍷⟜𝕩 ∾ 0⥊˜1-˜≠) "" (1¨ <⊸∾ codeMask⊸GetMultiHighlights)⊸Modify 𝕩 @@ -362,7 +370,7 @@ Markdown ← {filename𝕊𝕩: ProcLink ← {text 𝕊 target: ∾⟨"",ProcInline text,""⟩ } - ghPath ← "https://github.com/mlochbaum/BQN/blob/master/"∾path + ghPath ← blobURL∾path AdjustTarget ← { # Adjust relative *.md links, and make other relative links # absolute (pointing to github.com instead of github.io). @@ -430,9 +438,6 @@ Markdown ← {filename𝕊𝕩: ###### # Create the block structure using line classifications. - # First remove the html link line: the output *is* the html file. - 𝕩 ↩ 2⊸↓⍟("*View this file" (⊣ ≡ ⌊○≠↑⊢) ⊑) 𝕩 - lengths ← ≠¨ 𝕩 # Length of each line blanks ← (Lead ' '⊸=)¨ 𝕩 # Number of leading blanks nonEmptyMask ← blanks < lengths # Empty ←→ all leading blanks @@ -609,8 +614,18 @@ Fmt ← ⍕ _fmtm ################################ # Creating HTML files ConvertFile ← { + MatchStart‿MatchEnd ← { ≤○≠◶0‿(⊣ ≡ (𝕩×≠)⊸↑) }¨ 1‿¯1 + + # Input file 𝕩 should be markdown; output file is fileout + ! ".md" MatchEnd 𝕩 + fileout ← ".html" ∾˜ (¯6⊸↓∾"index"˙)⍟("README"⊸MatchEnd) ¯3↓𝕩 + + # Contents of file to convert md ← •LNS •path∾𝕩 - out ← 𝕩 Markdown md + # Verify and remove the html link line: the output *is* the html file. + ! ("*View this file"⊸MatchStart ∧ (siteURL∾fileout∾").*")⊸MatchEnd) ⊑md + out ← 𝕩 Markdown 2↓md + parts ← (1-˜·(¬×1++`)'/'⊸=)⊸⊔ (⊑⊐⟜".")⊸↑ 𝕩 root ← ⊑ up ← ⥊∘/⟜≍⟜"../"¨ ⌽↕≠parts isInd ← "README" ≡ ¯1⊑parts @@ -621,9 +636,9 @@ ConvertFile ← { "stylesheet" Link "style.css" "title" Html "BQN: " ∾⍟(¬·∨´"BQN"⍷⊢) 2↓⊑(2≤≠)◶0‿("# "≡2⊸↑)¨⊸/md ⟩ - gh ← "a href='https://github.com/mlochbaum/BQN'"Html"BQN" + repo ← "a href='"‿repoURL‿"'" ∾⊸Html "BQN" crumbs ← up ("a href='"∾∾⟜"index.html'")⊸Html¨○((-isInd)⊸↓) (<"main")»parts - nav ← RQ "div class='nav'" Html 3↓∾ " / "⊸∾¨ gh <⊸∾ crumbs + nav ← RQ "div class='nav'" Html 3↓∾ " / "⊸∾¨ repo <⊸∾ crumbs front ← head ∾○(∾⟜lf) nav front ∾ out } diff --git a/spec/inferred.md b/spec/inferred.md index 43e6221e..f61d6fce 100644 --- a/spec/inferred.md +++ b/spec/inferred.md @@ -1,3 +1,5 @@ +*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/spec/inferred.html).* + # Specification: BQN inferred properties BQN includes some simple deductive capabilities: detecting the type of empty array elements, and the Undo (`⁼`) and Under (`⌾`) modifiers. These tasks are a kind of proof-based or constraint programming, and can never be solved completely (some instances will be undecidable) but can be solved in more instances by ever-more sophisticated algorithms. To allow implementers to develop more advanced implementations while offering some stability and portability to programmers, two kinds of specification are given here. First, constraints are given on the behavior of inferred properties. These are not exact and require some judgment on the part of the implementer. Second, behavior for common or useful cases is specified more precisely. Non-normative suggestions are also given as a reference for implementers. -- cgit v1.2.3