-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/main'
- Loading branch information
Showing
13 changed files
with
133 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// usage: | ||
// cat README.md | deno run --allow-env --allow-read --allow-run bin/render-streaming-markdown.ts | ||
// | ||
|
||
import $ from 'jsr:@david/[email protected]' | ||
// todo: replace dax with this: | ||
// import { exec } from 'https://deno.land/std/process.mod.ts'; | ||
import { writeAllSync } from 'https://deno.land/[email protected]/streams/mod.ts'; | ||
|
||
let inputBuffer = "" | ||
|
||
const decoder = new TextDecoder() | ||
const encoder = new TextEncoder() | ||
|
||
// This style works well for prompt.. but not chat | ||
for await (const chunk of Deno.stdin.readable) { | ||
// show immediately, but meanwhile… | ||
writeAllSync(Deno.stdout, chunk); | ||
// Collect it. | ||
inputBuffer += decoder.decode(chunk); | ||
} | ||
|
||
// and now re-render it. | ||
if (inputBuffer) { | ||
console.log('⬇️… and now rendered…⬇️'); | ||
const output = await $`glow --style auto`.stdinText(inputBuffer).text() | ||
writeAllSync(Deno.stdout, encoder.encode(output)); | ||
} | ||
|
||
|
||
// This is a newline-buffered variant to avoid getting extra newlines in the output because we send it to glow too eagerly | ||
// it works but... the next problem is backtick codeblocks are broken up and... i'm sure there's more. | ||
// definitely need a better solution | ||
|
||
// let remainingContent = ''; | ||
// for await (const chunk of Deno.stdin.readable) { | ||
// const decoded = remainingContent + decoder.decode(chunk); | ||
|
||
// const lastNewline = decoded.lastIndexOf("\n"); | ||
// if (lastNewline !== -1) { | ||
// // Flush everything up to it | ||
// const output = await $`glow --style auto`.stdinText(decoded.substring(0, lastNewline + 1)).text() | ||
// writeAllSync(Deno.stdout, encoder.encode(output)); | ||
|
||
// // Hold onto the remaining content to flush with the next chunk | ||
// remainingContent = decoded.substring(lastNewline + 1); | ||
// } | ||
// } | ||
|
||
// // Flush any remaining content | ||
// if (remainingContent) { | ||
// const output = await $`glow --style auto`.stdinText(remainingContent).text() | ||
// writeAllSync(Deno.stdout, encoder.encode(output)); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/bin/bash | ||
|
||
# Install command-line tools using Homebrew | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# shellcheck disable=2148 | ||
|
||
# basic | ||
convert image-filename.png -resize 300% image-filename.3x-basic.png | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters