Skip to content

Commit

Permalink
Merge pull request #1400 from vivliostyle/fix/epub-noteref
Browse files Browse the repository at this point in the history
fix: Improve epub:noteref/footnote support
  • Loading branch information
MurakamiShinyu authored Oct 23, 2024
2 parents 674a368 + 6c894e7 commit 3ac2dcc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
12 changes: 8 additions & 4 deletions packages/core/src/vivliostyle/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1306,22 +1306,26 @@ m|math[display="block"] {
/*------------------ epub-specific ---------------------*/
a[epub|type="noteref"] {
a[epub|type="noteref"],
a[epub\\:type="noteref"] {
font-size: 0.75em;
vertical-align: super;
line-height: 0.01;
}
a[epub|type="noteref"]:href-epub-type(footnote, aside) {
a[epub|type="noteref"]:href-epub-type(footnote, aside),
a[epub\\:type="noteref"]:href-epub-type(footnote, aside) {
-adapt-template: footnote;
text-decoration: none;
}
aside[epub|type="footnote"] {
aside[epub|type="footnote"],
aside[epub\\:type="footnote"] {
display: none;
}
aside[epub|type="footnote"]:footnote-content {
aside[epub|type="footnote"]:footnote-content,
aside[epub\\:type="footnote"]:footnote-content {
display: block;
margin: 0.25em;
font-size: 1.2em;
Expand Down
11 changes: 6 additions & 5 deletions packages/core/src/vivliostyle/css-cascade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,16 +874,17 @@ export class CheckTargetEpubTypeAction extends ChainedAction {

override apply(cascadeInstance: CascadeInstance): void {
const elem = cascadeInstance.currentElement;
if (elem && cascadeInstance.currentLocalName == "a") {
const href = elem.getAttribute("href");
if (href && href.match(/^#/)) {
const id = href.substring(1);
if (elem instanceof HTMLAnchorElement) {
if (elem.hash && elem.href == elem.baseURI + elem.hash) {
const id = elem.hash.substring(1);
const target = elem.ownerDocument.getElementById(id);
if (
target &&
(!this.targetLocalName || target.localName == this.targetLocalName)
) {
const epubType = target.getAttributeNS(Base.NS.epub, "type");
const epubType =
target.getAttributeNS(Base.NS.epub, "type") ||
target.getAttribute("epub:type");
if (epubType && epubType.match(this.epubTypePatt)) {
this.chained.apply(cascadeInstance);
}
Expand Down
26 changes: 13 additions & 13 deletions packages/core/src/vivliostyle/vgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,19 +404,19 @@ export class ViewFactory
} else {
cont2 = Task.newResult(shadow);
}
});
cont2.then((shadow) => {
shadow = this.createPseudoelementShadow(
element,
isRoot,
cascStyle,
computedStyle,
styler,
context,
shadowContext,
shadow,
);
frame.finish(shadow);
cont2.then((shadow) => {
shadow = this.createPseudoelementShadow(
element,
isRoot,
cascStyle,
computedStyle,
styler,
context,
shadowContext,
shadow,
);
frame.finish(shadow);
});
});
});
return frame.result();
Expand Down

0 comments on commit 3ac2dcc

Please sign in to comment.