Skip to content

Commit b111013

Browse files
author
Markus Paulsen
committed
Paint a code span in letters, so its inside is filled rather than gone
Leaving spans untouched kept a step from looking like a blank, since a number followed by a command is filled. It only worked for the line a span starts on: a span may cross lines, and an interior line reading just a number was left exposed and reported as the blank somebody forgot. A row of pipes inside a multiline span had the same problem. Spans are now painted like everything else, in letters rather than spaces. The caller says which: masked fills with a space, because a heading inside a span must not be found, and the leftover scan fills with a letter, because it needs the shape gone rather than the content. A step becomes a number and a run of letters, which is not a blank, and an interior line becomes a run of letters, which is not one either, while a genuine bare number is untouched by any region and still is.
1 parent 89649a5 commit b111013

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

.github/scripts/CheckPullRequestTemplate.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -382,33 +382,33 @@ private static List<String> outOfOrder(List<String> required, List<String> found
382382
* in a fenced example, is not taken for a real one.
383383
*/
384384
private static String masked(String text) {
385-
return painted(text, true);
385+
return painted(text, ' ');
386386
}
387387

388388
/**
389-
* The same, except that code between backticks is left alone. A line that is a number and a
390-
* command, {@code 1. `mvn test`}, is a step somebody wrote, and painting its command out would
391-
* leave a number and a full stop, which is what an unfilled blank looks like. The same goes for
392-
* a table row whose cells hold code.
389+
* The same, except that code between backticks is painted in letters rather than spaces. A
390+
* line that is a number and a command, {@code 1. `mvn test`}, is a step somebody wrote, and
391+
* blanking its command would leave a number and a full stop, which is what an unfilled blank
392+
* looks like. A letter keeps such a line filled, whichever line of a span it falls on, and the
393+
* same holds for a table row whose cells hold code.
393394
*/
394395
private static String blocksOnly(String text) {
395-
return painted(text, false);
396+
return painted(text, 'x');
396397
}
397398

398399
/**
399-
* The text with the regions found by {@link #regions(String)} replaced by spaces of their own
400-
* length, the line breaks kept, taking code between backticks only when asked. A span always
401-
* covers what it holds, so a marker inside one is never markup, whether or not it is painted.
400+
* The text with the regions found by {@link #regions(String)} replaced by as many characters
401+
* as they held, the line breaks kept. Comments and fenced blocks become spaces; code between
402+
* backticks becomes whatever the caller asks for, since one caller needs it gone and the other
403+
* needs only its shape gone.
402404
*/
403-
private static String painted(String text, boolean spansToo) {
405+
private static String painted(String text, char spanFiller) {
404406
StringBuilder result = new StringBuilder(text);
405407
for (int[] region : regions(text)) {
406-
if (region[2] == SPAN && !spansToo) {
407-
continue;
408-
}
408+
char filler = region[2] == SPAN ? spanFiller : ' ';
409409
for (int index = region[0]; index < region[1]; index++) {
410410
if (result.charAt(index) != '\n') {
411-
result.setCharAt(index, ' ');
411+
result.setCharAt(index, filler);
412412
}
413413
}
414414
}

AGENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ template's own skeleton, a bare `1.` inside a comment, is read as a blank somebo
107107
That is wrong about a body written in good faith, and is the accepted cost of closing a
108108
hole where text hid from the length count.
109109

110-
What is not prose is found in one left-to-right walk rather than by searching for each
111-
construct separately, which is how the two settle their overlaps: a fence opening a line
112-
beats a code span left open above it, because Markdown decides blocks first, and a span
113-
covers what it holds, so a comment marker inside one is text rather than the start of a
114-
comment. It deliberately does not require checklist boxes to be ticked. It
110+
What is not prose is found in one left-to-right walk rather than by searching for comments,
111+
fenced blocks and code spans separately. That walk is what settles the overlaps between the
112+
three: a fence opening a line beats a code span left open above it because Markdown decides
113+
blocks first, and a span covers what it holds, so a comment marker inside one is text rather
114+
than the start of a comment. It deliberately does not require checklist boxes to be ticked. It
115115
re-runs when the description is edited, so a failure is fixed by editing the body rather
116116
than by pushing a commit.
117117

0 commit comments

Comments
 (0)