Skip to content

Commit

Permalink
Add HAML parser
Browse files Browse the repository at this point in the history
  • Loading branch information
breck7 committed Sep 26, 2024
1 parent 2b97934 commit b396e53
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 11 deletions.
6 changes: 2 additions & 4 deletions animation.scroll
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
br 1


<div class="animation">
div.animation
With Scroll your
Lines become particles
class atomToDot Lines
Expand All @@ -14,8 +13,7 @@ Joined with parsers
class atomToDot2 parsers
class animationLine
To lead the world
</div>

<link rel="stylesheet" href="animation.css" type="text/css"/>
animation.css

br 2
7 changes: 3 additions & 4 deletions blog/csvToScrollSet.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ endColumns
***

mediumColumns 1
<script src="scrollSetMaker.js"></script>
scrollSetMaker.js

# Your Data:
<textarea style="width: 100%" id="content" rows="15" oninput="updateScrollSet()"></textarea><br>
<label for="delimiter">Delimiter:</label>
<input id="delimiter" value="," style="width: 30px;"/>

# ScrollSet:
<pre id="scrollset"></pre>
pre#scrollset

<script>
script
function updateScrollSet() {
const delimiter = document.getElementById('delimiter').value;
const content = document.getElementById('content').value;
Expand All @@ -48,7 +48,6 @@ mediumColumns 1
document.getElementById('content').value = "id,year\nHawaii,1959"
updateScrollSet()
document.getElementById('delimiter').addEventListener('input', updateScrollSet);
</script>

# Related
printRelated ScrollSets
Expand Down
2 changes: 0 additions & 2 deletions faq.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ Scroll powers PLDB, a knowledge base with over 100 contributors who have added o
This site you are reading is powered by Scroll.
link index.html This site

<div style="clear:both;"></div>

? What makes Scroll different?
Scroll has an unusually simple syntax called Particles, an extensive set of parsers and commands needed by researchers, bloggers, knowledge bases and sites of all sizes, is highly expandable, and is familiar to anyone who knows Markdown.

Expand Down
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": "133.6.0",
"version": "134.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
26 changes: 26 additions & 0 deletions parsers/haml.parsers
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
hamlParser
popularity 0.007524
description HTML tag via HAML syntax.
extends abstractScrollParser
atoms urlAtom
catchAllAtomType stringAtom
pattern ^[\w-]+(#|\.)[\w-\.\#]+ *
javascript
get tag() {
return this.atoms[0].split(/[#\.]/).shift()
}
get htmlId() {
const idMatch = this.atoms[0].match(/#([\w-]+)/)
return idMatch ? idMatch[1] : ""
}
get htmlClasses() {
return this.atoms[0].match(/\.([\w-]+)/g)?.map(cls => cls.slice(1)) || [];
}
compile() {
const {htmlId, htmlClasses, content, tag} = this
this.parent.sectionStack.push(`</${tag}>`)
return `<${tag} ${htmlId ? ' id="' + htmlId + '"' : ""} ${htmlClasses ? ' class="' + htmlClasses.join(" ") + '"' : ""}>${content || ""}`
}
compileTxt() {
return this.content
}
1 change: 1 addition & 0 deletions parsers/tables.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ scrollReverseParser
scrollComposeParser
extends abstractTableTransformParser
description Add column using format string.
catchAllAtomType stringAtom
crux compose
javascript
get coreTable() {
Expand Down
4 changes: 4 additions & 0 deletions releaseNotes.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ ciBadges.scroll
br
thinColumns

📦 134.0.0 9/25/2024
🎉 added `haml` quick html tags
⚠️ BREAKING: (no one should be affected) if you have lines starting with a sequence like tag#id or tag.someClassName, they will now get matched to HAML parser.

📦 133.6.0 9/24/2024
🎉 added `links` parser to tables

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

css
#green {color: green;}
.red {color:red;}
.underline {text-decoration: underline;}

h1#green Green

h1.red Red

div.red.underline Red underline


div.underline#green Green underline

0 comments on commit b396e53

Please sign in to comment.