Skip to content
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

Add indentation to hidden counter text #604

Merged
merged 8 commits into from
Aug 27, 2024
Prev Previous commit
Next Next commit
Update fixture to include new JS and CSS
  • Loading branch information
gibson042 committed Aug 26, 2024
commit 2c58dda3ded41a3911935d62d13f995cf7889302
8 changes: 6 additions & 2 deletions test/baselines/generated-reference/assets-inline.html
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 1439,7 @@
function addStepNumberText(
ol,
depth = 0,
indent = '',
special = [...ol.classList].some(c => c.startsWith('nested-')),
) {
let counter = !special && counterByDepth[depth];
Expand All @@ -1462,7 1463,9 @@
let i = (Number(ol.getAttribute('start')) || 1) - 1;
for (const li of ol.children) {
const marker = document.createElement('span');
marker.textContent = `${i < cache.length ? cache[i] : getTextForIndex(i)}. `;
const markerText = i < cache.length ? cache[i] : getTextForIndex(i);
const extraIndent = ' '.repeat(markerText.length 2);
marker.textContent = `${indent}${markerText}. `;
marker.setAttribute('aria-hidden', 'true');
const attributesContainer = li.querySelector('.attributes-tag');
if (attributesContainer == null) {
Expand All @@ -1471,7 1474,7 @@
attributesContainer.insertAdjacentElement('afterend', marker);
}
for (const sublist of li.querySelectorAll(':scope > ol')) {
addStepNumberText(sublist, depth 1, special);
addStepNumberText(sublist, depth 1, indent extraIndent, special);
}
i ;
}
Expand Down Expand Up @@ -1684,6 1687,7 @@

span[aria-hidden='true'] {
font-size: 0;
white-space: pre;
}

a {
Expand Down
Loading