Ejemplo n.º 1
0
 public void CleanBook(BookBuilder builder, EpubReadingOptions options)
 {
     if (options.HasFlag(EpubReadingOptions.ShortenPaths))
     {
         pathShortener.ShortenFilePaths(builder);
     }
 }
Ejemplo n.º 2
0
        public void ShortenFilePaths(BookBuilder builder)
        {
            var longestCommonPath = FindLongestCommonPath(builder.Files.Select(f => f.Path).ToArray());

            var replacements = builder.Files
                               .ToDictionary(f => f, f => f.WithPath(f.Path.Substring(longestCommonPath.Length)));

            builder.AdjustNavigationPoints(point => point.WithFile(replacements[point.File]));
            builder.Files = replacements.Values;
        }
Ejemplo n.º 3
0
        public async Task <BookBuilder> CreateBuilder(EpubStructure structure)
        {
            var builder       = new BookBuilder();
            var manifestItems = manifestExtractor.ExtractManifestItems(structure.Opf);
            var meta          = metaExtractor.ExtractMeta(structure.Opf);
            var files         = await fileExtractor.ExtractFiles(structure.Opf, manifestItems, structure.Zip).ConfigureAwait(false);

            var navigationPoints = await navigationExtractor.ExtractNavigationPoints(structure, files).ConfigureAwait(false);

            builder.ReadFromMeta(meta);
            builder.NavigationPoints = navigationPoints.ToList();
            builder.Files            = files.ToList();
            return(builder);
        }