-
-
Notifications
You must be signed in to change notification settings - Fork 98
To modify the "1" matched in the regular expression to match all inte… #697
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
Conversation
…gers and decimals in Infinite issue The original regex is designed to match patterns like calc(infinity * 1px) or calc(infinity * 1rpx). When using a custom design width (e.g., 390 design units), Taro automatically calculates the ratio relative to the standard mini-program design width of 750. This results in formats like calc(infinite * 1.91rpx). However, the original regular expression can only handle scenarios with the 750 design width, causing the rounded-full replacement to fail. It is now proposed to modify the regex to match all numeric cases, thereby expanding the range of applicable scenarios. * (\d+\.?\d*|\.\d+) is used to match integers or decimals: * \d+\.?\d* : Matches integers with one or more digits, which can be followed by a decimal point and zero or more decimal digits (e.g., 1, 1., 1.2). * |\.\d+ : Alternatively, matches pure decimals starting with a decimal point (e.g., .5). This regular expression can match the following formats: * calc(infinity * 5px) * calc(infinity * 3.14rpx) * calc(infinity * .6px) * calc(infinity * 100.px)
|
评审员指南 (在小型 PR 上折叠)评审员指南更新了 CSS 后处理插件中的正则表达式,以匹配
|
| 更改 | 详情 | 文件 |
|---|---|---|
| 扩展正则表达式以匹配所有数值乘数 |
|
packages/postcss/src/plugins/post.ts |
可能相关的问题
- There is a problem with the WeChat Mini Program simulator's support for "infinite". Is there any way to replace it during the processing? #694: 此 PR 修改了正则表达式,以正确替换任意 N 的
calc(infinity * Npx),直接解决了模拟器中rounded-full的“无限”属性不生效的问题。
提示和命令
与 Sourcery 互动
- 触发新评审: 在拉取请求中评论
@sourcery-ai review。 - 继续讨论: 直接回复 Sourcery 的评审评论。
- 从评审评论生成 GitHub Issue: 回复 Sourcery 的评审评论,要求其创建 Issue。您也可以回复评审评论并输入
@sourcery-ai issue来创建 Issue。 - 生成拉取请求标题: 随时在拉取请求标题的任意位置写入
@sourcery-ai即可生成标题。您也可以在拉取请求中评论@sourcery-ai title来随时(重新)生成标题。 - 生成拉取请求摘要: 随时在拉取请求正文的任意位置写入
@sourcery-ai summary即可在您想要的位置生成 PR 摘要。您也可以在拉取请求中评论@sourcery-ai summary来随时(重新)生成摘要。 - 生成评审员指南: 在拉取请求中评论
@sourcery-ai guide来随时(重新)生成评审员指南。 - 解决所有 Sourcery 评论: 在拉取请求中评论
@sourcery-ai resolve来解决所有 Sourcery 评论。如果您已经处理了所有评论并且不想再看到它们,这会很有用。 - 关闭所有 Sourcery 评审: 在拉取请求中评论
@sourcery-ai dismiss来关闭所有现有 Sourcery 评审。如果您想重新开始一个新评审,这特别有用——别忘了评论@sourcery-ai review来触发新评审!
自定义您的体验
访问您的 仪表板 以:
- 启用或禁用评审功能,例如 Sourcery 生成的拉取请求摘要、评审员指南等。
- 更改评审语言。
- 添加、删除或编辑自定义评审说明。
- 调整其他评审设置。
获取帮助
Original review guide in English
Reviewer's guide (collapsed on small PRs)
Reviewer's Guide
Updated the regex in the CSS post-processing plugin to match any integer or decimal multiplier in calc(infinity * …px/rpx) instead of a fixed “1”, allowing proper handling of custom design widths.
Class diagram for updated regex handling in postcssWeappTailwindcssPostPlugin
classDiagram
class postcssWeappTailwindcssPostPlugin {
+processDeclaration(decl)
}
class Declaration {
+value: string
}
postcssWeappTailwindcssPostPlugin --> Declaration: processes
%% Highlight the updated regex usage
class postcssWeappTailwindcssPostPlugin {
+if value matches /calc(\s*infinity\s*\*\s*(\d+\.?\d*|\.\d+)r?px/)
+set value = "9999px"
}
Flow diagram for updated CSS value replacement logic
flowchart TD
A["CSS Declaration with value"] --> B["Check if value matches /calc(\s*infinity\s*\*\s*(\d+\.?\d*|\.\d+)r?px/)" ]
B -- Yes --> C["Replace value with '9999px'"]
B -- No --> D["Leave value unchanged"]
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Expand regex to match all numerical multipliers |
|
packages/postcss/src/plugins/post.ts |
Possibly linked issues
- There is a problem with the WeChat Mini Program simulator's support for "infinite". Is there any way to replace it during the processing? #694: The PR modifies the regex to correctly replace
calc(infinity * Npx)for any N, which directly solves the issue of the 'infinite' property not taking effect in the simulator for rounded-full.
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
✅ Deploy Preview for ice-tw canceled.
|
|
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.
你好 - 我已经审查了你的更改,它们看起来很棒!
请帮助我更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English
Hey there - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #697 +/- ##
=======================================
Coverage 90.62% 90.62%
=======================================
Files 75 75
Lines 5695 5695
Branches 664 672 +8
=======================================
Hits 5161 5161
Misses 534 534 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|



To modify the "1" matched in the regular expression to match all integers and decimals in Infinite issue #695
The original regex is designed to match patterns like calc(infinity * 1px) or calc(infinity * 1rpx).
When using a custom design width (e.g., 390 design units), Taro automatically calculates the ratio relative to the standard mini-program design width of 750. This results in formats like calc(infinite * 1.91rpx). However, the original regular expression can only handle scenarios with the 750 design width, causing the rounded-full replacement to fail.
It is now proposed to modify the regex to match all numeric cases, thereby expanding the range of applicable scenarios.
(\d+\.?\d*|\.\d+)is used to match integers or decimals:\d+\.?\d*: Matches integers with one or more digits, which can be followed by a decimal point and zero or more decimal digits (e.g., 1, 1., 1.2).|\.\d+: Alternatively, matches pure decimals starting with a decimal point (e.g., .5).This regular expression can match the following formats:
calc(infinity * 5px)calc(infinity * 3.14rpx)calc(infinity * .6px)calc(infinity * 100.px)Sourcery 摘要
增强:
Original summary in English
Summary by Sourcery
Enhancements: