Skip to content

Commit

Permalink
update to use jsr and deno
Browse files Browse the repository at this point in the history
  • Loading branch information
mgambill committed Jan 3, 2025
1 parent 78cff2d commit 1bdf4f0
Show file tree
Hide file tree
Showing 35 changed files with 1,494 additions and 5,559 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish
on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- name: Publish package
run: npx jsr publish
12 changes: 0 additions & 12 deletions .gitignore

This file was deleted.

23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Launch Program",
"type": "node",
"program": "${workspaceFolder}/main.ts",
"cwd": "${workspaceFolder}",
"env": {},
"runtimeExecutable": "C:\\Users\\mgamb\\.deno\\bin\\deno.EXE",
"runtimeArgs": [
"run",
"--inspect-wait",
"--allow-all"
],
"attachSimplePort": 9229
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# HtmlParser


```html
<div><input disabled required type='text' /></div>
<div><input disabled required type="text" /></div>
```

```js
const hp = new HtmlParser()
const hp = new HtmlParser();

let result = hp.Parse("<div><input disabled required type='text' /></div>")
let result = hp.Parse("<div><input disabled required type='text' /></div>");
```

![Screenshot](docs/output-screenshot.png)
156 changes: 156 additions & 0 deletions __tests__/__snapshots__/parser.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
export const snapshot = {};

snapshot[`HtmlParser Tests > simple test 1`] = `
HtmlNode {
_outerHTML: "<div />",
attributes: {
"/": undefined,
},
children: [],
content: undefined,
endIndex: 7,
endTag: undefined,
selfClosing: undefined,
startIndex: 0,
tag: "div",
type: 3,
}
`;

snapshot[`HtmlParser Tests > attribute test 1`] = `
HtmlNode {
_outerHTML: "<input disabled required type='text' />",
attributes: {
disabled: undefined,
required: undefined,
type: "text",
},
children: [],
content: undefined,
endIndex: 39,
endTag: "",
selfClosing: true,
startIndex: 0,
tag: "input",
type: 3,
}
`;

snapshot[`HtmlParser Tests > attribute test 2`] = `
HtmlNode {
_outerHTML: "<div><input disabled required type='text' /></div>",
attributes: {},
children: [
HtmlNode {
_outerHTML: "<input disabled required type='text' />",
attributes: {
disabled: undefined,
required: undefined,
type: "text",
},
children: [],
content: undefined,
endIndex: 44,
endTag: "",
selfClosing: true,
startIndex: 5,
tag: "input",
type: 3,
},
],
content: undefined,
endIndex: 50,
endTag: "div",
selfClosing: undefined,
startIndex: 0,
tag: "div",
type: 3,
}
`;

snapshot[`HtmlParser Tests > incomplete sample 1`] = `
[
HtmlNode {
_outerHTML: '<article id="edito',
attributes: {
dito: "ito",
id: "edito",
ito: "to",
o: undefined,
to: "o",
},
children: [],
content: undefined,
endIndex: 18,
endTag: undefined,
selfClosing: undefined,
startIndex: 0,
tag: "article",
type: 3,
},
]
`;

snapshot[`HtmlParser Tests > jsx sample 1`] = `
[
HtmlNode {
_outerHTML: "<fieldset>
<legend>Enter temperature in {scaleNames[scale]}:</legend>
<input value={temperature}
onChange={this.handleChange} />
</fieldset>",
attributes: {},
children: [
HtmlNode {
_outerHTML: "<legend>Enter temperature in {scaleNames[scale]}:</legend>",
attributes: {},
children: [
HtmlNode {
_outerHTML: undefined,
attributes: {},
children: [],
content: "Enter temperature in {scaleNames[scale]}:",
endIndex: 0,
endTag: undefined,
selfClosing: undefined,
startIndex: 0,
tag: undefined,
type: 4,
},
],
content: undefined,
endIndex: 77,
endTag: "legend",
selfClosing: undefined,
startIndex: 19,
tag: "legend",
type: 3,
},
HtmlNode {
_outerHTML: "<input value={temperature}
onChange={this.handleChange} />",
attributes: {
onChange: "{this.handleChange}",
value: "{temperature}
",
},
children: [],
content: undefined,
endIndex: 159,
endTag: "",
selfClosing: true,
startIndex: 86,
tag: "input",
type: 3,
},
],
content: undefined,
endIndex: 177,
endTag: "fieldset",
selfClosing: undefined,
startIndex: 0,
tag: "fieldset",
type: 3,
},
]
`;
Loading

0 comments on commit 1bdf4f0

Please sign in to comment.