Skip to content

Commit 2a81b5f

Browse files
committed
Add link underline styles for accessibility
Fixes #106 Fixes #44
1 parent cf55c61 commit 2a81b5f

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

constants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ export const ALLOW_CLASS = new Set([
9696
const octicon = String.raw`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>`;
9797

9898
export const manuallyAddedStyle = `
99+
.markdown-body a {
100+
text-decoration: underline;
101+
text-underline-offset: .2rem;
102+
}
103+
99104
.markdown-body .octicon {
100105
display: inline-block;
101106
fill: currentColor;

test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ test('transparentBackground - onlyVariables', async () => {
110110
assert.ok(css.includes('--bgColor-default: transparent'), 'should set --bgColor-default to transparent');
111111
});
112112

113+
test('link underline styles are included', async () => {
114+
const css = await githubMarkdownCss();
115+
assert.ok(css.includes('.markdown-body a {\n text-decoration: underline;'), 'should include link underline styles');
116+
assert.ok(css.includes('text-underline-offset'), 'should include underline offset');
117+
});
118+
119+
test('link underline styles in onlyStyles mode', async () => {
120+
const css = await githubMarkdownCss({onlyStyles: true});
121+
assert.ok(css.includes('.markdown-body a {\n text-decoration: underline;'), 'should include link underline styles in onlyStyles mode');
122+
});
123+
124+
test('no link underline styles in onlyVariables mode', async () => {
125+
const css = await githubMarkdownCss({onlyVariables: true});
126+
assert.ok(!css.includes('text-underline-offset'), 'should not include link styles in onlyVariables mode');
127+
});
128+
113129
test('no transparentBackground by default', async () => {
114130
const css = await githubMarkdownCss();
115131
assert.ok(!css.includes('--bgColor-default: transparent'), 'should not have transparent background by default');

0 commit comments

Comments
 (0)