You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for now I preprocess the html before. but will be more handy to have a callback onCssRequested.
And maybe same for fonts declaration in css (@font-face), a callback onFontFamillyRequested.
voidprepareText() {
text = widget.spine.file.asText.nbspFormat;
int i =0;
// load external csswhile (i < text.length) {
i = text.indexOf('<link', i);
if (i <0) break;
final n0 = text.indexOf('/>', i);
final n1 = text.indexOf('</link>', i);
int n =0;
if (n0 >0&& n1 >0) {
n =min(n0, n1);
n += n == n0 ?2:7;
} elseif (n0 >0) {
n = n0 +2;
} elseif (n1 >0) {
n = n1 +7;
} else {
break;
}
try {
final xml =XmlDocument.parse(text.substring(i, n));
final href = xml.rootElement.getAttribute('href');
if (href !=null&& href.isFileExt('css')) {
final aref = widget.spine.combine(href: href);
final bytes = widget.epub.files[aref]?.content;
if (bytes !=null) {
final style ='<style>${utf8.decode(bytes)}</style>';
text ='${text.substring(0, i)}$style${text.substring(n)}';
n = i + style.length;
}
}
} catch (error) {
Debug.info(error);
}
i = n;
}
}
Activity
[-][QUESTION] <style></style> handling[/-][+][QUESTION] <link/> handling[/+]renanyoy commentedon May 19, 2026
for now I preprocess the html before. but will be more handy to have a callback onCssRequested.
And maybe same for fonts declaration in css (@font-face), a callback onFontFamillyRequested.