Skip to content

Commit

Permalink
[#233,#171][Crum/Flashcards] Insert a <br> if Images are Absent.
Browse files Browse the repository at this point in the history
This existed, but was mistakenly removed in
f9c7165, perhaps under the assumption
that the use of `<div>` tags would render the line breaks unnecessary.
It's necessary to have two line breaks, not just one, when the images
are absent; in order for the horizontal line to avoid conflict with the
"dictionary" division.
  • Loading branch information
pishoyg committed Sep 7, 2024
1 parent f0c791d commit b79af33
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions flashcards/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,23 +268,26 @@ def _explanatory_alt(path: str) -> str:
"<br>",
),
# Image.
field.aon(
'<div id="images" class="images">',
field.img(
keys=roots_col("key"),
# Although the same result can be obtained using
# `glob.glob` on each image key, we cache the paths
# because this significantly reduces the running time.
get_paths=explanatory_images.get,
fmt_args=lambda path: {
"caption": image_sensor.get_caption(path),
"id": "explanatory" + utils.stem(path),
"class": "explanatory",
"alt": _explanatory_alt(path),
},
force=False,
field.xor(
field.aon(
'<div id="images" class="images">',
field.img(
keys=roots_col("key"),
# Although the same result can be obtained using
# `glob.glob` on each image key, we cache the paths
# because this significantly reduces the running time.
get_paths=explanatory_images.get,
fmt_args=lambda path: {
"caption": image_sensor.get_caption(path),
"id": "explanatory" + utils.stem(path),
"class": "explanatory",
"alt": _explanatory_alt(path),
},
force=False,
),
"</div>",
),
"</div>",
"<br/>",
),
# Editor's notes.
field.aon(
Expand Down

0 comments on commit b79af33

Please sign in to comment.