Skip to content

Commit

Permalink
show external anchor HREFs when printing
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Mar 12, 2024
1 parent 1659ed0 commit e8cc2b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions css/print.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ p {
#spec-container > emu-annex {
page-break-before: always;
}

a[data-print-href]::after {
content: ' <' attr(href) '>';
color: initial;
}
10 changes: 10 additions & 0 deletions src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ export default class Spec {
}
this.log('Propagating effect annotations...');
this.propagateEffects();
this.log('Annotating external links...');
this.annotateExternalLinks();
this.log('Linking xrefs...');
this._xrefs.forEach(xref => xref.build());
this.log('Linking non-terminal references...');
Expand Down Expand Up @@ -814,6 +816,14 @@ export default class Spec {
return null;
}

private annotateExternalLinks(): void {
for (const a of this.doc.getElementsByTagName('a')) {
if (a.hostname !== '' && a.href !== a.textContent && a.protocol !== 'mailto:') {
a.setAttribute('data-print-href', '');
}
}
}

private async buildMultipage(wrapper: Element, commonEles: Element[]) {
let stillIntro = true;
const introEles = [];
Expand Down

0 comments on commit e8cc2b5

Please sign in to comment.