-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: fix header escaping regression (Issue #22065) #22084
Conversation
tools/doc/html.js
Outdated
@@ -198,7 +198,8 @@ function preprocessElements({ filename }) { | |||
heading.children = [{ | |||
type: 'text', | |||
value: file.contents.slice( | |||
position.start.offset, position.end.offset), | |||
position.start.offset, position.end.offset) | |||
.replace(/\\.{1}/g, (match) => match[1]), |
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.
Maybe just:
.replace(/\\(?=.)/g, ''),
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.
Or, if we need to exclude escaped escapes:
.replace(/\\(?=[^\\])/g, ''),
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.
jslint doesn't accept .replace(/\\(?=.)/g, ''),
:
/Users/rubys/git/node/tools/doc/html.js
202:29 error Unescaped dot character in regular expression node-core/no-unescaped-regexp-dot
I want to include escaped escapes.
Finally, lookahead isn't appropriate here. If we have an escaped escape, I want to emit a single backslash and then to not consider that backslash as an escape character. Consider four escapes in a row, the desired result would be two backslashes:
> "\\\\\\\\".replace(/\\(?=.)/g, '').length
1
> "\\\\\\\\".replace(/\\.{1}/g, (match) => match[1]).length
2
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.
What about .replace(/\\(.{1})/g, '$1'),
? Whould it be simpler and faster then function call and string index access?
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.
BTW, we can disable linter rule for a line to simplify RegExp, but I am not sure what is more confusing:
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
.replace(/\\./g, (match) => match[1]),
Not sure what is wrong with CI. Is it infrastructural fails? |
Somebody either changed the version of Between the two, I would say that changing the build script seems considerably more likely. The second slash just looks outright wrong. Perhaps they meant to have a backslash escaping the next backslash so that they shell would pass |
This comment has been minimized.
This comment has been minimized.
Looks to be a real failure:
https://ci.nodejs.org/job/node-test-commit-linuxone/3483/nodes=rhel72-s390x/consoleFull |
tools/doc/html.js
Outdated
@@ -198,7 +198,8 @@ function preprocessElements({ filename }) { | |||
heading.children = [{ | |||
type: 'text', | |||
value: file.contents.slice( | |||
position.start.offset, position.end.offset), | |||
position.start.offset, position.end.offset) | |||
.replace(/\\(.{1})/g, '$1') |
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.
Missing trailing comma?
Node.js Collaborators, please, add 👍 here if you approve fast-tracking. |
It seems we have one more similar regression case: HTML entities verbatim rendering: Not sure if this should be fixed in this PR or in a new one. |
@rubys ... just a nit the prefix for the commit message here should be Also, just as a convention, it is helpful to include a |
My pull request for https://www.npmjs.com/package/mdast-util-to-hast has been accepted. Updating to the latest version of this dependency should fix everything. In fact, I should be able to back out some of the work that is currently committed. I'll run some tests and see what needs to be done from there. |
@rubys ... is this ready to go? |
@jasnell: this PR is an accumulated set of workarounds to a remark bug, it certainly can go in now, but will all need to be backed out when these pull requests land: #22140 (comment) |
Preferred long term fix can be found at: nodejs#22140
My read is that the freebsd failure is unrelated. Unless there are any objections, I'll land this PR tomorrow. |
quick fix for #22065 Preferred long term fix can be found at: #22140 PR-URL: #22084 Fixes: #22065 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Landed in 59f8276 |
quick fix for #22065 Preferred long term fix can be found at: #22140 PR-URL: #22084 Fixes: #22065 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Remove backslashes in headers.
Fixes: #22065
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes