epub presets improves

This commit is contained in:
Kiryl
2022-10-13 11:05:48 +03:00
parent 5a57bf4d32
commit 93979e8d59
2 changed files with 37 additions and 15 deletions

View File

@@ -48,17 +48,23 @@
{ {
"tags": ["^h[6-9]$", "^figure$", "^section$", "^div$", "blockquote"], "tags": ["^h[6-9]$", "^figure$", "^section$", "^div$", "blockquote"],
"condition": null, "condition": null,
"tag_to_replace": "p" "tag_to_replace": {
"name": "p"
}
}, },
{ {
"tags": ["^aside$"], "tags": ["^aside$"],
"condition": null, "condition": null,
"tag_to_replace": "div" "tag_to_replace": {
"name": "div"
}
}, },
{ {
"tags": ["^header$", "^footer$"], "tags": ["^header$", "^footer$"],
"condition": null, "condition": null,
"tag_to_replace": "span" "tag_to_replace": {
"name": "span"
}
}, },
{ {
"tags": ["^code$", "^kbd$", "^var$"], "tags": ["^code$", "^kbd$", "^var$"],
@@ -67,22 +73,30 @@
"child_tags": null, "child_tags": null,
"attrs": null "attrs": null
}, },
"tag_to_replace": "span" "tag_to_replace": {
"name": "span"
}
}, },
{ {
"tags": ["^em$"], "tags": ["^em$"],
"condition": null, "condition": null,
"tag_to_replace": "i" "tag_to_replace": {
"name": "i"
}
}, },
{ {
"tags": ["^b$"], "tags": ["^b$"],
"condition": null, "condition": null,
"tag_to_replace": "strong" "tag_to_replace": {
"name": "strong"
}
}, },
{ {
"tags": ["^image$"], "tags": ["^image$"],
"condition": null, "condition": null,
"tag_to_replace": "img" "tag_to_replace": {
"name": "img"
}
} }
] ]
}, },
@@ -90,12 +104,14 @@
"preset_name": "attr_replacer", "preset_name": "attr_replacer",
"rules": [ "rules": [
{ {
"attr": { "tags": ["^img$"],
"condition": {
"attrs": [
{
"name": "xlink:href", "name": "xlink:href",
"value": ".*" "value": ".*"
}, }
"condition": { ]
"tags": ["^img$"]
}, },
"attr_to_replace": { "attr_to_replace": {
"name": "src", "name": "src",
@@ -140,12 +156,18 @@
"child_tags": ":not(:has(code, kbd, var))", "child_tags": ":not(:has(code, kbd, var))",
"attrs": null "attrs": null
}, },
"tag_to_insert": "code" "tag_to_insert": {
"name": "code",
"attrs": []
}
}, },
{ {
"tags": ["^h[1-5]$"], "tags": ["^h[1-5]$"],
"condition": null, "condition": null,
"tag_to_insert": "strong" "tag_to_insert": {
"name":"strong",
"attrs": []
}
} }
] ]
} }

View File

@@ -43,7 +43,7 @@ class EpubBook(BookSolver):
if __name__ == "__main__": if __name__ == "__main__":
epub_file_path = "../../books/epub/9780763774134.epub" epub_file_path = "../../books/epub/9781634259804.epub"
logger_object = BookLogger( logger_object = BookLogger(
name="epub", book_id=epub_file_path.split("/")[-1]) name="epub", book_id=epub_file_path.split("/")[-1])