mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 10:39:32 +01:00
fix(terminal): keep the next table record out of a last-column URL
A URL in the last column of a space-aligned table ended on a slash, so the first cell of the next record (billing-api, CHANGELOG.md, ...) passed every continuation test and was joined onto it. The alignment check that refused this only ran when other columns followed the URL. A continuation row must now start inside the URL's own cell: a gap of two or more spaces between its indent and where the URL starts on the first row means it opens an earlier column. An indented token that is a whole email address is also refused. Adds the six table shapes and the email case as negative tests at detector and provider level, and documents the rule.
This commit is contained in:
1 parent
3a4e2c996e
commit
2a90fb8118
4 files changed
+96
-5
No files matched your search
@@ -2569,12 +2569,15 @@ function findTerminalUrls(text) {
|
||||
* - the URL fragment ends on a character a wrapper breaks after
|
||||
* (`/ ? & = - _ % # + ~`); a following table column may be excluded;
|
||||
* - the next row is indented, but no further right than the column the URL
|
||||
* started in (a table cell or list item continuation, not unrelated text);
|
||||
* started in (a table cell or list item continuation, not unrelated text),
|
||||
* and no column gap lies between its indent and the URL on the first row
|
||||
* (that would be the next record of a table);
|
||||
* - that row's first token looks like URL material (contains one of
|
||||
* `% & = / ? . - _`), is not a bare number/version or list marker,
|
||||
* and is not itself a new `scheme://`, a shell prompt (`user@host:`),
|
||||
* a home path (`~/`) or an HTTP status line; without `% & = / ?`, the token
|
||||
* must finish its cell (row end or a gap of at least two spaces).
|
||||
* a home path (`~/`), an email address or an HTTP status line; without
|
||||
* `% & = / ?`, the token must finish its cell (row end or a gap of at
|
||||
* least two spaces).
|
||||
* The last rule is what stops prose such as "…/files/" + "then run it" from
|
||||
* being glued into one link.
|
||||
*
|
||||
@@ -2629,10 +2632,16 @@ function terminalUrlContinuationExtent(buffer, row, cols, maxRows) {
|
||||
/ {2,}/.test(first.text.slice(indent, last.startIndex)))
|
||||
)
|
||||
break;
|
||||
// The next row must start inside the URL's own cell: a column gap between
|
||||
// its indent and the URL on the first row means it opens an earlier
|
||||
// column (the next record of a table), not the rest of the URL.
|
||||
if (/ {2,}/.test(first.text.slice(indent, last.startIndex).trimStart())) break;
|
||||
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(token) || !/^[A-Za-z0-9%_~]/.test(token)) break;
|
||||
// A shell prompt (`user@host:~/dir$`), a home path and an HTTP status line
|
||||
// are never the rest of a URL, however much URL punctuation they carry.
|
||||
if (/^[\w.-]+@[\w.-]+:|^~\/|^HTTP\/\d/i.test(token)) break;
|
||||
// Nor is a token that is a whole email address.
|
||||
if (/^[\w.+-]+@[\w-]+(?:\.[\w-]+)+$/.test(token)) break;
|
||||
if (!/[%&=/?.\-_]/.test(token) || /^v?\d+(?:\.\d+)*(?:[-+][\w.-]+)?[.,;:!?)]?$/i.test(token)) break;
|
||||
// Hyphens, underscores and dots also occur in prose. Without stronger
|
||||
// URL punctuation, the token must finish its cell, not introduce a sentence.
|
||||
|
||||
Reference in new issue
Block a user