-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Rewrite html plugin #23
Conversation
Document(root) | ||
html(element) | ||
head(element) | ||
title(element) | ||
Str(text) | ||
Str(text) | ||
body(element) | ||
Str(text) | ||
Paragraph(element) | ||
span(element) | ||
Str(text) | ||
Str(text) | ||
Paragraph(element) | ||
span(element) | ||
span(element) | ||
Str(text) | ||
span(element) | ||
Str(text) | ||
Str(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<html>
<head><title>テスト</title></head>
<body>
<p><span>こんにちは、世界。</span></p>
<p><span><span>こんにちは、</span><span>世界。</span></span></p>
</body>
</html>
to be this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
textlint-util-to-string can get "こんにちは、世界。"
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "textlint test/ -f pretty-error || exit 0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example test
if (txtNode.type === "Link") { | ||
if (txtNode.properties.href !== undefined) txtNode.url = txtNode.properties.href; | ||
if (txtNode.properties.title !== undefined) txtNode.title = txtNode.properties.title; | ||
} else if (txtNode.type === "Image") { | ||
if (txtNode.properties.alt !== undefined) txtNode.alt = txtNode.properties.alt; | ||
if (txtNode.properties.title !== undefined) txtNode.title = txtNode.properties.title; | ||
if (txtNode.properties.src !== undefined) txtNode.url = txtNode.properties.src; | ||
} else if (txtNode.type === "Header") { | ||
const depth = Number(txtNode.tagName.slice(1)) as TxtHeaderNode["depth"]; | ||
if (depth > 0 && depth < 7) txtNode.depth = depth; | ||
} else if (txtNode.type === "List") { | ||
if (txtNode.tagName === "ul") { | ||
txtNode.ordered = false; | ||
} else if (txtNode.tagName === "ol") { | ||
txtNode.ordered = true; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mapping properties
} else { | ||
// other case, return original tagName | ||
return node.tagName; | ||
} | ||
} else if (node.type === "doctype") { | ||
return "doctype"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fix #19
html
to be html
Previously, html
to be Html
. This cause textlint-ja/textlint-rule-no-synonyms#4
Document(root) | ||
doctype(doctype) | ||
html(element) | ||
head(element) | ||
title(element) | ||
Str(text) | ||
Str(text) | ||
body(element) | ||
Paragraph(element) | ||
Str(text) | ||
Str(text) | ||
table(element) | ||
Str(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tree dump
Rewrite ALL!!!
Breaking Changes
Features
<h1>
...<h6>
'slevels
<ul>
and<ol>
<img />
'salt
andtitle
<a>
'stitle
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
📝 Welcome to contribute! We looking for new maintainer!