Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown: add thematic breaks and change test #95

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions md.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ Markdown ← {filename𝕊𝕩:
(1¨ <⊸∾ codeMask⊸GetMultiHighlights)⊸Modify 𝕩
}⟜JoinLines
ProcHtmlBlock ← extensions◶JoinLines‿(<⟜2◶ProcComment‿ProcHtml)

# Thematic Breaks
ProcBreak ← ∾("<hr />"∾lf)¨

dig ← '0'+↕10
[lineChars,lineClas,procFns] ← ⍉[
Expand All @@ -392,6 +395,7 @@ Markdown ← {filename𝕊𝕩:
"-+*" ‿ LenBullet ‿ ProcBullet
# dig ‿ LenListNum ‿ ProcListNum
"<" ‿ IsHtmlBlock ‿ ProcHtmlBlock
"" ‿ 0 ‿ ProcBreak
]

######
Expand Down Expand Up @@ -541,6 +545,10 @@ Markdown ← {filename𝕊𝕩:
# part of a code block, it will be included in a paragraph.
lineType -↩ codeMask ∧ 1 = lineType

# Lines that are thematic breaks
breakMask ← nonEmptyMask ∧ (blanks ≤ 3) ∧ {(3≤+´⊏0∾˜˘⌾⍉bw/nw)∧∨´bw←∧´˘(𝕩∊" ")⊸∨˘nw←"*-_"=⌜𝕩}¨𝕩
lineType 6¨⌾(breakMask⊸/)↩

# Tables are made up of rows that would otherwise be paragraph rows.
# They are indicated by the delimiter row, consisting of only a few
# allowed characters, preceded (!) by a header row with the same
Expand Down
2 changes: 1 addition & 1 deletion test/markdown.bqn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ UnEscape ← {
}
RunTest ← {
in‿exp ← UnEscape∘(1↓¯1↓⊢)¨2↑𝕩
out ← 0 Markdown (@+10) ((⊢-˜¬×+`)∘=⊔⊢) in
out ← 0 Markdown⎊("Runtime Error:"∾•Fmt∘⊢) (@+10) ((⊢-˜¬×+`)∘=⊔⊢) in
⟨exp≡out,in,exp,out,2⊑𝕩⟩
}

Expand Down