Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add textlint #1

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bf54f56
feat(textlint): add textlint md/txt support
azu May 7, 2017
b93b385
chore(docs): describe fork version
azu May 7, 2017
e02b375
fix(menu): hide save
azu May 7, 2017
e08e7ed
feat(textlint): update @textlint parser
azu Jan 20, 2018
3614245
feat(html): add html parser
azu Jan 20, 2018
0b673ea
Merge commit 'origin/master' into textlint
azu May 24, 2021
6920d61
update textlint@12
azu May 24, 2021
c9401c5
feat: support url storage
azu May 24, 2021
fd89044
feat: support textlint 13 and html plugin
azu Feb 5, 2023
94976d0
Merge pull request #2 from textlint/textlint-13
azu Feb 5, 2023
677f64c
Update README.md
azu Feb 5, 2023
1d6521d
Update README.md
azu Feb 5, 2023
fbec8f8
CI: add deploy
azu Feb 5, 2023
cfc5e65
CI: fix
azu Feb 5, 2023
048651c
Add renovate.json
renovate[bot] Feb 5, 2023
b6bc4b9
CI: fix build
azu Feb 5, 2023
7853375
CI: remove permission
azu Feb 5, 2023
6daf402
Update renovate.json
azu Feb 5, 2023
d898d89
CI: support Node 18
azu Feb 5, 2023
cd3681c
Merge pull request #3 from textlint/renovate/configure
azu Feb 5, 2023
dc8167e
fix(deps): update dependency @textlint/text-to-ast to v13.3.2
renovate[bot] Mar 27, 2023
2d133fe
fix(deps): update dependency @textlint/textlint-plugin-markdown to v1…
renovate[bot] Mar 27, 2023
87f45ac
Merge pull request #8 from textlint/renovate/textlint-textlint-plugin…
azu Mar 28, 2023
3fcbbf9
Merge pull request #7 from textlint/renovate/textlint-text-to-ast-13.…
azu Mar 28, 2023
85d3421
Update renovate.json
azu Jun 30, 2023
a39eda4
Update textlint to v13.3.3
renovate[bot] Jun 30, 2023
e1abb18
Merge pull request #12 from textlint/renovate/textlint
azu Jun 30, 2023
45f68ca
Update textlint to v13.4.0
renovate[bot] Nov 8, 2023
62b3440
Merge pull request #13 from textlint/renovate/textlint
azu Nov 8, 2023
2b09426
Update textlint to v14
renovate[bot] Feb 3, 2024
bd68154
Merge pull request #15 from textlint/renovate/major-textlint
azu Feb 4, 2024
be63d01
Update textlint to v14.0.1
renovate[bot] Feb 4, 2024
b3f29dc
Merge pull request #14 from textlint/renovate/textlint
azu Feb 4, 2024
2ee9141
Update textlint to v14.0.2
renovate[bot] Feb 11, 2024
6d0f8c5
Merge pull request #16 from textlint/renovate/textlint
azu Feb 11, 2024
d1bb772
Update textlint to v14.0.3
renovate[bot] Feb 17, 2024
0194fc6
Merge pull request #17 from textlint/renovate/textlint
azu Feb 17, 2024
98b1a86
fix(deps): update textlint to v14.0.4
renovate[bot] Mar 12, 2024
73fe7ab
Merge pull request #18 from textlint/renovate/textlint
azu Mar 12, 2024
f7570e4
fix(deps): update textlint to v14.0.5
renovate[bot] Aug 7, 2024
6250787
Merge pull request #19 from textlint/renovate/textlint
azu Aug 7, 2024
eb34926
fix(deps): update textlint
renovate[bot] Aug 18, 2024
b853dcf
Merge pull request #20 from textlint/renovate/textlint
azu Aug 18, 2024
9ad1527
fix(deps): update textlint to v14.3.0
renovate[bot] Oct 24, 2024
082fa0f
Merge pull request #21 from textlint/renovate/textlint
azu Oct 24, 2024
b610f50
fix(deps): update textlint to v14.4.0
renovate[bot] Dec 1, 2024
e64c8ca
Merge pull request #22 from textlint/renovate/textlint
azu Dec 1, 2024
82f74a4
fix(deps): update textlint to v14.4.2
renovate[bot] Jan 7, 2025
0db3c38
Merge pull request #23 from textlint/renovate/textlint
azu Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy

on:
push:
branches:
- textlint

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build
run: yarn install && yarn run build
working-directory: ./website
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
## AST explorer

## Fork version for textlint

This version limited for [textlint](http://textlint.github.io/ "textlint").

- [@textlint/textlint-plugin-markdown](https://github.com/textlint/textlint/tree/master/packages/%40textlint/textlint-plugin-markdown)
- [@textlint/textlint-plugin-text](https://github.com/textlint/textlint/tree/master/packages/%40textlint/textlint-plugin-text)
- [textlint-plugin-html](https://github.com/textlint/textlint-plugin-html)

Visit [https://textlint.github.io/astexplorer](https://textlint.github.io/astexplorer).

**Developer Notes**

- Deploy: use `website/deploy.sh`

------


[![Join the chat at https://gitter.im/astexplorer/Lobby](https://badges.gitter.im/astexplorer/Lobby.svg)](https://gitter.im/astexplorer/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/fkling/astexplorer.svg?branch=master)](https://travis-ci.org/fkling/astexplorer)

Expand Down
26 changes: 26 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"enabledManagers": [
"npm"
],
"packageRules": [
{
"matchPackagePatterns": [
"*"
],
"enabled": false
},
{
"groupName": "textlint",
"matchPackagePatterns": [
"textlint",
"^@textlint/",
"textlint-plugin-html"
],
"enabled": true
}
]
}
2 changes: 1 addition & 1 deletion scripts/inject-rev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# likely just out/index.html

rev=$(git rev-parse --short HEAD)
sed -i "s%@@COMMIT@@%Build: <a href='https://github.com/fkling/astexplorer/commits/$rev'>$rev</a>%" "$1"
sed -i "s%@@COMMIT@@%Build: <a href='https://github.com/textlint/astexplorer/commits/$rev'>$rev</a>%" "$1"
19 changes: 6 additions & 13 deletions website/index.ejs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>AST explorer</title>
<title>textlint AST explorer</title>
<meta charset="UTF-8">
<meta name="description" content="An online AST explorer.">
<script>
<!-- NOPE -->
window.ga = () => {}
</script>
<%= htmlWebpackPlugin.files.webpackManifest %>
</head>
<body>
Expand All @@ -19,21 +23,10 @@
and
<a href="https://webpack.js.org/">webpack</a>
|
<a href="https://github.com/fkling/astexplorer">GitHub</a>
<a href="https://github.com/textlint/astexplorer">GitHub</a>
|
<span>@@COMMIT@@</span>
</div>
</div>
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
var ID = location.hostname === 'astexplorer.net' ?
'UA-81889051-1' :
'UA-81889051-2';
ga('create', ID, 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->
</body>
</html>
18 changes: 14 additions & 4 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"eslint-plugin-require-in-package": "^1.0.3",
"exports-loader": "^0.7.0",
"file-loader": "^6.0.0",
"gh-pages": "^0.12.0",
"html-webpack-plugin": "^3.2.0",
"inline-manifest-webpack-plugin": "^4.0.1",
"js-yaml": "^3.13.1",
Expand All @@ -44,13 +45,19 @@
"@angular-eslint/template-parser": "^1.0.0",
"@angular/compiler": "^11.2.0",
"@babel/eslint-parser": "^7.12.0",
"@babel/parser": "^7.14.3",
"@babel/runtime": "^7.12.0",
"@creditkarma/thrift-parser": "^1.2.0",
"@gengjiawen/monkey-wasm": "^0.5.0",
"@glimmer/compiler": "^0.73.1",
"@glimmer/syntax": "^0.73.1",
"@humanwhocodes/momoa": "^1.0.0",
"@mdx-js/mdx": "^1.5.8",
"@textlint/kernel": "^14.0.0",
"@textlint/markdown-to-ast": "^14.0.0",
"@textlint/text-to-ast": "^14.0.0",
"@textlint/textlint-plugin-markdown": "^14.0.0",
"@textlint/textlint-plugin-text": "^14.0.0",
"@typescript-eslint/parser": "^4.1.0",
"@vue/compiler-dom": "^3.0.0-rc.10",
"@webassemblyjs/wast-parser": "^1.9.0",
Expand Down Expand Up @@ -107,6 +114,7 @@
"jscodeshift": "^0.11.0",
"json-stringify-safe": "^5.0.1",
"json-to-ast": "^2.1.0",
"json-url": "^3.0.0",
"lodash.isequal": "^4.5.0",
"luaparse": "^0.3.0",
"lucene": "^2.1.1",
Expand Down Expand Up @@ -149,6 +157,7 @@
"svelte": "^3.4.1",
"tenko": "^1.0.6",
"tern": "^0.24.3",
"textlint-plugin-html": "^1.0.0",
"traceur": "0.0.111",
"tslint": "^6.1.1",
"typescript": "^4.0.3",
Expand All @@ -166,10 +175,11 @@
"browserslist": "> 0.25%, not dead",
"scripts": {
"start": "serve -l 8080 ../out",
"build": "rimraf ../out/* && cross-env NODE_ENV=production webpack --mode=production",
"build-dev": "rimraf ../out/* && cross-env NODE_ENV=development webpack -d --mode=development",
"watch": "webpack -dw --mode=development",
"build": "rimraf ../out/* && cross-env NODE_ENV=production NODE_OPTIONS='--openssl-legacy-provider' webpack --mode=production",
"build-dev": "rimraf ../out/* && cross-env NODE_ENV=development NODE_OPTIONS='--openssl-legacy-provider' webpack -d --mode=development",
"watch": "NODE_OPTIONS='--openssl-legacy-provider' webpack -dw --mode=development",
"lint": "node_modules/eslint/bin/eslint.js src/",
"fontcustom": "fontcustom compile ./fontcustom/input-svg/ --config=./fontcustom/config.yml"
"fontcustom": "fontcustom compile ./fontcustom/input-svg/ --config=./fontcustom/config.yml",
"deploy": "npm run build && gh-pages -d ../out"
}
}
7 changes: 4 additions & 3 deletions website/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import {createStore, applyMiddleware, compose} from 'redux';
import {canSaveTransform, getRevision} from './store/selectors';
import {loadSnippet} from './store/actions';
import {render} from 'react-dom';
import * as gist from './storage/gist';
import * as parse from './storage/parse';
import * as urlStore from './storage/urlStore';
// import * as gist from './storage/gist';
// import * as parse from './storage/parse';
import StorageHandler from './storage';
import '../css/style.css';
import parserMiddleware from './store/parserMiddleware';
Expand Down Expand Up @@ -73,7 +74,7 @@ const AppContainer = connect(
)(App);

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const storageAdapter = new StorageHandler([gist, parse]);
const storageAdapter = new StorageHandler([urlStore]);
const store = createStore(
astexplorer,
revive(LocalStorage.readState()),
Expand Down
12 changes: 4 additions & 8 deletions website/src/parsers/html/codeExample.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<!DOCTYPE html>
<html>
<h1>Title</h1>

<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>

</html>
<div>
<p>This is a paragraph.</p>
</div>
5 changes: 2 additions & 3 deletions website/src/parsers/html/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'codemirror/mode/htmlmixed/htmlmixed';
import 'codemirror/mode/htmlembedded/htmlembedded';

export const id = 'htmlmixed';
export const id = 'html';
export const displayName = 'HTML';
export const mimeTypes = ['text/html'];
export const fileExtension = 'html';
29 changes: 29 additions & 0 deletions website/src/parsers/html/textlint-plugin-html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import defaultParserInterface from '../utils/defaultParserInterface';

import pkg from 'textlint-plugin-html/package.json';

const ID = 'textlint:html';

export default {
...defaultParserInterface,
id: ID,
displayName: "textlint-plugin-html",
version: pkg.version,
homepage: pkg.homepage,
locationProps: new Set(['loc', 'range']),

loadParser(callback) {
require(['textlint-plugin-html/module/html-to-ast'], callback);
},

parse(parser, text) {
console.log("parser", parser);
return parser.parse(text);
},

opensByDefault(node, key) {
return key === 'rules';
},

_ignoredProperties: new Set(['location'])
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = function (context) {
const {Syntax, RuleError, report, getSource} = context;
return {
[Syntax.Str](node){
report(node, new Error("error"));
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import compileModule from '../../../utils/compileModule';
import pkg from '@textlint/kernel/package.json';

const ID = 'textlint-plugin-html';

function formatResults(results, code) {
const format = (message) => {
return formatResult(message, code);
};
return results.messages.length === 0
? 'Lint rule not fired.'
: results.messages.map(format).join('').trim();
}

function formatResult(result, code) {
const pointer = '-'.repeat(result.column - 1) + '^';
console.log(code.split('\n')[result.line - 1]);
return `
| ${result.message} (at ${result.line}:${result.column})
${code.split('\n')[result.line - 1] || ''}
| ${pointer}
`;
}

export default {
id: ID,
displayName: ID,
version: pkg.version,
homepage: pkg.homepage,

defaultParserID: 'textlint-plugin-html',

loadTransformer(callback) {
require(['@textlint/kernel', "textlint-plugin-html"], ({ TextlintKernel }, plugin) => {
callback({ TextlintKernel, plugin });
})
},

transform({ TextlintKernel, plugin }, transformCode, code) {
const kernel = new TextlintKernel();
const rule = compileModule( // eslint-disable-line no-shadow
transformCode
);
return kernel.lintText(code, {
rules: [{
ruleId: "astExplorerRule",
rule: rule,
options: true
}],
plugins: [{
pluginId: "html",
plugin: plugin,
options: true
}],
ext: ".html"
}).then(result => {
return formatResults(result, code);
});
},
};

11 changes: 5 additions & 6 deletions website/src/parsers/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const localRequire = require.context('./', true, /^\.\/(?!utils|transpilers)[^/]+\/(transformers\/([^/]+)\/)?(codeExample\.txt|[^/]+?\.js)$/);

// const localRequire = require.context('./', true, /^\.\/(?!utils)[^/]+\/(transformers\/([^/]+)\/)?(codeExample\.txt|[^/]+?\.js)$/);
const localRequire = require.context('./', true, /^\.\/(textlint-.*?)\/(transformers\/([^/]+)\/)?(codeExample\.txt|[^/]+?\.js)$/);
function interopRequire(module) {
return module.__esModule ? module.default : module;
return module.__esModule ? module.default : module;
}

const files =
localRequire.keys()
.map(name => name.split('/').slice(1));

const categoryByID = {};
const parserByID = {};
const transformerByID = {};
Expand All @@ -24,7 +23,6 @@ export const categories =
.filter(name => name[1] === 'index.js')
.map(([catName]) => {
let category = localRequire(`./${catName}/index.js`);

categoryByID[category.id] = category;

category.codeExample = interopRequire(localRequire(`./${catName}/codeExample.txt`))
Expand Down Expand Up @@ -59,7 +57,8 @@ export const categories =
});

export function getDefaultCategory() {
return categoryByID.javascript;
return categoryByID["markdown"];
// return categoryByID.javascript;
}

export function getDefaultParser(category = getDefaultCategory()) {
Expand Down
5 changes: 5 additions & 0 deletions website/src/parsers/textlint-html/codeExample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Title</h1>

<div>
<p>This is a paragraph.</p>
</div>
5 changes: 5 additions & 0 deletions website/src/parsers/textlint-html/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'codemirror/mode/htmlembedded/htmlembedded';

export const id = 'html';
export const displayName = 'HTML';
export const mimeTypes = ['text/html'];
Loading
Loading