You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: push.pl
+16-5Lines changed: 16 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,9 @@
15
15
use Term::UI;
16
16
use Term::ReadLine;
17
17
18
-
my$hubLengthLimit = 25_000;
18
+
require bytes; # this is not recommended, but we *only* use "bytes::length" from it to determine whether we need to do a more correct conversion to/from bytes for trimming (see $hubLengthLimit and usages)
19
+
20
+
my$hubLengthLimit = 25_000; # NOTE: this is *bytes*, not characters 🙃
19
21
my$githubBase = 'https://github.com/docker-library/docs/tree/master'; # TODO point this at the correct "dist-xxx" branch based on "namespace"
# ... if that doesn't do the trick, then do our older naïve description trimming (respecting utf8; see https://www.perlmonks.org/?node_id=1230659 and https://perldoc.perl.org/utf8)
# (deal with the potential of "bytes::substr" here cutting us in the middle of a unicode glyph, which is arguably a much worse problem than the markdown cutting described below 😬 again, see https://www.perlmonks.org/?node_id=1230659)
102
+
$trimmedText =~ s/(?:
103
+
[\xC0-\xDF]
104
+
| [\xE0-\xEF] [\x80-\xBF]?
105
+
| [\xF0-\xF7] [\x80-\xBF]{0,2}
106
+
)\z//x;
107
+
utf8::decode($trimmedText);
97
108
98
109
# adding the "ending note" (https://github.com/docker/hub-feedback/issues/2220) is a bit more complicated as we have to deal with cutting off markdown ~cleanly so it renders correctly
99
110
# TODO deal with "```foo" appropriately (so we don't drop our note in the middle of a code block) - the Hub's current markdown rendering (2022-04-07) does not auto-close a dangling block like this, so this isn't urgent
0 commit comments