Skip to content

Commit 399f54a

Browse files
committed
feat: add altText as a data attribute to rendered span
1 parent 1371659 commit 399f54a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/expandableImages.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@ module.exports = function expandableImages() {
1919
link.alt &&
2020
link.alt.endsWith("expandable")
2121
) {
22+
const altText = link.alt.replace(/expandable$/, "").trim()
2223
link.type = "span";
2324
link.data = {
2425
hName: "span",
2526
hProperties: {
2627
dataUrl: link.url,
28+
dataAlt: altText,
2729
className: "expandable-image"
2830
}
2931
};
3032
link.children = [
3133
{
3234
type: "text",
33-
value: link.alt.substr(0, -1 * "expandable".length).trim()
35+
value: altText
3436
}
3537
];
3638
}

test/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ schema.attributes.img.push('height', 'width');
2121

2222
// Add support for expandableImages
2323
schema.tagNames.push('span');
24-
schema.attributes.span = ['dataUrl', 'className'];
24+
schema.attributes.span = ['dataUrl', 'dataAlt', 'className'];
2525

2626
// Add support for inline styles (gross)
2727
// TODO replace all inline styles in our curriculum content with

0 commit comments

Comments
 (0)