mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 18:39:45 +00:00
Fixed image loading on certain ebooks
This commit is contained in:
@@ -85,7 +85,7 @@ namespace QuickLook.Plugin.EpubViewer
|
||||
basePath = System.IO.Path.GetDirectoryName(basePath);
|
||||
}
|
||||
string fullPath = String.Concat(basePath.Replace('\\', '/'), '/', relativePath);
|
||||
return fullPath.Length > 1 ? fullPath.Substring(1) : String.Empty;
|
||||
return fullPath.StartsWith("/") ? fullPath.Length > 1 ? fullPath.Substring(1) : String.Empty : fullPath;
|
||||
}
|
||||
|
||||
private static async void OnChapterRefChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
|
||||
|
@@ -10,7 +10,6 @@ namespace VersOne.Epub.Internal
|
||||
{
|
||||
public static List<EpubChapterRef> GetChapters(EpubBookRef bookRef)
|
||||
{
|
||||
// return GetChapters(bookRef, bookRef.Schema.Navigation.NavMap);
|
||||
return GetChapters(bookRef, bookRef.Schema.Package.Spine, bookRef.Schema.Navigation.NavMap);
|
||||
}
|
||||
|
||||
@@ -46,38 +45,5 @@ namespace VersOne.Epub.Internal
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<EpubChapterRef> GetChapters(EpubBookRef bookRef, List<EpubNavigationPoint> navigationPoints, EpubChapterRef parentChapter = null)
|
||||
{
|
||||
List<EpubChapterRef> result = new List<EpubChapterRef>();
|
||||
foreach (EpubNavigationPoint navigationPoint in navigationPoints)
|
||||
{
|
||||
string contentFileName;
|
||||
string anchor;
|
||||
int contentSourceAnchorCharIndex = navigationPoint.Content.Source.IndexOf('#');
|
||||
if (contentSourceAnchorCharIndex == -1)
|
||||
{
|
||||
contentFileName = WebUtility.UrlDecode(navigationPoint.Content.Source);
|
||||
anchor = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
contentFileName = WebUtility.UrlDecode(navigationPoint.Content.Source.Substring(0, contentSourceAnchorCharIndex));
|
||||
anchor = navigationPoint.Content.Source.Substring(contentSourceAnchorCharIndex + 1);
|
||||
}
|
||||
if (!bookRef.Content.Html.TryGetValue(contentFileName, out EpubTextContentFileRef htmlContentFileRef))
|
||||
{
|
||||
throw new Exception(String.Format("Incorrect EPUB manifest: item with href = \"{0}\" is missing.", contentFileName));
|
||||
}
|
||||
EpubChapterRef chapterRef = new EpubChapterRef(htmlContentFileRef);
|
||||
chapterRef.ContentFileName = contentFileName;
|
||||
chapterRef.Anchor = anchor;
|
||||
chapterRef.Parent = parentChapter;
|
||||
chapterRef.Title = navigationPoint.NavigationLabels.First().Text;
|
||||
chapterRef.SubChapters = GetChapters(bookRef, navigationPoint.ChildNavigationPoints, chapterRef);
|
||||
result.Add(chapterRef);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user