├── packages
├── webparser
│ ├── .npmignore
│ ├── src
│ │ ├── public_api.ts
│ │ ├── interpolation_config.ts
│ │ ├── html_parser.ts
│ │ ├── assertions.ts
│ │ ├── ast_path.ts
│ │ ├── chars.ts
│ │ └── ast_spec_utils.ts
│ ├── jest.config.js
│ ├── tsconfig.json
│ ├── tslint.json
│ ├── package.json
│ ├── LICENSE
│ └── README.md
├── prettyhtml-hast-to-html
│ ├── index.js
│ ├── lib
│ │ ├── omission
│ │ │ ├── index.js
│ │ │ ├── util
│ │ │ │ ├── place.js
│ │ │ │ ├── first.js
│ │ │ │ ├── white-space-left.js
│ │ │ │ └── siblings.js
│ │ │ ├── omission.js
│ │ │ └── opening.js
│ │ ├── raw.js
│ │ ├── comment.js
│ │ ├── text.js
│ │ ├── doctype.js
│ │ ├── one.js
│ │ ├── all.js
│ │ ├── constants.js
│ │ └── index.js
│ ├── test
│ │ ├── omission-opening.js
│ │ ├── index.js
│ │ ├── root.js
│ │ ├── core.js
│ │ ├── comment.js
│ │ ├── raw.js
│ │ ├── omission-closing-tr.js
│ │ ├── omission-closing-tfoot.js
│ │ ├── omission-opening-html.js
│ │ ├── omission-closing-body.js
│ │ ├── omission-closing-html.js
│ │ ├── omission-closing.js
│ │ ├── omission-closing-li.js
│ │ ├── text.js
│ │ ├── omission-closing-optgroup.js
│ │ ├── omission-opening-tbody.js
│ │ ├── omission-closing-head.js
│ │ ├── omission-closing-dd.js
│ │ ├── omission-closing-dt.js
│ │ ├── omission.js
│ │ ├── omission-closing-tbody.js
│ │ ├── element.js
│ │ ├── omission-closing-colgroup.js
│ │ ├── omission-closing-option.js
│ │ ├── omission-closing-thead.js
│ │ ├── omission-opening-head.js
│ │ ├── omission-closing-caption.js
│ │ ├── omission-closing-td-th.js
│ │ ├── omission-opening-colgroup.js
│ │ ├── omission-closing-rp-rt.js
│ │ ├── omission-opening-body.js
│ │ ├── omission-closing-menuitem.js
│ │ └── omission-closing-p.js
│ ├── README.md
│ ├── LICENSE
│ └── package.json
├── prettyhtml-formatter
│ ├── test
│ │ ├── fixtures
│ │ │ ├── indent-number
│ │ │ │ ├── config.json
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── indent-tabs
│ │ │ │ ├── config.json
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── attribute-known-incasesensitive
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── print-width-tabs
│ │ │ │ ├── config.json
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── indent-initial-false
│ │ │ │ ├── input.html
│ │ │ │ ├── config.json
│ │ │ │ └── output.html
│ │ │ ├── print-width-custom
│ │ │ │ ├── config.json
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── print-width-nested-tabs
│ │ │ │ ├── config.json
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── script-no-prettier
│ │ │ │ ├── config.json
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── style-no-prettier
│ │ │ │ ├── config.json
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── attribute-single-quotes
│ │ │ │ ├── config.json
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── case-sensitive-void-elements
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── attribute-no-quotes
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── camelCase-tags
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── doctype
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── force-attribute-wrapping
│ │ │ │ ├── config.json
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── custom-void-elements
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── preserve-boolean-attributes
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── attribute-casesensitive
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── auto-close-tags
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── entity-encoding
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── void
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── indent-default
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── self-closing-elements
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── indent-initial-default
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── table-foster-parenting
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── tag-casesensitive
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── white-space-void
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── attribute-quoting
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── attribute-character-references
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── comments-elements
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── image-tag
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── style
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── print-width-void
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── structural-directives-vue
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── style-different-type
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── print-width-nested
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── print-width-self-closing
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── print-width
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── structural-directives-angular
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── template-expressions-vue
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── preserve-whitespace-flag
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── issue-74-white-space
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── parent-insertion
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── preserve-explicit-namespace
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── attribute-encoding
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── nested-templates
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── mixed-documents
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── template-expressions-angular
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── gaps-preservation
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── indent-multiline-text
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── prettier-embedded
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── comments
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── issue-79-gaps-preservation
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── print-width-with-inner-text
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── comments-conditional
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── template-expressions-svelte
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── whitespace-leading-text
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── script-nested
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── ignore-flag
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── example
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── vue
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── issue-65-white-space
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── soft-table-handling
│ │ │ │ ├── output.html
│ │ │ │ └── input.html
│ │ │ ├── preserve-attribute-wrapping-flag
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── white-space
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ ├── attribute-boolean
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ │ └── html5-boilerplate
│ │ │ │ ├── input.html
│ │ │ │ └── output.html
│ │ └── index.js
│ ├── stringify.js
│ ├── README.md
│ ├── LICENSE
│ └── package.json
├── prettyhtml-hastscript
│ ├── index.js
│ ├── .editorconfig
│ ├── svg.js
│ ├── html.js
│ ├── README.md
│ ├── LICENSE
│ └── package.json
├── prettyhtml
│ ├── test
│ │ ├── snapshots
│ │ │ ├── api.js.snap
│ │ │ ├── cli.js.snap
│ │ │ ├── api.js.md
│ │ │ └── cli.js.md
│ │ └── api.js
│ ├── README.md
│ ├── test-helpers
│ │ ├── prepareVfile.js
│ │ └── util.js
│ ├── LICENSE
│ ├── index.js
│ ├── package.json
│ └── cli
│ │ ├── processor.js
│ │ ├── index.js
│ │ └── args.js
├── expression-parser
│ ├── test
│ │ ├── snapshots
│ │ │ └── index.js.snap
│ │ └── index.js
│ ├── package.json
│ └── README.md
├── rehype-webparser
│ ├── test
│ │ └── index.test.ts
│ ├── tsconfig.json
│ ├── jest.config.js
│ ├── tslint.json
│ ├── LICENSE
│ ├── package.json
│ └── README.md
├── prettyhtml-sort-attributes
│ ├── README.md
│ ├── index.js
│ ├── package.json
│ └── test.js
├── hast-util-from-webparser
│ ├── tsconfig.json
│ ├── jest.config.js
│ ├── tslint.json
│ ├── LICENSE
│ ├── package.json
│ └── README.md
├── rehype-minify-whitespace
│ ├── list.js
│ ├── README.md
│ ├── LICENSE
│ ├── package.json
│ └── test.js
└── prettyhtml-quick
│ ├── package.json
│ ├── LICENSE
│ ├── README.md
│ ├── lib
│ └── git.js
│ └── bin
│ └── cli.js
├── logo.png
├── .eslintrc.json
├── .gitattributes
├── .prettierrc
├── .prettierignore
├── lerna.json
├── azure-pipelines.yml
├── .github
├── ISSUE_TEMPLATE.md
├── ISSUE_TEMPLATE
│ ├── feature.md
│ ├── question.md
│ ├── bug.md
│ └── regression.md
└── stale.yml
├── .eslintignore
├── examples
└── simple.js
├── .editorconfig
├── azure-pipelines-template.yml
├── LICENSE
├── .gitignore
└── package.json
/packages/webparser/.npmignore:
--------------------------------------------------------------------------------
1 | coverage
2 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prettyhtml/prettyhtml/HEAD/logo.png
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | module.exports = require('./lib')
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-number/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 4
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-tabs/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "useTabs": true
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hastscript/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = require('./html')
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-known-incasesensitive/input.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-number/input.html:
--------------------------------------------------------------------------------
1 | Foo
2 | bar
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-tabs/input.html:
--------------------------------------------------------------------------------
1 | Foo
2 | bar
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-tabs/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "useTabs": true
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-known-incasesensitive/output.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-initial-false/input.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-custom/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 120
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-nested-tabs/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "useTabs": true
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/script-no-prettier/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "usePrettier": false
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/style-no-prettier/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "usePrettier": false
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-single-quotes/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/case-sensitive-void-elements/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-initial-false/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "indentInitial": false
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-initial-false/output.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-no-quotes/input.html:
--------------------------------------------------------------------------------
1 | This is valid.
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/camelCase-tags/input.html:
--------------------------------------------------------------------------------
1 | This is valid.
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/doctype/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/force-attribute-wrapping/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "wrapAttributes": true
3 | }
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-tabs/output.html:
--------------------------------------------------------------------------------
1 |
2 | Foo
3 | bar
4 |
5 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "hemera",
3 | "globals": {
4 | "expect": true,
5 | "Code": true
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-no-quotes/output.html:
--------------------------------------------------------------------------------
1 | This is valid.
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/camelCase-tags/output.html:
--------------------------------------------------------------------------------
1 | This is valid.
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/case-sensitive-void-elements/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/custom-void-elements/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/doctype/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-number/output.html:
--------------------------------------------------------------------------------
1 |
2 | Foo
3 | bar
4 |
5 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/custom-void-elements/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/preserve-boolean-attributes/output.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-casesensitive/output.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/auto-close-tags/input.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/entity-encoding/input.html:
--------------------------------------------------------------------------------
1 | &
2 | foo > bar
3 | foo < bar
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/entity-encoding/output.html:
--------------------------------------------------------------------------------
1 | &
2 | foo > bar
3 | foo < bar
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/preserve-boolean-attributes/input.html:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/void/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-casesensitive/input.html:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/auto-close-tags/output.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/void/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set the default behavior, in case people don't have core.autocrlf set.
2 | * text=auto
3 | *.html text eol=lf
4 | *.htm text eol=lf
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-default/input.html:
--------------------------------------------------------------------------------
1 | Foo
2 | bar
3 |
4 | Foo
5 | bar
6 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml/test/snapshots/api.js.snap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prettyhtml/prettyhtml/HEAD/packages/prettyhtml/test/snapshots/api.js.snap
--------------------------------------------------------------------------------
/packages/prettyhtml/test/snapshots/cli.js.snap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prettyhtml/prettyhtml/HEAD/packages/prettyhtml/test/snapshots/cli.js.snap
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 110,
3 | "semi": false,
4 | "singleQuote": true,
5 | "trailingComma": "none",
6 | "bracketSpacing": true
7 | }
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/self-closing-elements/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/omission/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | exports.opening = require('./opening')
3 | exports.closing = require('./closing')
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/self-closing-elements/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | packages/prettyhtml-formatter/test/fixtures
3 | coverage
4 | packages/*/dist
5 | packages/*/coverage
6 | packages/*/.nyc_output
7 |
--------------------------------------------------------------------------------
/packages/expression-parser/test/snapshots/index.js.snap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prettyhtml/prettyhtml/HEAD/packages/expression-parser/test/snapshots/index.js.snap
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/force-attribute-wrapping/input.html:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/force-attribute-wrapping/output.html:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-default/output.html:
--------------------------------------------------------------------------------
1 |
2 | Foo
3 | bar
4 |
5 |
6 | Foo
7 | bar
8 |
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-initial-default/input.html:
--------------------------------------------------------------------------------
1 |
4 |
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-initial-default/output.html:
--------------------------------------------------------------------------------
1 |
4 |
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/table-foster-parenting/input.html:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/tag-casesensitive/input.html:
--------------------------------------------------------------------------------
1 | foo
2 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/tag-casesensitive/output.html:
--------------------------------------------------------------------------------
1 | foo
2 |
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/white-space-void/input.html:
--------------------------------------------------------------------------------
1 | Some code , emphasis , and more importance
2 | .
3 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/raw.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = raw
4 |
5 | /* Stringify `raw`. */
6 | function raw(ctx, node) {
7 | return node.value
8 | }
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-quoting/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-quoting/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/table-foster-parenting/output.html:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/white-space-void/output.html:
--------------------------------------------------------------------------------
1 |
2 | Some
3 | code,
4 | emphasis , and
5 | more
6 | importance
7 | .
8 |
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/comment.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = comment
4 |
5 | /* Stringify a comment `node`. */
6 | function comment(ctx, node) {
7 | return ''
8 | }
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-single-quotes/input.html:
--------------------------------------------------------------------------------
1 | This is valid.
2 | This is valid.
3 | This is valid.
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-character-references/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-character-references/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-single-quotes/output.html:
--------------------------------------------------------------------------------
1 | This is valid.
2 | This is valid.
3 | This is valid.
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/comments-elements/output.html:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/packages/rehype-webparser/test/index.test.ts:
--------------------------------------------------------------------------------
1 | import parse from '../index'
2 |
3 | test('Simple', () => {
4 | const parser: any = {}
5 | parse.bind(parser)()
6 |
7 | expect(parser.Parser).toBeInstanceOf(Function)
8 | })
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hastscript/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/comments-elements/input.html:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/text.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = text
4 |
5 | /* Stringify `text`. */
6 | function text(ctx, node, index, parent) {
7 | var value = node.value
8 |
9 | return value
10 | }
11 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/image-tag/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | foo
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/image-tag/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | foo
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/style/output.html:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-sort-attributes/README.md:
--------------------------------------------------------------------------------
1 | # @starptech/prettyhtml-sort-attributes
2 |
3 | Sort attributes alphabetically
4 |
5 | ## Installation
6 |
7 | ```
8 | npm install --save @starptech/prettyhtml-sort-attributes
9 | ```
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml/README.md:
--------------------------------------------------------------------------------
1 | # @starptech/prettyhtml
2 |
3 | This is the primary tool to interact with the formatter. We provide cli and api.
4 |
5 | ## Installation
6 |
7 | ```
8 | npm install --save @starptech/prettyhtml
9 | ```
10 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "lerna": "3.20.2",
3 | "packages": ["packages/*"],
4 | "useWorkspaces": true,
5 | "version": "0.10.1",
6 | "command": {
7 | "publish": {
8 | "registry": "https://registry.npmjs.org"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-void/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/structural-directives-vue/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 404
4 | the {{ resource }} was
5 | not found
6 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/style-different-type/input.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-nested/input.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-self-closing/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hastscript/svg.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var schema = require('property-information/svg')
4 | var factory = require('./factory')
5 |
6 | var svg = factory(schema, 'g')
7 | svg.displayName = 'svg'
8 |
9 | module.exports = svg
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/structural-directives-vue/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 404
4 |
5 | the {{ resource }} was
6 |
7 | not found
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/style/input.html:
--------------------------------------------------------------------------------
1 |
3 |
9 |
10 |
12 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hastscript/html.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var schema = require('property-information/html')
4 | var factory = require('./factory')
5 |
6 | var html = factory(schema, 'div')
7 | html.displayName = 'html'
8 |
9 | module.exports = html
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml/test-helpers/prepareVfile.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = prepareVfile
4 |
5 | function prepareVfile(vfile) {
6 | // eslint-disable-next-line no-param-reassign
7 | vfile.cwd = 'skipped in tests'
8 | return vfile
9 | }
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-nested-tabs/input.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-tabs/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/structural-directives-angular/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 404
4 | the {{ resource }} was
5 | not found
6 |
7 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - template: azure-pipelines-template.yml
3 | parameters:
4 | name: Linux
5 | vmImage: ubuntu-16.04
6 |
7 | - template: azure-pipelines-template.yml
8 | parameters:
9 | name: Windows
10 | vmImage: vs2017-win2016
11 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/template-expressions-vue/output.html:
--------------------------------------------------------------------------------
1 |
2 | {{ message.split('').reverse().join('') }}
3 | Hello world
4 | {{ ok ? 'YES' : 'NO' }}
5 | foo bar
6 | {{ name }}
7 | {{ footer }}
8 |
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/omission/util/place.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = place
4 |
5 | /* Get the position of `node` in `parent`. */
6 | function place(parent, child) {
7 | return parent && parent.children && parent.children.indexOf(child)
8 | }
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/structural-directives-angular/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 404
4 |
5 | the {{ resource }} was
6 |
7 | not found
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/style-different-type/output.html:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/template-expressions-vue/input.html:
--------------------------------------------------------------------------------
1 |
2 | {{ message.split('').reverse().join('') }}
3 | Hello world
4 | {{ ok ? 'YES' : 'NO' }}
5 | foo bar
6 | {{ name }}
7 | {{ footer }}
8 |
9 |
--------------------------------------------------------------------------------
/packages/webparser/src/public_api.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @module
3 | * @description
4 | * Entry point for all APIs of the parser package.
5 | *
6 | */
7 |
8 | export * from './html_parser'
9 | export * from './ast'
10 | export * from './parse_util'
11 | export * from './tags'
12 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## 👉 [Please follow one of these issue templates](https://github.com/Prettyhtml/prettyhtml/issues/new/choose) 👈
2 |
3 | Note: to keep the backlog clean and actionable, issues may be immediately closed if they do not follow one of the above issue templates.
4 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/preserve-whitespace-flag/output.html:
--------------------------------------------------------------------------------
1 |
2 | Check me out
3 | foo
4 |
5 |
9 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | **/dist/**
2 | **/node_modules/**
3 | .nyc_output
4 | **/coverage/**
5 | packages/rehype-webparser
6 | packages/rehype-minify-whitespace
7 | packages/prettyhtml-sort-attributes
8 | packages/prettyhtml-hastscript
9 | packages/prettyhtml-hast-to-html
10 | packages/expression-parser
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/preserve-whitespace-flag/input.html:
--------------------------------------------------------------------------------
1 |
2 | Check me out
3 | foo
4 |
5 |
9 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-void/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-self-closing/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-tabs/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-nested-tabs/output.html:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-nested/output.html:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/omission/util/first.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var after = require('./siblings').after
4 |
5 | module.exports = first
6 |
7 | /* Get the first child in `parent`. */
8 | function first(parent, includeWhiteSpace) {
9 | return after(parent, -1, includeWhiteSpace)
10 | }
11 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/issue-74-white-space/input.html:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/packages/rehype-webparser/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "esModuleInterop": true,
5 | "target": "es6",
6 | "noImplicitAny": true,
7 | "moduleResolution": "node",
8 | "sourceMap": true,
9 | "outDir": "dist",
10 | "baseUrl": "."
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/hast-util-from-webparser/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "esModuleInterop": true,
5 | "target": "es6",
6 | "noImplicitAny": true,
7 | "moduleResolution": "node",
8 | "sourceMap": true,
9 | "outDir": "dist",
10 | "baseUrl": "."
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/omission-opening.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | /* eslint-disable import/no-unassigned-import */
4 |
5 | require('./omission-opening-body')
6 | require('./omission-opening-colgroup')
7 | require('./omission-opening-head')
8 | require('./omission-opening-html')
9 | require('./omission-opening-tbody')
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-custom/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/webparser/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | globals: {
3 | 'ts-jest': {
4 | tsConfig: 'tsconfig.json'
5 | }
6 | },
7 | moduleFileExtensions: ['ts', 'js'],
8 | transform: {
9 | '^.+\\.(ts|tsx)$': 'ts-jest'
10 | },
11 | testMatch: ['**/test/**/*.spec.ts'],
12 | testEnvironment: 'node'
13 | }
14 |
--------------------------------------------------------------------------------
/packages/rehype-webparser/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | globals: {
3 | 'ts-jest': {
4 | tsConfig: 'tsconfig.json'
5 | }
6 | },
7 | moduleFileExtensions: ['ts', 'js'],
8 | transform: {
9 | '^.+\\.(ts|tsx)$': 'ts-jest'
10 | },
11 | testMatch: ['**/test/**/*.test.ts'],
12 | testEnvironment: 'node'
13 | }
14 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/parent-insertion/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/parent-insertion/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/preserve-explicit-namespace/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/issue-74-white-space/output.html:
--------------------------------------------------------------------------------
1 |
12 |
--------------------------------------------------------------------------------
/packages/webparser/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "esModuleInterop": true,
5 | "target": "es6",
6 | "noImplicitAny": true,
7 | "moduleResolution": "node",
8 | "declaration": true,
9 | "sourceMap": true,
10 | "outDir": "dist",
11 | "baseUrl": "."
12 | },
13 | "include": ["src/**/*"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/hast-util-from-webparser/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | globals: {
3 | 'ts-jest': {
4 | tsConfig: 'tsconfig.json'
5 | }
6 | },
7 | moduleFileExtensions: ['ts', 'js'],
8 | transform: {
9 | '^.+\\.(ts|tsx)$': 'ts-jest'
10 | },
11 | testMatch: ['**/test/**/*.test.ts', '**/__snapshot__/**/*.snap'],
12 | testEnvironment: 'node'
13 | }
14 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-custom/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/omission/util/white-space-left.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var is = require('unist-util-is')
4 | var whiteSpace = require('hast-util-whitespace')
5 |
6 | module.exports = whiteSpaceLeft
7 |
8 | /* Check if `node` starts with white-space. */
9 | function whiteSpaceLeft(node) {
10 | return is('text', node) && whiteSpace(node.value.charAt(0))
11 | }
12 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-encoding/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | help
6 |
7 | Special
8 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/nested-templates/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{getChipString(data.item)}} {{data.item.name}}
5 |
6 | {{getChipString(data.item)}} {{data.item.name}}
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/mixed-documents/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Document 1
5 |
6 |
7 |
8 | foo1
9 |
10 |
11 |
12 |
13 |
14 |
15 | Document 2
16 |
17 |
18 |
19 | foo2
20 |
21 |
22 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/template-expressions-angular/input.html:
--------------------------------------------------------------------------------
1 |
2 | {{ message | translate }}
3 | Hello world
4 | {{ title }}
5 | foo bar
6 | {{ name }} {{ footer }}
7 |
8 |
9 | {{ message | translate }}Hello world {{ title }}{{ name }} {{ footer }}
10 |
11 | {{
12 | name
13 | }}
14 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/stringify.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const xtend = require('xtend')
4 | const toHTML = require('@starptech/prettyhtml-hast-to-html')
5 |
6 | module.exports = stringify
7 |
8 | function stringify(config) {
9 | const settings = xtend(config, this.data('settings'))
10 |
11 | this.Compiler = compiler
12 |
13 | function compiler(tree) {
14 | return toHTML(tree, settings)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/preserve-explicit-namespace/output.html:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | /* eslint-disable import/no-unassigned-import */
4 |
5 | require('./core')
6 | require('./root')
7 | require('./comment')
8 | require('./doctype')
9 | require('./text')
10 | require('./raw')
11 | require('./element')
12 | require('./attribute')
13 | require('./omission')
14 | require('./omission-opening')
15 | require('./omission-closing')
16 | require('./svg')
17 |
--------------------------------------------------------------------------------
/examples/simple.js:
--------------------------------------------------------------------------------
1 | const prettyhtml = require('./../packages/prettyhtml')
2 |
3 | // example with angular template
4 | try {
5 | const result = prettyhtml(
6 | ``
7 | )
8 | console.log(result.contents)
9 | } catch (error) {
10 | console.error(error)
11 | }
12 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/gaps-preservation/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/mixed-documents/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Document 1
5 |
6 |
7 | foo1
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Document 2
16 |
17 |
18 | foo2
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/root.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var h = require('@starptech/prettyhtml-hastscript')
5 | var u = require('unist-builder')
6 | var to = require('..')
7 |
8 | test('`root`', function(t) {
9 | t.deepEqual(
10 | to(u('root', [u('text', 'alpha '), h('i', 'bravo'), u('text', ' charlie')])),
11 | 'alpha bravo charlie',
12 | 'should stringify `root`s'
13 | )
14 | })
15 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/nested-templates/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{getChipString(data.item)}}
5 | {{data.item.name}}
6 |
7 |
8 | {{getChipString(data.item)}}
9 | {{data.item.name}}
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/attribute-encoding/output.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 | help
11 |
14 | Special
15 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-multiline-text/output.html:
--------------------------------------------------------------------------------
1 |
2 | my text
3 | on multiple
4 | lines
5 |
6 |
7 | my text
8 | on multiple
9 | lines
10 | fooBar
11 |
12 |
13 | my text
14 | on multiple
15 | lines
16 |
17 |
18 |
19 | my text
20 | on multiple
21 | lines
22 |
23 | dedwedwed
24 | dwedwedwe
25 |
26 |
27 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/prettier-embedded/output.html:
--------------------------------------------------------------------------------
1 |
10 |
11 |
21 |
22 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/indent-multiline-text/input.html:
--------------------------------------------------------------------------------
1 |
2 | my text
3 | on multiple
4 | lines
5 |
6 |
7 | my text
8 | on multiple
9 | lines
10 | fooBar
11 |
12 |
13 | my text
14 | on multiple
15 | lines
16 |
17 |
18 | my text
19 | on multiple
20 | lines
21 | dedwedwed
22 | dwedwedwe
23 |
24 |
25 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/template-expressions-angular/output.html:
--------------------------------------------------------------------------------
1 |
2 | {{ message | translate }}
3 | Hello world
4 | {{ title }}
5 | foo bar
6 | {{ name }}
7 | {{ footer }}
8 |
9 |
10 |
11 | {{ message | translate }}
12 | Hello world
13 | {{ title }}
14 | {{ name }}
15 | {{ footer }}
16 |
17 |
18 |
19 | {{
20 | name
21 | }}
22 |
23 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/gaps-preservation/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Content
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/comments/input.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | foo
12 |
13 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/comments/output.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | foo
14 |
15 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/prettier-embedded/input.html:
--------------------------------------------------------------------------------
1 |
5 |
6 |
16 |
25 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/script-no-prettier/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/script-no-prettier/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/issue-79-gaps-preservation/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
19 |
--------------------------------------------------------------------------------
/packages/expression-parser/test/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const test = require('ava')
4 | const parse = require('..')
5 | const tests = require('./texpr')
6 |
7 | function getOptions(opt) {
8 | return {
9 | brackets: ['{', '}'],
10 | ...opt
11 | }
12 | }
13 |
14 | Object.keys(tests).forEach(title => {
15 | test(title, function(t) {
16 | const test = tests[title]
17 | const result = parse(test.data, getOptions(test.options))
18 | t.snapshot({ input: test.data, result })
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/style-no-prettier/output.html:
--------------------------------------------------------------------------------
1 |
2 |
10 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/core.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var u = require('unist-builder')
5 | var to = require('..')
6 |
7 | test('toHTML()', function(t) {
8 | t.throws(
9 | function() {
10 | to(true)
11 | },
12 | /Expected node, not `true`/,
13 | 'should throw on non-nodes'
14 | )
15 |
16 | t.throws(
17 | function() {
18 | to(u('foo', []))
19 | },
20 | /Cannot compile unknown node `foo`/,
21 | 'should throw on unknown nodes'
22 | )
23 | })
24 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/comment.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var u = require('unist-builder')
5 | var to = require('..')
6 |
7 | test('`comment`', function(t) {
8 | t.deepEqual(to(u('comment', 'alpha')), '', 'should stringify `comment`s')
9 |
10 | t.deepEqual(to(u('comment', 'AT&T')), '', 'should not encode `comment`s (#1)')
11 |
12 | /* No way to get around this. */
13 | t.deepEqual(to(u('comment', '-->')), '-->', 'should not encode `comment`s (#2)')
14 | })
15 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/raw.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var u = require('unist-builder')
5 | var to = require('..')
6 |
7 | test('`element/raw`', function(t) {
8 | t.deepEqual(
9 | to(u('raw', '')),
10 | '',
11 | 'should not encode `raw`s'
12 | )
13 |
14 | t.deepEqual(
15 | to(u('raw', '')),
16 | '',
17 | 'should not encode `raw`s'
18 | )
19 | })
20 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/style-no-prettier/input.html:
--------------------------------------------------------------------------------
1 |
3 |
11 |
19 |
20 |
22 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/README.md:
--------------------------------------------------------------------------------
1 | # @starptech/prettyhtml-formatter
2 |
3 | HTML formatter for [HAST](https://github.com/syntax-tree/hast)
4 |
5 | ## Installation
6 |
7 | ```
8 | npm install --save @starptech/prettyhtml-formatter
9 | ```
10 |
11 | ## Api
12 |
13 | ###### `node.data.ignore`
14 |
15 | When the data-property `ignore` is `true` the node is skipped for formatting.
16 |
17 | ## Caveats
18 |
19 | The implementation is a derivated from [**rehype-format Version 2.3.0**](https://github.com/rehypejs/rehype-format) rehype-format.
20 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/issue-79-gaps-preservation/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/omission/omission.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = omission
4 |
5 | var own = {}.hasOwnProperty
6 |
7 | /* Factory to check if a given node can have a tag omitted. */
8 | function omission(handlers) {
9 | return omit
10 |
11 | /* Check if a given node can have a tag omitted. */
12 | function omit(node, index, parent) {
13 | var name = node.tagName
14 | var fn = own.call(handlers, name) ? handlers[name] : false
15 |
16 | return fn ? fn(node, index, parent) : false
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/prettyhtml/test/api.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | const test = require('ava')
3 | const prettyhtml = require('..')
4 | const prepareVfile = require('../test-helpers/prepareVfile')
5 |
6 | test('Should format with default settings', t => {
7 | const result = prettyhtml(
8 | ``
9 | )
10 | t.snapshot(prepareVfile(result))
11 | })
12 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-with-inner-text/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/comments-conditional/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
foo
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/comments-conditional/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
foo
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/template-expressions-svelte/input.html:
--------------------------------------------------------------------------------
1 | Cats of YouTube
2 |
3 |
4 | {#each cats as cat}
5 | {cat.name}
6 | {/each}
7 |
8 |
9 |
10 | {#each rows as row, y}
11 |
12 | {#each columns as column, x}
13 |
14 | {x + 1},{y + 1}:
15 | {row[column]}
16 |
17 | {/each}
18 |
19 | {/each}
20 |
21 |
22 | {
23 | y + 1
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/print-width-with-inner-text/output.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
13 |
17 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/template-expressions-svelte/output.html:
--------------------------------------------------------------------------------
1 | Cats of YouTube
2 |
3 |
4 | {#each cats as cat}
5 |
6 | {cat.name}
7 |
8 | {/each}
9 |
10 |
11 |
12 | {#each rows as row, y}
13 |
14 | {#each columns as column, x}
15 |
16 | {x + 1},{y + 1}:
17 | {row[column]}
18 |
19 | {/each}
20 |
21 | {/each}
22 |
23 |
24 | {
25 | y + 1
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hastscript/README.md:
--------------------------------------------------------------------------------
1 | # @starptech/prettyhtml-hastscript
2 |
3 | Hyperscript compatible DSL for creating virtual HAST trees
4 |
5 | ## Installation
6 |
7 | ```
8 | npm install --save @starptech/prettyhtml-hastscript
9 | ```
10 |
11 | ## Caveats
12 |
13 | The implementation is a modified version of [**Hastscript Version 4.0.0**](https://github.com/syntax-tree/hastscript)
14 |
15 | - Known html attributes aren't handled case-sensitively
16 | - Don't coerce or optimize attribute values
17 | - Don't house `` node through `content` property. Handle it like any other element.
18 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/whitespace-leading-text/input.html:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Some code,
8 | emphasis , and
9 |
10 | importance
11 | .
12 |
13 |
14 | Some
15 | code,
16 | emphasis , and
17 |
18 | importance
19 | .
20 |
--------------------------------------------------------------------------------
/packages/webparser/src/interpolation_config.ts:
--------------------------------------------------------------------------------
1 | import { assertInterpolationSymbols } from './assertions'
2 |
3 | export class InterpolationConfig {
4 | static fromArray(markers: [string, string] | null): InterpolationConfig {
5 | if (!markers) {
6 | return DEFAULT_INTERPOLATION_CONFIG
7 | }
8 |
9 | assertInterpolationSymbols('interpolation', markers)
10 | return new InterpolationConfig(markers[0], markers[1])
11 | }
12 |
13 | constructor(public start: string, public end: string) {}
14 | }
15 |
16 | export const DEFAULT_INTERPOLATION_CONFIG: InterpolationConfig = new InterpolationConfig('{{', '}}')
17 |
--------------------------------------------------------------------------------
/packages/prettyhtml/test/snapshots/api.js.md:
--------------------------------------------------------------------------------
1 | # Snapshot report for `test/api.js`
2 |
3 | The actual snapshot is saved in `api.js.snap`.
4 |
5 | Generated by [AVA](https://ava.li).
6 |
7 | ## Should format with default settings
8 |
9 | > Snapshot 1
10 |
11 | VFile {
12 | contents: `␊
16 | `,
17 | cwd: 'skipped in tests',
18 | data: {},
19 | history: [],
20 | messages: [],
21 | }
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 🚀 Feature Proposal
3 | about: Submit a proposal for a new feature
4 | ---
5 |
6 | ## 🚀 Feature Proposal
7 |
8 |
9 |
10 | A clear and concise description of what the feature is.
11 |
12 | ## Motivation
13 |
14 | Please outline the motivation for the proposal.
15 |
16 | ## Example
17 |
18 | Please provide an example for how this feature would be used.
19 |
20 | ## Vote
21 |
22 | If you agree with my proposal vote with a 👍
23 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 💬 Questions / Help
3 | about: If you have questions, please check our Gitter
4 | ---
5 |
6 | ## 💬 Questions and Help
7 |
8 |
9 |
10 | ### Please note that this issue tracker is not a help form and this issue will be closed.
11 |
12 | Before you submit an issue we recommend you drop into the [Gitter community](https://gitter.im/Prettyhtml/Lobby) and ask any questions you have or mention any problems you've had getting started with prettyhtml.
13 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 | [*]
8 |
9 | # Change these settings to your own preference
10 | indent_style = space
11 | indent_size = 2
12 | space_after_anon_function = true
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [**/fixtures/**/*.html]
21 | insert_final_newline = false
22 | trim_trailing_whitespace = false
23 |
24 | [*.md]
25 | trim_trailing_whitespace = false
26 |
27 | [*.js]
28 | quote_type = "single"
29 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/whitespace-leading-text/output.html:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 | Some
13 | code,
14 | emphasis , and
15 |
16 | importance
17 | .
18 |
19 |
20 |
21 | Some
22 | code,
23 | emphasis , and
24 |
25 | importance
26 | .
27 |
28 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/omission-closing-tr.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var h = require('@starptech/prettyhtml-hastscript')
5 | var to = require('..')
6 |
7 | test('`tr` (closing)', function(t) {
8 | t.deepEqual(to(h('tr'), { omitOptionalTags: true }), '', 'should omit tag without siblings')
9 |
10 | t.deepEqual(
11 | to(h('table', h('tr')), { omitOptionalTags: true }),
12 | '',
13 | 'should omit tag without following'
14 | )
15 |
16 | t.deepEqual(
17 | to(h('table', [h('tr'), h('tbody')]), { omitOptionalTags: true }),
18 | '',
19 | 'should not omit tag followed by others'
20 | )
21 | })
22 |
--------------------------------------------------------------------------------
/packages/prettyhtml/test/snapshots/cli.js.md:
--------------------------------------------------------------------------------
1 | # Snapshot report for `test/cli.js`
2 |
3 | The actual snapshot is saved in `cli.js.snap`.
4 |
5 | Generated by [AVA](https://ava.li).
6 |
7 | ## Should format with default settings
8 |
9 | > Snapshot 1
10 |
11 | VFile {
12 | contents: `␊
16 | `,
17 | cwd: 'skipped in tests',
18 | data: {
19 | unifiedEngineGiven: true,
20 | unifiedEngineStreamIn: true,
21 | },
22 | history: [],
23 | messages: [],
24 | }
25 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/script-nested/output.html:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
21 |
22 |
38 |
--------------------------------------------------------------------------------
/packages/prettyhtml/test-helpers/util.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const { PassThrough } = require('stream')
4 |
5 | module.exports = spy
6 |
7 | function spy() {
8 | const stream = new PassThrough()
9 | const output = []
10 | const originalWrite = stream.write
11 |
12 | stream.write = write
13 |
14 | done.stream = stream
15 |
16 | return done
17 |
18 | function write(chunk, encoding, callback) {
19 | const cb = typeof encoding === 'function' ? encoding : callback
20 |
21 | if (typeof cb === 'function') {
22 | setImmediate(cb)
23 | }
24 |
25 | output.push(chunk)
26 | }
27 |
28 | function done() {
29 | stream.write = originalWrite
30 |
31 | return output.join('')
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/omission-closing-tfoot.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var h = require('@starptech/prettyhtml-hastscript')
5 | var to = require('..')
6 |
7 | test('`tfoot` (closing)', function(t) {
8 | t.deepEqual(to(h('tfoot'), { omitOptionalTags: true }), ' ', 'should omit tag without siblings')
9 |
10 | t.deepEqual(
11 | to(h('table', h('tfoot')), { omitOptionalTags: true }),
12 | '',
13 | 'should omit tag without following'
14 | )
15 |
16 | t.deepEqual(
17 | to(h('table', [h('tfoot'), h('tr')]), { omitOptionalTags: true }),
18 | '',
19 | 'should not omit tag followed by others'
20 | )
21 | })
22 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/ignore-flag/input.html:
--------------------------------------------------------------------------------
1 |
2 | Check me out
3 | Check me out
4 |
5 |
9 |
13 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/omission-opening-html.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var h = require('@starptech/prettyhtml-hastscript')
5 | var u = require('unist-builder')
6 | var to = require('..')
7 |
8 | test('`html` (opening)', function(t) {
9 | t.deepEqual(to(h('html'), { omitOptionalTags: true }), '', 'should omit tag without first child')
10 |
11 | t.deepEqual(
12 | to(h('html', [u('comment', 'alpha'), 'bravo']), { omitOptionalTags: true }),
13 | 'bravo',
14 | 'should not omit tag if head is `comment`'
15 | )
16 |
17 | t.deepEqual(
18 | to(h('html', 'bravo'), { omitOptionalTags: true }),
19 | 'bravo',
20 | 'should omit tag if head is not `comment`'
21 | )
22 | })
23 |
--------------------------------------------------------------------------------
/azure-pipelines-template.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - job: ${{ parameters.name }}
3 | pool:
4 | vmImage: ${{ parameters.vmImage }}
5 | strategy:
6 | matrix:
7 | node_8_x:
8 | node_version: 8.x
9 | node_10_x:
10 | node_version: 10.x
11 | maxParallel: 3
12 | steps:
13 | - task: NodeTool@0
14 | inputs:
15 | versionSpec: $(node_version)
16 | displayName: 'Install Node.js'
17 | - script: git config --global core.autocrlf false
18 | displayName: 'Git settings'
19 | - script: yarn
20 | displayName: 'Install dependencies'
21 | - script: yarn build-ts
22 | displayName: 'Build'
23 | - script: yarn test
24 | displayName: 'Run tests'
25 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/example/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | {{ item.label }}
8 |
11 |
12 | {{ item.label }}
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/script-nested/input.html:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
21 |
22 |
--------------------------------------------------------------------------------
/packages/prettyhtml-sort-attributes/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var visit = require('unist-util-visit')
4 | var has = require('hast-util-has-property')
5 |
6 | module.exports = sort
7 |
8 | function sort() {
9 | return transform
10 | }
11 |
12 | function transform(tree) {
13 | visit(tree, 'element', reorder)
14 |
15 | function reorder(node) {
16 | var props = node.properties
17 | var index = -1
18 | var result = {}
19 | var prop
20 |
21 | var all = Object.keys(props).sort((left, right) => left.localeCompare(right))
22 |
23 | while (++index < all.length) {
24 | prop = all[index]
25 |
26 | if (has(node, prop)) {
27 | result[prop] = props[prop]
28 | }
29 | }
30 |
31 | node.properties = result
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/prettyhtml-formatter/test/fixtures/ignore-flag/output.html:
--------------------------------------------------------------------------------
1 |
2 | Check me out
3 |
4 |
5 | Check me out
6 |
7 |
8 |
9 |
13 |
20 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/lib/omission/util/siblings.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var whiteSpace = require('hast-util-whitespace')
4 |
5 | exports.before = siblings(-1)
6 | exports.after = siblings(1)
7 |
8 | /* Factory to check siblings in a direction. */
9 | function siblings(increment) {
10 | return sibling
11 |
12 | /* Find applicable siblings in a direction. */
13 | function sibling(parent, index, includeWhiteSpace) {
14 | var siblings = parent && parent.children
15 | var next
16 |
17 | index += increment
18 | next = siblings && siblings[index]
19 |
20 | if (!includeWhiteSpace) {
21 | while (next && whiteSpace(next)) {
22 | index += increment
23 | next = siblings[index]
24 | }
25 | }
26 |
27 | return next
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/omission-closing-body.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var h = require('@starptech/prettyhtml-hastscript')
5 | var u = require('unist-builder')
6 | var to = require('..')
7 |
8 | test('`body` (closing)', function(t) {
9 | t.deepEqual(to(h('body'), { omitOptionalTags: true }), '', 'should omit tag without following')
10 |
11 | t.deepEqual(
12 | to(h('html', [h('body'), u('comment', 'alpha')]), {
13 | omitOptionalTags: true
14 | }),
15 | '',
16 | 'should not omit tag if followed by `comment`'
17 | )
18 |
19 | t.deepEqual(
20 | to(h('html', [h('body'), u('text', 'alpha')]), { omitOptionalTags: true }),
21 | 'alpha',
22 | 'should omit tag if not followed by `comment`'
23 | )
24 | })
25 |
--------------------------------------------------------------------------------
/packages/prettyhtml-hast-to-html/test/omission-closing-html.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var test = require('ava')
4 | var h = require('@starptech/prettyhtml-hastscript')
5 | var u = require('unist-builder')
6 | var to = require('..')
7 |
8 | test('`html` (closing)', function(t) {
9 | t.deepEqual(to(h('html'), { omitOptionalTags: true }), '', 'should omit tag without following')
10 |
11 | t.deepEqual(
12 | to(u('root', [h('html'), u('comment', 'alpha')]), {
13 | omitOptionalTags: true
14 | }),
15 | '