Skip to content

Commit

Permalink
bump crengine: optimizations, fixes, View HTML helpers (#1589)
Browse files Browse the repository at this point in the history
Includes:
- LVStyleSheet: "const" some accessors
- LVStyleSheet: optimize `LVStyleSheet::merge`
- LVStyleSheet: simplify `insert_into_selectors` implementation
- Update German hyphenation patterns
- Header: render title/authors with book language glyphs
- Text: fix issues when hyphenation happened on a ligature
- getDocumentFileStream() support percent-encoded path
- getHtml(): add flag to get CSS selectors for met elements
- Add gatherStylesheetsMatchingRulesets(node)
  • Loading branch information
poire-z committed Mar 5, 2023
1 parent 8e9bef0 commit acba402
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions cre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2562,14 +2562,16 @@ static int getHTMLFromXPointer(lua_State *L) {
}
nodep = ldomXPointer(node, 0); // reset offset to 0, to get the full text of text nodes
lString32Collection cssFiles;
lString8 html = nodep.getHtml(cssFiles, wflags);
lString8 extra;
lString8 html = nodep.getHtml(cssFiles, extra, wflags);
lua_pushstring(L, html.c_str());
lua_createtable(L, cssFiles.length(), 0);
for (int i = 0; i < cssFiles.length(); i++) {
lua_pushstring(L, UnicodeToLocal(cssFiles[i]).c_str());
lua_rawseti(L, -2, i+1);
}
return 2;
lua_pushstring(L, extra.c_str());
return 3;
}

static int getHTMLFromXPointers(lua_State *L) {
Expand All @@ -2589,14 +2591,29 @@ static int getHTMLFromXPointers(lua_State *L) {
if (r.getStart().isNull() || r.getEnd().isNull())
return 0;
lString32Collection cssFiles;
lString8 html = r.getHtml(cssFiles, wflags, fromRootNode);
lString8 extra;
lString8 html = r.getHtml(cssFiles, extra, wflags, fromRootNode);
lua_pushstring(L, html.c_str());
lua_createtable(L, cssFiles.length(), 0);
for (int i = 0; i < cssFiles.length(); i++) {
lua_pushstring(L, UnicodeToLocal(cssFiles[i]).c_str());
lua_rawseti(L, -2, i+1);
}
return 2;
lua_pushstring(L, extra.c_str());
return 3;
}

static int getStylesheetsMatchingRulesets(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
lUInt32 nodeDataIndex = (lUInt32) lua_tointeger(L, 2);
lString8Collection matches;
doc->text_view->gatherStylesheetsMatchingRulesets(nodeDataIndex, matches);
lua_createtable(L, matches.length(), 0);
for (int i = 0; i < matches.length(); i++) {
lua_pushstring(L, matches[i].c_str());
lua_rawseti(L, -2, i+1);
}
return 1;
}

static int getPageLinks(lua_State *L) {
Expand Down Expand Up @@ -4020,6 +4037,7 @@ static const struct luaL_Reg credocument_meth[] = {
{"getTextFromXPointer", getTextFromXPointer},
{"getHTMLFromXPointer", getHTMLFromXPointer},
{"getHTMLFromXPointers", getHTMLFromXPointers},
{"getStylesheetsMatchingRulesets", getStylesheetsMatchingRulesets},
{"getPageLinks", getPageLinks},
{"isLinkToFootnote", isLinkToFootnote},
{"highlightXPointer", highlightXPointer},
Expand Down

0 comments on commit acba402

Please sign in to comment.