Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .c8rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"reporter": ["lcov", "text"]
}
17 changes: 7 additions & 10 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# This file is for unifying the coding style for different editors and IDEs.
# More information at http://EditorConfig.org

# No .editorconfig files above the root directory
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
indent_style = space
charset = utf-8
quote_type = single
trim_trailing_whitespace = true
insert_final_newline = true

[*.{bemjson.js,deps.js}]
indent_size = 4

[{bower,package}.json]
[{package.json,*.yml,*.jade,*.pss,*.css,*.js,*.md,.*,*.ts}]
indent_size = 2

[{changelog.md,.*}]
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false
12 changes: 12 additions & 0 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: posthtml
open_collective: posthtml
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
39 changes: 39 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Actions Status
on:
pull_request:
types: [opened, synchronize]
branches:
- master
env:
CI: true

jobs:
run:
name: Node ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node: [10, 12, 14]
os: [ubuntu-latest]

steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set Node.js version
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install npm dependencies
run: npm ci

- name: Run tests
run: npm run test

- name: Run Coveralls
uses: coverallsapp/github-action@master
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
61 changes: 0 additions & 61 deletions .jscsrc

This file was deleted.

2 changes: 0 additions & 2 deletions .jshintignore

This file was deleted.

8 changes: 0 additions & 8 deletions .jshintrc

This file was deleted.

4 changes: 2 additions & 2 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"*.js": "jshint . && jscs ."
}
"*.js": "xo"
}
7 changes: 2 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
node_modules/
test/
node_modules
test
npm-debug.log
.editorconfig
.jscsrc
.jshintignore
.jshintrc
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions MAINTAINERS

This file was deleted.

28 changes: 26 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
## <small>0.5.1 (2020-10-27)</small>

* style: 2 space, close issue #33 ([cdd7dbd](https://github.com/posthtml/posthtml-parser/commit/cdd7dbd)), closes [#33](https://github.com/posthtml/posthtml-parser/issues/33)
* style: after lint ([23dd2a0](https://github.com/posthtml/posthtml-parser/commit/23dd2a0))
* build: change eslint to xo ([5233a43](https://github.com/posthtml/posthtml-parser/commit/5233a43))
* build: change lint to eslint ([f6eef50](https://github.com/posthtml/posthtml-parser/commit/f6eef50))
* build: update bump version script ([7b7cfbf](https://github.com/posthtml/posthtml-parser/commit/7b7cfbf))
* build: update dep dev ([8601e40](https://github.com/posthtml/posthtml-parser/commit/8601e40))
* perf: concate with prev content string ([fe7ddb0](https://github.com/posthtml/posthtml-parser/commit/fe7ddb0))
* perf: downgrade code for old node ([b160b9d](https://github.com/posthtml/posthtml-parser/commit/b160b9d))
* perf: migrate to parser v5 ([c2349ad](https://github.com/posthtml/posthtml-parser/commit/c2349ad))
* ci: change nyc to c8 ([1638a07](https://github.com/posthtml/posthtml-parser/commit/1638a07))
* ci: forgot config for c8 ([ba45ba6](https://github.com/posthtml/posthtml-parser/commit/ba45ba6))
* ci: migrate to github action from travis ([05e3768](https://github.com/posthtml/posthtml-parser/commit/05e3768))
* test: contents are split with '<' in comment, issue #18 ([cbeb319](https://github.com/posthtml/posthtml-parser/commit/cbeb319)), closes [#18](https://github.com/posthtml/posthtml-parser/issues/18)
* test: contents are split with '<' in comment, issue #45 ([74169cd](https://github.com/posthtml/posthtml-parser/commit/74169cd)), closes [#45](https://github.com/posthtml/posthtml-parser/issues/45)
* fix: contents are split with '<' in comment, close #18, close #45 ([8e64082](https://github.com/posthtml/posthtml-parser/commit/8e64082)), closes [#18](https://github.com/posthtml/posthtml-parser/issues/18) [#45](https://github.com/posthtml/posthtml-parser/issues/45)
* refactor: migrate to es-next syntax ([d89bf85](https://github.com/posthtml/posthtml-parser/commit/d89bf85))
* docs: simple update ([0c10d9d](https://github.com/posthtml/posthtml-parser/commit/0c10d9d))



## 0.5.0 (2020-08-22)

* revert: incorrect changes ([0601fbd](https://github.com/posthtml/posthtml-parser/commit/0601fbd))
* style: lintstage lint update ([43398d5](https://github.com/posthtml/posthtml-parser/commit/43398d5))
* 0.5.0 ([be05a9f](https://github.com/posthtml/posthtml-parser/commit/be05a9f))
* build: forgot conventional-changelog-cli ([8ff437a](https://github.com/posthtml/posthtml-parser/commit/8ff437a))
* build: update changelog ([d0a07dc](https://github.com/posthtml/posthtml-parser/commit/d0a07dc))
* build: update dep dev ([f8efe55](https://github.com/posthtml/posthtml-parser/commit/f8efe55))
* build: update lint/build system ([54adc49](https://github.com/posthtml/posthtml-parser/commit/54adc49))
* build(deps): bump handlebars from 4.0.11 to 4.5.3 ([8773f14](https://github.com/posthtml/posthtml-parser/commit/8773f14))
* revert: incorrect changes ([0601fbd](https://github.com/posthtml/posthtml-parser/commit/0601fbd))
* style: lintstage lint update ([43398d5](https://github.com/posthtml/posthtml-parser/commit/43398d5))
* ci: drop old node support ([cf95d62](https://github.com/posthtml/posthtml-parser/commit/cf95d62))
* ci: drop support old node ([d415fb9](https://github.com/posthtml/posthtml-parser/commit/d415fb9))
* fix: incorrect merge defaultOptions, close #47 ([11ba7fb](https://github.com/posthtml/posthtml-parser/commit/11ba7fb)), closes [#47](https://github.com/posthtml/posthtml-parser/issues/47)
Expand Down
54 changes: 27 additions & 27 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
declare namespace parser {
type DefaultOptions = {
/**
/**
* @default false
*/
lowerCaseTags: boolean;
lowerCaseTags: boolean;

/**
/**
* @default false
*/
lowerCaseAttributeNames: boolean;
lowerCaseAttributeNames: boolean;
};

type Directive = {
name: string;
start: string;
end: string;
name: string;
start: string;
end: string;
};

type Options = {
/**
/**
* Adds processing of custom directives.
* Note: The property `name` in custom directives can be `String` or `RegExp` type.
*
* @default
* [{name: '!doctype', start: '<', end: '>'}]
*/
directives?: Directive[];
directives?: Directive[];

/**
/**
* Indicates whether special tags (`<script>` and `<style>`) should get special treatment and if "empty" tags (eg. `<br>`) can have children.
* If `false`, the content of special tags will be text only.
* For feeds and other XML content (documents that don't consist of HTML), set this to true.
*
* @default false
*/
xmlMode?: boolean;
xmlMode?: boolean;

/**
/**
* If set to `true`, entities within the document will be decoded.
*
* @default false
*/
decodeEntities?: boolean;
decodeEntities?: boolean;

/**
/**
* If set to `true`, all tags will be lowercased. If `xmlMode` is disabled.
*
* @default false
*/
lowerCaseTags?: boolean;
lowerCaseTags?: boolean;

/**
/**
* If set to `true`, all attribute names will be lowercased. This has noticeable impact on speed.
*
* @default false
*/
lowerCaseAttributeNames?: boolean;
lowerCaseAttributeNames?: boolean;

/**
/**
* If set to true, CDATA sections will be recognized as text even if the `xmlMode` option is not enabled.
* NOTE: If `xmlMode` is set to `true` then CDATA sections will always be recognized as text.
*
* @default false
*/
recognizeCDATA?: boolean;
recognizeCDATA?: boolean;

/**
/**
* If set to `true`, self-closing tags will trigger the `onclosetag` event even if `xmlMode` is not set to `true`.
* NOTE: If `xmlMode` is set to true then self-closing tags will always be recognized.
*
* @default false
*/
recognizeSelfClosing?: boolean;
recognizeSelfClosing?: boolean;
};

type Tree = Node[];
type Node = NodeText | NodeTag;
type NodeText = string;
type NodeTag = {
tag: string;
attrs?: Attributes;
content?: Node[];
tag: string;
attrs?: Attributes;
content?: Node[];
};

type Attributes = Record<string, string>;
}

declare const parser: {
defaultOptions: parser.DefaultOptions;
defaultDirectives: parser.Directive[];
defaultOptions: parser.DefaultOptions;
defaultDirectives: parser.Directive[];

(content: string, options?: parser.Options): parser.Tree;
(content: string, options?: parser.Options): parser.Tree;
};

export = parser;
Loading