-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat(api): add <p>
and <a>
and <br>
elements
#5
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5 +/- ##
==========================================
- Coverage 84.07% 83.13% -0.95%
==========================================
Files 10 10
Lines 2261 2324 +63
Branches 107 119 +12
==========================================
+ Hits 1901 1932 +31
- Misses 358 390 +32
Partials 2 2
|
<p>
and <a>
elements<p>
and <a>
and <br>
elements
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.
LGTM
这个 PR 和下版本的一个更改冲突了。我先合了 PR,等之后再来写单测和 review 吧。 |
<p>
and <a>
and <br>
elements<p>
and <a>
and <br>
elements
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.
normalize()
里使用 reduce()
很帅,a
元素没问题了,不过 br
和 p
元素还是有点小问题。我加了几个单测,有谁愿意看看的话之后可以看一下(稍微有点难)。
https://github.com/chrononeko/chronocat/runs/23502779980
有打算解决单测的话,写好代码之后可以新开 PR。
case 'br': { | ||
// 换行 | ||
if (this.isEndLine) { | ||
this.children.push(r.text('\n')) | ||
} | ||
this.isEndLine = false | ||
return | ||
} | ||
|
||
case 'p': { | ||
// 文本段落 | ||
if (this.isEndLine) { | ||
this.children.push(r.text('\n')) | ||
} | ||
await this.render(children) | ||
this.isEndLine = true | ||
return | ||
} |
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.
br
和 p
还是有点小问题
Not tested (don't know how to test)