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

fix: epub:type="footnote" on non-aside element should not cause footnote layout #1365

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/vivliostyle/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ a[epub|type="noteref"] {
line-height: 0.01;
}

a[epub|type="noteref"]:href-epub-type(footnote) {
a[epub|type="noteref"]:href-epub-type(footnote, aside) {
-adapt-template: url(user-agent.xml#footnote);
text-decoration: none;
}
Expand Down
17 changes: 12 additions & 5 deletions packages/core/src/vivliostyle/css-cascade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,10 @@ export class CheckNSTagAction extends ChainedAction {
}

export class CheckTargetEpubTypeAction extends ChainedAction {
constructor(public readonly epubTypePatt: RegExp) {
constructor(
public readonly epubTypePatt: RegExp,
public readonly targetLocalName?: string,
) {
super();
}

Expand All @@ -876,7 +879,10 @@ export class CheckTargetEpubTypeAction extends ChainedAction {
if (href && href.match(/^#/)) {
const id = href.substring(1);
const target = elem.ownerDocument.getElementById(id);
if (target) {
if (
target &&
(!this.targetLocalName || target.localName == this.targetLocalName)
) {
const epubType = target.getAttributeNS(Base.NS.epub, "type");
if (epubType && epubType.match(this.epubTypePatt)) {
this.chained.apply(cascadeInstance);
Expand Down Expand Up @@ -3779,10 +3785,11 @@ export class CascadeParserHandler
break;
case "-adapt-href-epub-type":
case "href-epub-type":
if (params && params.length == 1 && typeof params[0] == "string") {
if (params && params.length >= 1 && typeof params[0] == "string") {
const value = params[0] as string;
const patt = new RegExp(`(^|s)${Base.escapeRegExp(value)}(\$|s)`);
this.chain.push(new CheckTargetEpubTypeAction(patt));
const patt = new RegExp(`(^|\\s)${Base.escapeRegExp(value)}(\$|\\s)`);
const targetLocalName = params[1] as string;
this.chain.push(new CheckTargetEpubTypeAction(patt, targetLocalName));
} else {
this.chain.push(new CheckConditionAction("")); // always fails
}
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/vivliostyle/css-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,17 @@ export class Parser {
if (token.type === TokenType.IDENT) {
params = [token.text];
tokenizer.consume();
if (
text === "href-epub-type" &&
tokenizer.token().type === TokenType.COMMA
) {
tokenizer.consume();
token = tokenizer.token();
if (token.type === TokenType.IDENT) {
params.push(token.text);
tokenizer.consume();
}
}
break;
} else {
break pseudoclassType;
Expand Down
Loading