-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
lesson_check.py: harden single-line image/link pattern #597
lesson_check.py: harden single-line image/link pattern #597
Conversation
This change hardens the pattern that matches single-line image or link: 1. It extends the pattern to be matched in a heading 2. It allows the line to contain {: ...} customizations 3. It allows the line to end with \
@jhlegarreta, here is the list of "long lines" that I get for your lesson with this change:
The lines you were concerned about seems to be no longer reported as "too long". Line 190 in Line 458 in the same file was triggering the "Line too long" warning again due to |
I'm going to merge this one as all the checks have passed and I'm pretty confident it addresses the issues reported. @jhlegarreta, let me know if there is some other extra syntax that you use (or would like to use) for links/images that I haven't captured in this regex. |
@maxim-belkin thanks for the explanation in the commit message, and your time and effort ! The new changeset does fix the lines I pointed to 👍. The relevant part of my There are still three instances that are not handled correctly: I am not sure in which ways those lines are different from other instances. I have noticed that they have a trailing whitespace, and they only contain a link, but apart from that I see no other noticeable different to the many similar instances in that file. Some other lines, e.g. I grant that trailing whitespaces should always be trimmed, and that we should configure our tools to do that. If you conclude that the reason behind the above lines not being handled correctly are the trailing whitespaces, I'll remove them all from the file. However, note that I went ahead and removed them locally (only for the pointed lines), then passed the check again and the warnings are still there. So there is still something that is elusive to us. |
All of these lines are images and they have the following parts that don't match the pattern:
What's interesting (at least, I've never seen this done before) is that you treat images' alt text as part of the corresponding paragraphs. I think that due to accessibility considerations paragraphs should refer to images rather than use them this way.
Line 37 is an image-only line, doesn't have neither a period nor comma at the end, so it matches the pattern and is, therefore, skipped by this check.
Two trailing whitespaces force line breaks in Markdown - see 740773a (PR #522), so you should keep them, if that's what you use them for. |
Again, thanks for having had a look at this @maxim-belkin.
Thanks for identifying the reason. As I see it, having a punctuation mark at the end should not be a reason to miss these cases. But let me know if I'm wrong.
Not sure if "treating images' alt text as part of the corresponding paragraphs" was intended. I do not see its effects or how this can be done otherwise. Alt texts were introduced so that all images, even the inline ones, have a caption when being listed in So not sure how this comment and the above are intertwined so that we can fix the cases.
The intention was not to force line breaks; maybe it was just the way the contributor added the text. But I did not know about the two trailing whitespaces. Interesting. Thanks. |
Currently, images in the lessons are displayed as block elements (line 256 below), meaning that they start on new lines and take up the whole width of the page: Lines 255 to 259 in af7efa5
Because of that, text that follows immediately after an image in Markdown ends up on a new line in HTML, see the screenshot below: So, all of that was to say that our lessons don't currently support inline images. But they could and, probably, should. I'll submit a PR proposing this and another PR to allow punctuation marks after links and images because it seems logical to be able to use punctuation marks after the inline images. |
Thanks for having had a close look at this 💯.
I see. Yes, I had noticed that what we pretended to be inline images were in fact not so. I did not investigate further, though. Now I know the reason 👍.
Excellent ! Both endeavors make sense to me as separate PRs. They are by no means urgent. At least we now know better the reasons behind. |
@jhlegarreta, I submitted PR #599 that allows up to 3 non-word characters to appear on the same line before and after a link or an image. I chose 3 characters as a middle ground between "too few" and "too many". I think it's OK to allow non-word characters in the beginning of the image because I noticed that in the carpentries-incubator/SDC-BIDS-dMRI lesson there is at least one case where an image is surrounded by parentheses. |
Thanks @maxim-belkin ! Looks like our
vs. without the changes in the PR:
|
This change hardens the pattern that matches single-line
image or link:
Fixes #591