Skip to content

Commit 1d2975a

Browse files
show external anchor HREFs when printing (#578)
1 parent 1659ed0 commit 1d2975a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

css/print.css

+5
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ p {
2626
#spec-container > emu-annex {
2727
page-break-before: always;
2828
}
29+
30+
a[data-print-href]::after {
31+
content: ' <' attr(href) '>';
32+
color: initial;
33+
}

src/Spec.ts

+10
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ export default class Spec {
535535
}
536536
this.log('Propagating effect annotations...');
537537
this.propagateEffects();
538+
this.log('Annotating external links...');
539+
this.annotateExternalLinks();
538540
this.log('Linking xrefs...');
539541
this._xrefs.forEach(xref => xref.build());
540542
this.log('Linking non-terminal references...');
@@ -814,6 +816,14 @@ export default class Spec {
814816
return null;
815817
}
816818

819+
private annotateExternalLinks(): void {
820+
for (const a of this.doc.getElementsByTagName('a')) {
821+
if (a.hostname !== '' && a.href !== a.textContent && a.protocol !== 'mailto:') {
822+
a.setAttribute('data-print-href', '');
823+
}
824+
}
825+
}
826+
817827
private async buildMultipage(wrapper: Element, commonEles: Element[]) {
818828
let stillIntro = true;
819829
const introEles = [];

0 commit comments

Comments
 (0)