Skip to content

Commit

Permalink
Markdown improvement (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan authored Jun 15, 2024
1 parent 3a70f7a commit 7ba0043
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ GenAIScript exposes the context through the `env` variable. The context is impli
- you can right click on or in a file and the `env.files` will contain only that file.
- you can run the script using the [command line interface](/genaiscript/reference/cli) and specify content of `env.files` in the CLI arguments.

```js title="proofreader.genai.js" system=false assistant=false
```js title="proofreader.genai.js" system=false assistant=false user=true
def("FILES", env.files)
```

{/* genaiscript output start */}

<details>
<details open>
<summary>👤 user</summary>


Expand Down
1 change: 1 addition & 0 deletions packages/core/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export async function githubUpdatePullRequestDescription(
const token = await host.readSecret(GITHUB_TOKEN)
if (!token) return { updated: false, statusText: "missing github token" }

text = prettifyMarkdown(text)
text += generatedByFooter(script, info)

const fetch = await createFetch({ retryOn: [] })
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import { trimNewlines } from "./util"
export function prettifyMarkdown(md: string) {
let res = md
res = convertAnnotationsToMarkdown(res)
res = cleanMarkdown(res)
return res
}

export function cleanMarkdown(res: string): string {
return res?.replace(/(\r?\n){3,}/g, "\n\n")
}

export function fenceMD(t: string, contentType?: string) {
if (t === undefined) return undefined
if (!contentType) contentType = "markdown"
Expand Down

0 comments on commit 7ba0043

Please sign in to comment.