Skip to content

Commit

Permalink
Rewrite html plugin (#23)
Browse files Browse the repository at this point in the history
Rewrite ALL!!!

## Breaking Changes

- Require [textlint v13.0.0](https://textlint.github.io/blog/2023/01/27/textlint-13.html)+
  - html plugin is written in Pure ESM
- Require Node.js 16+
- Convert JavaScript to TypeScript

## Features

- use [rehype](https://github.com/rehypejs/rehype#readme) instead of hast
- support `<h1>` ... `<h6>`'s `levels`
- support `<ul>` and `<ol>`
- support `<img />`'s `alt` and `title`
- support `<a>`'s `title`

## Bug Fixes

fix #19 
fix textlint-ja/textlint-rule-no-synonyms#4
fix #2 

close #15 - It looks like rule implementation issue https://github.com/KeitaMoromizato/textlint-rule-max-appearence-count-of-words/blob/master/src/max-appearence-count-of-words.js

## Testings

- New snapshot testing
  - Tree Dump view for human


📝 Welcome to contribute! We looking for new maintainer! 

- #21
  • Loading branch information
azu authored Jan 29, 2023
1 parent 4435db6 commit 4e442fa
Show file tree
Hide file tree
Showing 166 changed files with 26,480 additions and 10,930 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

26 changes: 21 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,31 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12, 14]
node-version: [16,18]
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm install
run: yarn install
- name: Test
run: npm test
run: yarn test
example:
name: "Run Example"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install
run: yarn install
working-directory: ./example
- name: Test
run: yarn test
working-directory: ./example
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/lib
/module
### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore

# Logs
Expand Down
10 changes: 6 additions & 4 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"timeout": "5000",
"require": [
"@babel/register"
]
"$schema": "https://json.schemastore.org/mocharc",
"loader": "ts-node/esm",
"spec": [
"test/**/*.{js,ts}"
],
"timeout": 10000
}
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

Add HTML support for [textlint](https://github.com/textlint/textlint "textlint").

What is textlint plugin? Please see https://github.com/textlint/textlint/blob/master/docs/plugin.md

What is textlint plugin? Please see <https://github.com/textlint/textlint/blob/master/docs/plugin.md>

## Installation

npm install textlint-plugin-html

Requirements:

- textlint v13+

## Default supported extensions

- `.html`
Expand Down Expand Up @@ -52,6 +55,16 @@ For example, if you want to treat `.custom-ext` as html, put following config to

npm test

## Development

If you update snapshot, please run `npm run updateSnapshot`.

### Add new test case

1. add new fixture file to `test/ast-test-case/<test-case-name>/index.html`
2. npm run updateSnapshot
3. check outputs

## Contributing

1. Fork it!
Expand Down
30 changes: 30 additions & 0 deletions example/.github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
changelog:
exclude:
labels:
- 'Type: Meta'
- 'Type: Question'
- 'Type: Release'

categories:
- title: Security Fixes
labels: ['Type: Security']
- title: Breaking Changes
labels: ['Type: Breaking Change']
- title: Features
labels: ['Type: Feature']
- title: Bug Fixes
labels: ['Type: Bug']
- title: Documentation
labels: ['Type: Documentation']
- title: Refactoring
labels: ['Type: Refactoring']
- title: Testing
labels: ['Type: Testing']
- title: Maintenance
labels: ['Type: Maintenance']
- title: CI
labels: ['Type: CI']
- title: Dependency Updates
labels: ['Type: Dependencies', "dependencies"]
- title: Other Changes
labels: ['*']
11 changes: 11 additions & 0 deletions example/.textlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": [
"html"
],
"filters": {},
"rules": {
"preset-ja-technical-writing": {
"ja-no-mixed-period": false
}
}
}
20 changes: 20 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"private": true,
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "textlint test/ -f pretty-error || exit 0"
},
"workspaces": [
"../"
],
"author": "azu",
"license": "MIT",
"devDependencies": {
"textlint": "^13.0.5",
"textlint-rule-preset-ja-technical-writing": "^7.0.0",
"textlint-plugin-html": "^0.3.0"
}
}
Loading

0 comments on commit 4e442fa

Please sign in to comment.