-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from posthtml/feat/updates
- Loading branch information
Showing
19 changed files
with
7,414 additions
and
11,423 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 2020 | ||
}, | ||
"rules": { | ||
"indent": [2, 2, {"SwitchCase": 1}], | ||
"quotes": [2, "single"], | ||
"linebreak-style": [2, "unix"], | ||
"camelcase": [2, {"properties": "always"}], | ||
"brace-style": [2, "1tbs", {"allowSingleLine": true}] | ||
}, | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"browser": false | ||
}, | ||
"extends": "eslint:recommended" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: npm | ||
directory: "/" | ||
schedule: | ||
interval: weekly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,28 @@ | ||
name: Actions Status | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: build | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
types: [opened, synchronize] | ||
branches: | ||
- master | ||
env: | ||
CI: true | ||
|
||
jobs: | ||
run: | ||
name: Node ${{ matrix.node }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: [10, 12, 14] | ||
os: [ubuntu-latest] | ||
node-version: [16, 18, 20] | ||
|
||
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 | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm test | ||
env: | ||
CI: true |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<div align="center"> | ||
<img width="150" height="150" alt="PostHTML" src="https://posthtml.github.io/posthtml/logo.svg"> | ||
<h1>PostCSS Plugin</h1> | ||
<p>Use <a href="https://github.com/postcss/postcss/">PostCSS</a> with PostHTML</p> | ||
|
||
[![Version][npm-version-shield]][npm] | ||
[![Build][github-ci-shield]][github-ci] | ||
[![License][license-shield]][license] | ||
[![Downloads][npm-stats-shield]][npm-stats] | ||
</div> | ||
|
||
## Install | ||
|
||
```bash | ||
npm i -D posthtml-postcss | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
const { readFileSync } = require('fs') | ||
|
||
const posthtml = require('posthtml') | ||
const postcss = require('posthtml-postcss') | ||
|
||
const postcssPlugins = [] | ||
const postcssOptions = {} | ||
const filterType = /^text\/css$/ | ||
|
||
const filePath = `${__dirname}/index.html` | ||
const html = readFileSync(filePath, 'utf8') | ||
|
||
posthtml([ postcss(postcssPlugins, postcssOptions, filterType) ]) | ||
.process(html, { from: filePath }) | ||
.then((result) => console.log(result.html)) | ||
``` | ||
|
||
If you don't pass arguments to `posthtml-postcss`, it will use your project's PostCSS configuration (see [`postcss-load-config`](https://www.npmjs.com/package/postcss-load-config)). | ||
|
||
Notice that we're setting the option `from` when calling `process`. `posthtml-postcss` forwards this to PostCSS, which is useful for syntax error messages. (`postcss-cli` and `gulp-posthtml` are setting `from` automatically.) | ||
|
||
## Example | ||
|
||
```js | ||
const posthtml = require('posthtml') | ||
const postcss = require('posthtml-postcss') | ||
|
||
const postcssPlugins = [ | ||
require('autoprefixer')({ browsers: ['last 2 versions'] }) | ||
] | ||
const postcssOptions = {} | ||
const filterType = /^text\/css$/ | ||
|
||
const html = ` | ||
<style>div { display: flex; }</style> | ||
<div style="display: flex;">Text</div> | ||
` | ||
|
||
posthtml([ postcss(postcssPlugins, postcssOptions, filterType) ]) | ||
.process(html) | ||
.then((result) => console.log(result.html)) | ||
``` | ||
|
||
Output: | ||
|
||
```html | ||
<style> | ||
div { display: -webkit-flex;display: -ms-flexbox;display: flex; } | ||
</style> | ||
<div style="display: -webkit-flex;display: -ms-flexbox;display: flex;"> | ||
Text | ||
</div> | ||
``` | ||
|
||
[npm]: https://www.npmjs.com/package/posthtml-postcss | ||
[npm-version-shield]: https://img.shields.io/npm/v/posthtml-postcss.svg | ||
[npm-stats]: https://npm-stat.com/charts.html?package=posthtml-postcss | ||
[npm-stats-shield]: https://img.shields.io/npm/dt/posthtml-postcss.svg | ||
[github-ci]: https://github.com/posthtml/posthtml-postcss/actions/workflows/nodejs.yml | ||
[github-ci-shield]: https://github.com/posthtml/posthtml-postcss/actions/workflows/nodejs.yml/badge.svg | ||
[license]: ./LICENSE | ||
[license-shield]: https://img.shields.io/npm/l/posthtml-postcss.svg |
File renamed without changes.
Oops, something went wrong.