Skip to content

Commit

Permalink
Merge pull request #56 from posthtml/feat/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin authored Feb 26, 2024
2 parents 10512c2 + 685600c commit 9249cc5
Show file tree
Hide file tree
Showing 19 changed files with 7,414 additions and 11,423 deletions.
3 changes: 0 additions & 3 deletions .c8rc

This file was deleted.

15 changes: 0 additions & 15 deletions .clintonrc.json

This file was deleted.

18 changes: 18 additions & 0 deletions .eslintrc
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"
}
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
47 changes: 18 additions & 29 deletions .github/workflows/nodejs.yml
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
7 changes: 0 additions & 7 deletions .huskyrc

This file was deleted.

4 changes: 0 additions & 4 deletions .lintstagedrc

This file was deleted.

File renamed without changes.
File renamed without changes.
82 changes: 82 additions & 0 deletions README.md
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.
Loading

0 comments on commit 9249cc5

Please sign in to comment.