Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
breck7 committed Aug 1, 2024
1 parent 782c144 commit e1ec779
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scroll-cli",
"version": "112.1.2",
"version": "113.0.0",
"description": "A language for scientists of all ages. A curated collection of tools for refining and sharing thoughts.",
"main": "scroll.js",
"engines": {
Expand Down
25 changes: 23 additions & 2 deletions parsers/inlineMarkups.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ inlineMarkupNameCell
description Options to turn on some inline markups.
enum bold italics code katex none

inlineMarkupsParser
description Set global inline markups.
extends abstractTopLevelSingleMetaParser
cruxFromId
example
inlineMarkups
*
// Disable * for bold
_ u
// Make _ underline

inlineMarkupsOnParser
cruxFromId
description Enable these inline markups only.
Expand All @@ -15,12 +26,22 @@ inlineMarkupsOnParser
return true
}
get markups() {
const markups = [{delimiter: "`", tag: "code", exclusive: true, name: "code"},{delimiter: "*", tag: "strong", name: "bold"}, {delimiter: "_", tag: "em", name: "italics"}]
const {root} = this
let markups = [{delimiter: "`", tag: "code", exclusive: true, name: "code"},{delimiter: "*", tag: "strong", name: "bold"}, {delimiter: "_", tag: "em", name: "italics"}]
// only add katex markup if the root doc has katex.
if (this.root.has("katex"))
if (root.has("katex"))
markups.unshift({delimiter: "$", tag: "span", attributes: ' class="scrollKatex"', exclusive: true, name: "katex"})
if (this.content)
return markups.filter(markup => this.content.includes(markup.name))
if (root.has("inlineMarkups")) {
root.getNode("inlineMarkups").forEach(markup => {
const delimiter = markup.getWord(0)
const tag = markup.getWord(1)
markups = markups.filter(mu => mu.delimiter !== delimiter) // Remove any overridden markups
if (tag)
markups.push({delimiter, tag})
})
}
return markups
}
matchWholeLine = true
Expand Down
10 changes: 8 additions & 2 deletions parsers/source.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ printSourceStackParser
get sources() {
const {file} = this.root
const passNames = ["codeAtStart", "codeAfterImportPass", "codeAfterMacroPass"]
return passNames.map(name => { return {
let lastCode = ""
return passNames.map(name => {
let code = file[name]
if (lastCode === code)
code = "[Unchanged]"
lastCode = file[name]
return {
name,
code: file[name]
code
}})
}
compile() {
Expand Down
4 changes: 4 additions & 0 deletions releaseNotes.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import microlangs/changes.parsers
thinColumns

📦 113.0.0 8/1/2024
🎉 added `inlineMarkups` parser. Thanks to eugenesvk for the idea.
https://github.com/eugenesvk eugenesvk
https://github.com/breck7/scroll/issues/122 idea
🎉 `printSourceStack` now prints [Unchanged] if the source was not changed during a compiler step.
⚠️ BREAKING: `wrapsOn` is now `inlineMarkupsOn`
⚠️ BREAKING: `wrap` is now `inlineMarkup`

Expand Down
19 changes: 19 additions & 0 deletions tests/kitchenSink/customMarkups.scroll
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
buildHtml

thinColumns 1

gazetteCss

# Custom Inline Markups Test

belowAsCode 3
inlineMarkups
*
// disable bold
_ u
// override underline
~~~ marquee
// Add marquee!

*This* should not be bold. ~~~This should be a marquee.~~~ And _this_ should be underlined.

0 comments on commit e1ec779

Please sign in to comment.