Skip to content

Commit

Permalink
extract root_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
milmazz committed Sep 27, 2024
1 parent aa094f1 commit 16c7b21
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/bupe/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ defmodule BUPE.Parser do
&parse_xml(&2, xml, &1)
)

root_dir = Path.dirname(root_file)

%{
config
| pages: extract_item_content(epub, root_file, config.pages || []),
images: extract_item_content(epub, root_file, config.images || []),
styles: extract_item_content(epub, root_file, config.styles || []),
scripts: extract_item_content(epub, root_file, config.scripts || [])
| pages: extract_item_content(epub, root_dir, config.pages || []),
images: extract_item_content(epub, root_dir, config.images || []),
styles: extract_item_content(epub, root_dir, config.styles || []),
scripts: extract_item_content(epub, root_dir, config.scripts || [])
}
end
end

defp extract_item_content(epub, root_file, items) do
root_dir = Path.dirname(root_file)
defp extract_item_content(epub, root_dir, items) do
root_dir_length = String.length(root_dir) + 1

item_paths = Enum.map(items, &Path.join([root_dir, &1.href]))
Expand Down

0 comments on commit 16c7b21

Please sign in to comment.