Skip to content

Commit

Permalink
bump crengine: support for private CSS property "-cr-hint:" (#786)
Browse files Browse the repository at this point in the history
Includes:
- Fix restore of last xpointer in scroll mode
- Adds support for private CSS property "-cr-hint:"
- CSS: Implement -cr-hint: toc-level and toc-ignore
- CSS: Implement -cr-hint: footnote-inpage
- Tweak "in-page" footnotes rendering

cre.cpp: adds support for -cr-hint: noteref, noteref-ignore,
footnote and footnote-ignore in footnote detection code.
  • Loading branch information
poire-z committed Jan 2, 2019
1 parent d6aa320 commit feb4c1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions cre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,29 @@ static bool _isLinkToFootnote(CreDocument *doc, const lString16 source_xpointer,
// in frontend/apps/reader/modules/readerlink.lua
bool trusted_source_xpointer = flags & 0x0002;

// Trust -cr-hint: noteref noteref-ignore footnote footnote-ignore
if (trusted_source_xpointer) {
css_cr_hint_t hint = sourceNode->getStyle()->cr_hint;
if (hint == css_cr_hint_noteref) {
reason = "source has -cr-hint: noteref";
return true;
}
else if (hint == css_cr_hint_noteref_ignore) {
reason = "source has -cr-hint: noteref-ignore";
return false;
}
}
css_cr_hint_t hint = targetNode->getStyle()->cr_hint;
if (hint == css_cr_hint_footnote) {
reason = "target has -cr-hint: footnote";
return true;
}
else if (hint == css_cr_hint_footnote_ignore) {
reason = "target has -cr-hint: footnote-ignore";
return false;
}


if (flags & 0x0004) { // Trust role= and epub:type= attributes
// About epub:type, see:
// http://apex.infogridpacific.com/df/epub-type-epubpackaging8.html
Expand All @@ -1610,10 +1633,6 @@ static bool _isLinkToFootnote(CreDocument *doc, const lString16 source_xpointer,
// as footnotes?
// And other like epub:type="chapter" that probably are not footnotes?
//
// (If needed, add check for a private CSS property "-cr-hint: footnote"
// or "-cr-hint: noteref", so one can define it to specific classes
// with Styles tweaks.)
//
// We also trust that the target is the whole footnote container, and
// so there is no need to extend it.
// These attributes value may contain multiple values separated by space
Expand Down Expand Up @@ -1660,7 +1679,6 @@ static bool _isLinkToFootnote(CreDocument *doc, const lString16 source_xpointer,
}
}
}
// if needed: getStyle() -cr-hint: noteref
}
// Target
// (Note that calibre first gets the block container of targetNode if
Expand Down Expand Up @@ -1699,7 +1717,6 @@ static bool _isLinkToFootnote(CreDocument *doc, const lString16 source_xpointer,
}
}
}
// if needed: getStyle() -cr-hint: footnote
}

if (flags & 0x0010) { // Target must have an anchor #id
Expand Down

0 comments on commit feb4c1d

Please sign in to comment.