Skip to content

Commit

Permalink
Add support for HTML tables. Contains a breaking change. table rename…
Browse files Browse the repository at this point in the history
…d to datatable.
  • Loading branch information
breck7 committed Jan 23, 2025
1 parent 5b6e8c9 commit a22e8c1
Show file tree
Hide file tree
Showing 27 changed files with 181 additions and 118 deletions.
2 changes: 1 addition & 1 deletion blog/contacts.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ code
theme gazette
mediumColumns 1
printTitle
table
datatable
printTable
tableSearch

Expand Down
2 changes: 1 addition & 1 deletion blog/heatrix.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ aboveAsCode

## Use your own custom color palettes and set your own thresholds:
heatrixAdvanced
table
datatable

h10;w30 '2015 '2016 '2017 '2018 '2019 '2020 '2021 '2022 '2023 '2024
h30;w30; 0 0 5 1 2 11 15 10 12 56
Expand Down
2 changes: 1 addition & 1 deletion blog/plot.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ planets.csv

# Step 3: Add inline data
belowAsCode
table
datatable
scatterplot
title The Simpson Family
x age
Expand Down
2 changes: 1 addition & 1 deletion blog/scrollsets.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ScrollSets are normal plain text files written in Scroll that also contain measu
https://scroll.pub/ Scroll
match 1

ScrollSets are line oriented but represent a table(s). You might call them _deconstructed csvs_ or _deconstructed spreadsheets_.
ScrollSets are line oriented but represent a datatable(s). You might call them _deconstructed csvs_ or _deconstructed spreadsheets_.

- Use LLMs to *instantly generate ScrollSets* that are ready for human verification and improvement.
- Intermingle structured data with markup to *annotate any and every part of a ScrollSets* while still generating strict tabular files for data analysis tools.
Expand Down
10 changes: 5 additions & 5 deletions blog/tables.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ authors Breck Yunits
https://twitter.com/breckyunits Breck Yunits
date 8/09/2024
tags All
title Tables: a microlang for data science
title Datatables: a microlang for data science

header.scroll
keyboardNav
Expand All @@ -11,7 +11,7 @@ printAuthors

mediumColumns 1

Tables, aka spreadsheets, are arguably the most important _visual_ thought tool.
Datatables, aka spreadsheets, are arguably the most important _visual_ thought tool.
dateline

But no one has designed the perfect _textual_ language for manipulating them.
Expand All @@ -20,20 +20,20 @@ Until now.

endSnippet

# Say hello to Tables
# Say hello to Datatables

youtube https://www.youtube.com/watch?v=lO8blNtYYBA

br
center
scrollButton Try now
https://try.scroll.pub/#scroll%0A%20theme%20gazette%0A%20%0A%20expander%20Presidents%0A%20https%3A%2F%2Fohayo.breckyunits.com%2Fohayo%2Fpackages%2Fsamples%2Fpresidents.csv%0A%20%20groupBy%20Party%0A%20%20%20orderBy%20-count%0A%20%20%20%20printTable%0A%20%20scatterplot%0A%20%20%20x%20number%0A%20%20%20y%20Party%0A%20%20%20fill%20Party%0A%20%0A%20expander%20Elements%0A%20https%3A%2F%2Fohayo.breckyunits.com%2Fohayo%2Fpackages%2Fsamples%2Fperiodic-table.csv%0A%20%20scatterplot%0A%20%20%20x%20Year%0A%20%20%20y%20AtomicNumber%0A%20%20%20fill%20Radioactive%0A%20%20%20symbol%20Metal%0A%20%0A%20%2F%2F%20expander%20Inline%20Data%0A%20table%0A%20%20scatterplot%0A%20%20%20title%20Top%2050%20programming%20language%20projects%20on%20GitHub.%0A%20%20%20x%20appeared%0A%20%20%20y%20rank%0A%20%20%20radius%20githubStars%0A%20%20%20label%20name%0A%20%20orderBy%20appeared%0A%20%20%20sparkline%0A%20%20%20%20y%20githubStars%0A%20%20%20%20color%20green%0A%20%20%20select%20name%20githubStars%0A%20%20%20%20heatrix%0A%20%20data%0A%20%20%20rank%2Cname%2Cappeared%2CgithubStars%0A%20%20%203%2CPython%2C1991%2C61378%0A%20%20%204%2CJava%2C1995%2C19037%0A%20%20%208%2CPerl%2C1987%2C1886%0A%20%20%209%2CRuby%2C1995%2C21790%0A%20%20%2010%2CPHP%2C1995%2C37688%0A%20%20%2013%2CGo%2C2009%2C121611%0A%20%20%2014%2CTypeScript%2C2012%2C99410%0A%20%20%2018%2CPowerShell%2C2006%2C44220%0A%20%20%2020%2CRust%2C2010%2C95455%0A%20%20%2021%2CSwift%2C2014%2C67064%0A%20%20%2025%2CKotlin%2C2011%2C48462%0A%20%20%2027%2CClojure%2C2007%2C10392%0A%20%20%2028%2CCoffeeScript%2C2009%2C16466%0A%20%20%2029%2CElixir%2C2011%2C24093%0A%20%20%2030%2CErlang%2C1986%2C11203%0A%20%20%2034%2CJulia%2C2012%2C45137%0A%20%20%2041%2CRacket%2C1994%2C4741%0A%20%20%2042%2CSolidity%2C2014%2C22794%0A%20%20%2043%2CWebAssembly%2C2015%2C6621%0A%20%20%2045%2CZig%2C2015%2C32864%0A%20%20%2047%2CNim%2C2008%2C16308%0A%20%20%2050%2CTOML%2C2013%2C19332
https://try.scroll.pub/#scroll%0A%20theme%20gazette%0A%20%0A%20expander%20Presidents%0A%20https%3A%2F%2Fohayo.breckyunits.com%2Fohayo%2Fpackages%2Fsamples%2Fpresidents.csv%0A%20%20groupBy%20Party%0A%20%20%20orderBy%20-count%0A%20%20%20%20printTable%0A%20%20scatterplot%0A%20%20%20x%20number%0A%20%20%20y%20Party%0A%20%20%20fill%20Party%0A%20%0A%20expander%20Elements%0A%20https%3A%2F%2Fohayo.breckyunits.com%2Fohayo%2Fpackages%2Fsamples%2Fperiodic-table.csv%0A%20%20scatterplot%0A%20%20%20x%20Year%0A%20%20%20y%20AtomicNumber%0A%20%20%20fill%20Radioactive%0A%20%20%20symbol%20Metal%0A%20%0A%20%2F%2F%20expander%20Inline%20Data%0A%20datatable%0A%20%20scatterplot%0A%20%20%20title%20Top%2050%20programming%20language%20projects%20on%20GitHub.%0A%20%20%20x%20appeared%0A%20%20%20y%20rank%0A%20%20%20radius%20githubStars%0A%20%20%20label%20name%0A%20%20orderBy%20appeared%0A%20%20%20sparkline%0A%20%20%20%20y%20githubStars%0A%20%20%20%20color%20green%0A%20%20%20select%20name%20githubStars%0A%20%20%20%20heatrix%0A%20%20data%0A%20%20%20rank%2Cname%2Cappeared%2CgithubStars%0A%20%20%203%2CPython%2C1991%2C61378%0A%20%20%204%2CJava%2C1995%2C19037%0A%20%20%208%2CPerl%2C1987%2C1886%0A%20%20%209%2CRuby%2C1995%2C21790%0A%20%20%2010%2CPHP%2C1995%2C37688%0A%20%20%2013%2CGo%2C2009%2C121611%0A%20%20%2014%2CTypeScript%2C2012%2C99410%0A%20%20%2018%2CPowerShell%2C2006%2C44220%0A%20%20%2020%2CRust%2C2010%2C95455%0A%20%20%2021%2CSwift%2C2014%2C67064%0A%20%20%2025%2CKotlin%2C2011%2C48462%0A%20%20%2027%2CClojure%2C2007%2C10392%0A%20%20%2028%2CCoffeeScript%2C2009%2C16466%0A%20%20%2029%2CElixir%2C2011%2C24093%0A%20%20%2030%2CErlang%2C1986%2C11203%0A%20%20%2034%2CJulia%2C2012%2C45137%0A%20%20%2041%2CRacket%2C1994%2C4741%0A%20%20%2042%2CSolidity%2C2014%2C22794%0A%20%20%2043%2CWebAssembly%2C2015%2C6621%0A%20%20%2045%2CZig%2C2015%2C32864%0A%20%20%2047%2CNim%2C2008%2C16308%0A%20%20%2050%2CTOML%2C2013%2C19332

****

# Acknowledgements

Tables evolved over the past decade primarily by:
Datatables evolved over the past decade primarily by:

- just doing what Hadley Wickham did in dplyr
https://dplyr.tidyverse.org/ dplyr
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": "168.8.0",
"version": "169.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
2 changes: 1 addition & 1 deletion parserLeetsheet.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ br
thinColumns 1
expander Parser usage rankings
A rough _estimate_ of parser usage in Parsers.
table
datatable
printTable
data
count id
Expand Down
2 changes: 1 addition & 1 deletion parsers/concepts.parsers
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scrollConceptsParser
description Load concepts as table.
description Load concepts as datatable.
extends abstractDatatableProviderParser
cue concepts
atoms cueAtom
Expand Down
2 changes: 1 addition & 1 deletion parsers/disk.parsers
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
scrollDiskParser
extends scrollTableParser
description Output file into as table.
description Output file into as datatable.
cue disk
javascript
delimiter = "json"
Expand Down
6 changes: 3 additions & 3 deletions parsers/heatrix.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ heatrixParser
buildHtml() {
// A hacky but simple way to do this for now.
const advanced = new Particle("heatrixAdvanced")
advanced.appendLineAndSubparticles("table", "\n " + this.tableData.replace(/\n/g, "\n "))
advanced.appendLineAndSubparticles("datatable", "\n " + this.tableData.replace(/\n/g, "\n "))
const particle = this.appendSibling("heatrixAdvanced", advanced.subparticlesToString())
const html = particle.buildHtml()
particle.destroy()
Expand Down Expand Up @@ -51,7 +51,7 @@ heatrixAdvancedParser
description Advanced heatrix.
example
heatrix
table
datatable

%h10; '2007 '2008 '2009
12 4 323
Expand Down Expand Up @@ -94,7 +94,7 @@ heatrixAdvancedParser
numbers.unshift(0)
return generateColorBinningString(numbers, colors);
}
const table = particle.getParticle("table").subparticlesToString()
const table = particle.getParticle("datatable").subparticlesToString()
const scale = particle.getParticle("scale")?.subparticlesToString() || buildScale(table)
const thresholds = []
const colors = []
Expand Down
49 changes: 48 additions & 1 deletion parsers/html.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,51 @@ htmlBlockquoteParser
cue blockquote
example
blockquote
p A wise quote
p A wise quote

htmlTableParser
extends abstractHtmlElementParser
cue table
example
table
tr
th Header 1
th Header 2
tr
td Cell 1
td Cell 2

htmlTrParser
extends abstractHtmlElementParser
cue tr
example
tr
td Cell 1

htmlTdParser
extends abstractHtmlElementParser
cue td
example
td Cell content

htmlThParser
extends abstractHtmlElementParser
cue th
example
th Header content

htmlTheadParser
extends abstractHtmlElementParser
cue thead
example
thead
tr
th Header 1

htmlTbodyParser
extends abstractHtmlElementParser
cue tbody
example
tbody
tr
td Cell 1
2 changes: 1 addition & 1 deletion parsers/leetsheet.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ printUsageStatsParser
}
buildHtml() {
// A hacky but simple way to do this for now.
const particle = this.appendSibling("table")
const particle = this.appendSibling("datatable")
particle.appendLine("delimiter ")
particle.appendLine("printTable")
const dataParticle = particle.appendLine("data")
Expand Down
8 changes: 4 additions & 4 deletions parsers/posts.parsers
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
abstractPostsParser
description Load posts as table.
description Load posts as datatable.
extends abstractDatatableProviderParser
cueFromId
atoms cueAtom
Expand Down Expand Up @@ -41,10 +41,10 @@ abstractPostsParser
scrollPostsParser
popularity 0.000024
cue posts
description Posts as table.
description Posts as datatable.
extends abstractPostsParser
example
// Print a search table:
// Print a search datatable:
posts
printTable
tableSearch
Expand All @@ -56,7 +56,7 @@ scrollPostsParser
scrollPostsMetaParser
popularity 0.000024
cue postsMeta
description Post meta as table.
description Post meta as datatable.
extends abstractPostsParser
javascript
columnNames = ["date", "year", "title", "permalink", "authors", "tags", "wordCount", "minutes"]
Expand Down
2 changes: 1 addition & 1 deletion parsers/root.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ scrollParser
}
get scrollVersion() {
// currently manually updated
return "168.8.0"
return "169.0.0"
}
// Use the first paragraph for the description
// todo: add a particle method version of get that gets you the first particle. (actulaly make get return array?)
Expand Down
18 changes: 9 additions & 9 deletions parsers/tables.parsers
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ printColumnParser
printTableParser
popularity 0.001085
cueFromId
description Print table.
description Print datatable.
extends abstractTableVisualizationParser
javascript
get tableHeader() {
Expand Down Expand Up @@ -244,9 +244,9 @@ abstractDatatableProviderParser
scrollTableParser
extends abstractDatatableProviderParser
popularity 0.002133
cue table
cue datatable
example
table
datatable
printTable
data
year,count
Expand Down Expand Up @@ -357,7 +357,7 @@ scrollWhereParser
atoms cueAtom columnNameAtom comparisonAtom
catchAllAtomType constantAtom
example
table iris.csv
datatable iris.csv
where Species = setosa
javascript
get coreTable() {
Expand Down Expand Up @@ -433,7 +433,7 @@ scrollComposeParser
cue compose
atoms cueAtom newColumnNameAtom
example
table
datatable
compose sentence My name is {name}
printTable
javascript
Expand Down Expand Up @@ -532,12 +532,12 @@ scrollShuffleParser
description Randomly reorder rows.
cue shuffle
example
table data.csv
datatable data.csv
shuffle
printTable
javascript
get coreTable() {
// Create a copy of the table to avoid modifying original
// Create a copy of the datatable to avoid modifying original
const rows = this.parent.coreTable.slice()
// Fisher-Yates shuffle algorithm
for (let i = rows.length - 1; i > 0; i--) {
Expand All @@ -549,7 +549,7 @@ scrollShuffleParser

scrollTransposeParser
extends abstractTableTransformParser
description Tranpose table.
description Tranpose datatable.
cue transpose
javascript
get coreTable() {
Expand Down Expand Up @@ -689,7 +689,7 @@ scrollSummarizeParser
description Generate summary statistics for each column.
cue summarize
example
table data.csv
datatable data.csv
summarize
printTable
javascript
Expand Down
Loading

0 comments on commit a22e8c1

Please sign in to comment.