Comments (1)
A simple pattern can be used to group similar rules:
export const rules = [
// Table
{
match: ({ name }) => {
const tableTags = [
'table', 'colgroup', 'col', 'thead', 'tbody', 'tr', 'th', 'td'
]
return tableTags.includes(name)
},
update: node => Promise.resolve({ node })
},
// Text
{
match: ({ type }) => type === 'text',
update: node => Promise.resolve({ node })
},
{
match: ({ name }) => {
const textTags = [
'p', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'strong', 'em', 'br'
]
return textTags.includes(name)
},
update: node => Promise.resolve({ node })
},
{
match: ({ name }) => name === 'a',
update: node => Promise.resolve({ node })
},
// List
{
match: ({ name }) => {
const listTags = ['ul', 'ol', 'li']
return listTags.includes(name)
},
update: node => Promise.resolve({ node })
}
]
Let's see if this is sufficient.
P.S. We're solving a question similar to iptables
, some ideas may be borrowed from there.
from bumpover.
Related Issues (20)
- Making `result.action` optional HOT 1
- Intuitive approach running examples HOT 1
- Add test cases to cover common scenarios HOT 1
- Expose full API in documentation HOT 1
- Add UMD build HOT 1
- Integrate CI test coverage HOT 1
- Provide consistent error format
- Handle errors thrown by serializer HOT 1
- Preparation for debut HOT 1
- Error visiting wrong `childKey`
- Best practise writing async tests
- Error using CommonJS build
- Handler for unmatched nodes
- Empty JSON data not serialized
- Returning result from `rule.struct`
- Simplify promise invoking
- Add handler before node visited
- Add module key
- Error using XMLBumpover in live demo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bumpover.