Skip to content

Commit

Permalink
Added plainText and printSource keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
Breck Yunits authored and Breck Yunits committed Apr 5, 2024
1 parent 57e67e8 commit c1aa539
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ scrollNodePerf.cpuprofile
tests/importExamples/
tests/kitchenSink/style.css
tests/kitchenSink/posts.csv
tests/kitchenSink/prompt.txt

# Do not check in files built by Scroll
*.html
Expand Down
13 changes: 13 additions & 0 deletions grammar/plainText.grammar
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plainTextParser
description Use for plain text one liners and/or blocks of plain text.
cruxFromId
extends abstractScrollParser
catchAllParser plainTextLineParser
catchAllCellType stringCell
javascript
compile() {
return `${this.content ?? ""}${this.childrenToString()}`
}
plainTextLineParser
catchAllCellType stringCell
catchAllParser plainTextLineParser
12 changes: 12 additions & 0 deletions grammar/source.grammar
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
printSourceParser
description Prints out the source code for each file in a group.
extends printFeedParser
example
printSource index
permalink source.txt
javascript
compile() {
const file = this.root.file
const files = file.getFilesInGroupsForEmbedding(this.getWordsFrom(1)).map(file => file.file)
return `${files.map(file => file.filePath + "\n " + file.originalScrollCode.replace(/\n/g, "\n ") ).join("\n")}`
}
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": "73.0.0",
"version": "73.1.0",
"description": "Tools for thoughts.",
"main": "scroll.js",
"engines": {
Expand Down
4 changes: 4 additions & 0 deletions releaseNotes.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ title Scroll Release Notes

startColumns

# 73.1.0 4/05/2024
- 🎉 added `plainText` keyword
- 🎉 added `printSource` keyword to be able to dump the source code for a group of posts to a plain text file.

# 73.0.0 4/03/2024
- 🎉 added `printCsv` keyword to make it as easy to generate a CSV of a blog as it is to generate an RSS feed

Expand Down
2 changes: 1 addition & 1 deletion scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class ScrollFile {
const content = this.scrollProgram.compile().trim()
// Don't add html tags to XML/RSS/CSV feeds. A little hacky as calling a getter named _html_ to get _xml_ is not ideal. But
// <1% of use case so might be good enough.
const wrapWithHtmlTags = permalink.endsWith(".xml") || permalink.endsWith(".rss") || permalink.endsWith(".csv") ? false : true
const wrapWithHtmlTags = permalink.endsWith(".xml") || permalink.endsWith(".rss") || permalink.endsWith(".csv") || permalink.endsWith(".txt") ? false : true
this._compiledStandalonePage = wrapWithHtmlTags ? `<!DOCTYPE html><html lang="${this.lang}">` + content + "</html>" : content
}
return this._compiledStandalonePage
Expand Down
12 changes: 12 additions & 0 deletions tests/kitchenSink/source.scroll
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import settings.scroll
permalink prompt.txt
// Demonstrates a technique for building a big prompt to give to an LLM.

plainText
Instructions:
Below are the files in a blog. I want you to read them, and then perform the following tasks, and give me your results in the format of a git patch so I can easily apply your changes on my local computer and commit them.

Tasks:

The Files:
printSource index

0 comments on commit c1aa539

Please sign in to comment.