-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update HTML parsing APIs and script references, introduce docify scri…
…pt, and remove unnecessary cache flags
- Loading branch information
Showing
7 changed files
with
102 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: HTML | ||
description: Learn how to use HTML parsing functions in GenAIScript for effective content manipulation and data extraction. | ||
keywords: HTML parsing, content manipulation, data extraction, HTML to text, HTML to markdown | ||
sidebar: | ||
order: 18 | ||
--- | ||
|
||
# HTML in GenAIScript | ||
|
||
HTML processing in GenAIScript enables you to manipulate and extract data from HTML content effectively. Below you can find guidelines on using the HTML-related APIs available in GenAIScript. | ||
|
||
## Overview | ||
|
||
HTML processing functions allow you to convert HTML content to text or markdown, helping in content extraction and manipulation for various automation tasks. | ||
|
||
## API Reference | ||
|
||
### `HTMLToText` | ||
|
||
Converts HTML content into plain text. This is useful for extracting readable text from web pages. | ||
|
||
#### Example | ||
|
||
```js | ||
const htmlContent = "<p>Hello, world!</p>"; | ||
const text = HTML.HTMLToText(htmlContent); | ||
// Output will be: "Hello, world!" | ||
``` | ||
|
||
### `HTMLToMarkdown` | ||
|
||
Converts HTML into Markdown format. This function is handy for content migration projects or when integrating web content into markdown-based systems. | ||
|
||
#### Example | ||
|
||
```js | ||
const htmlContent = "<p>Hello, <strong>world</strong>!</p>"; | ||
const markdown = HTML.HTMLToMarkdown(htmlContent); | ||
// Output will be: "Hello, **world**!" | ||
``` | ||
|
||
For more details on related APIs, refer to the [GenAIScript documentation](https://microsoft.github.io/genaiscript/). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
script({ | ||
model: "openai:gpt-4-turbo", | ||
tools: ["fs", "md"], | ||
}) | ||
|
||
const api = env.vars.api + "" | ||
|
||
$`You are an expert technical writer for the GenAIScript language. | ||
## Task | ||
Generate a documentation page about the ${api}. | ||
Save to file in the docs/src/content/docs/reference/scripts folder. | ||
## Information | ||
- use markdown, with Astro Starlight syntax | ||
- the genaiscript type definition: genaisrc/genaiscript.d.ts. Assume that all globals are ambient. Do not import or require genaiscript module. | ||
- the documentation is in markdown and has frontmatter: docs/src/content/docs/**/*.md* | ||
- the online documentation: https://microsoft.github.io/genaiscript/ | ||
- the genaiscript samples: packages/sample/src/*.genai.* | ||
- document each api separately with a short example | ||
- use "js" language for genai code blocks | ||
- link to online documentation for related apis | ||
- use const keyword for all variables if possible | ||
- do not add console.log to snippets | ||
- minimize changes to existing documentation | ||
` | ||
|
||
defFileOutput("docs/src/content/docs/reference/scripts/*.md", "Documentation pages") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
script({ | ||
model: "openai:gpt-3.5-turbo", | ||
title: "HTML to Text", | ||
tests: {}, | ||
}) | ||
|
||
const { text: html } = await fetchText( | ||
"https://microsoft.github.io/genaiscript/getting-started/" | ||
) | ||
const text = HTML.convertToText(html) | ||
def("TEXT", text) | ||
|
||
const md = HTML.convertToMarkdown(html) | ||
const v = def("MARKDOWN", md) | ||
|
||
const tables = HTML.convertTablesToJSON(html) | ||
defData("TABLES", tables) | ||
|
||
$`Compare TEXT and MARKDOWN. | ||
Analyze the TABLES data.` |