From a4be94a752f6fc5c8af2ca4a4b6c03b0e9c6ab12 Mon Sep 17 00:00:00 2001 From: Johannes Wilm Date: Tue, 10 Dec 2024 16:24:27 +0100 Subject: [PATCH] convert HTML + print exporters from DOMExporter to string concatenation --- .../book/fixtures/initial_book_data.json | 10 +- .../book/migrations/0017_book_styles.py | 30 ++ .../js/modules/books/exporter/epub/index.js | 2 +- .../js/modules/books/exporter/epub/tools.js | 31 ++ .../js/modules/books/exporter/html/index.js | 400 +++++++++++++++++- .../modules/books/exporter/html/multifile.js | 371 ---------------- .../modules/books/exporter/html/singlefile.js | 165 -------- .../modules/books/exporter/html/templates.js | 111 ++++- .../js/modules/books/exporter/html/tools.js | 44 +- .../js/modules/books/exporter/print/index.js | 177 ++------ .../modules/books/exporter/print/templates.js | 17 - .../book/static/js/modules/books/menu.js | 7 +- 12 files changed, 622 insertions(+), 743 deletions(-) create mode 100644 fiduswriter/book/migrations/0017_book_styles.py delete mode 100644 fiduswriter/book/static/js/modules/books/exporter/html/multifile.js delete mode 100644 fiduswriter/book/static/js/modules/books/exporter/html/singlefile.js diff --git a/fiduswriter/book/fixtures/initial_book_data.json b/fiduswriter/book/fixtures/initial_book_data.json index 737114b..d4ef1df 100644 --- a/fiduswriter/book/fixtures/initial_book_data.json +++ b/fiduswriter/book/fixtures/initial_book_data.json @@ -5,7 +5,7 @@ "fields": { "title": "Springer", "slug": "springer", - "contents": "@font-face {font-family: 'Source Sans Pro';\r\nfont-style: normal;\r\nfont-weight: 700;\r\nsrc: local('Source Sans Pro Bold'), local('SourceSansPro-Bold'), url(SourceSansPro-Bold.woff) format('woff');}\r\n\r\n@font-face {font-family: 'Noticia Text';\r\nfont-style: italic;\r\nfont-weight: 700;\r\nsrc: local('Noticia Text Bold Italic'), local('NoticiaText-BoldItalic'), url(NoticiaText-BoldItalic.woff) format('woff');}\r\n\r\n@font-face {font-family: 'Noticia Text';\r\nfont-style: italic;\r\nfont-weight: 400;\r\nsrc: local('Noticia Text Italic'), local('NoticiaText-Italic'), url(NoticiaText-Italic.woff) format('woff');}\r\n\r\n@font-face {font-family: 'Noticia Text';\r\nfont-style: normal;\r\nfont-weight: 400;\r\nsrc: local('Noticia Text'), local('NoticiaText-Regular'), url(NoticiaText-Regular.woff) format('woff');}\r\n\r\n@font-face {font-family: 'Noticia Text';\r\nfont-style: normal;\r\nfont-weight: 700;\r\nsrc: local('Noticia Text Bold'), local('NoticiaText-Bold'), url(NoticiaText-Bold_2.woff) format('woff');}\r\n\r\ndiv#print {\r\n font-size: 9pt;\r\n}\r\ndiv#flow {\r\n font-size: 12pt;\r\n}\r\n.user-contents {\r\n font-family: 'Noticia Text', serif;\r\n font-weight: 400;\r\n line-height: 1.25em;\r\n text-align: justify;\r\n word-wrap: break-word;\r\n hyphens: auto;\r\n}\r\ndiv#print,\r\ndiv#flow {\r\n counter-reset: footnote-counter footnote-marker-counter heading section subsection cat-figure cat-equation cat-photo cat-table !important;\r\n}\r\n.article-title {\r\n margin-bottom: 30px;\r\n font-size: 2em;\r\n font-weight: 700;\r\n text-transform: initial;\r\n}\r\n.article-title,\r\n.article-part.metadata {\r\n padding-left: 50px;\r\n padding-right: 50px;\r\n}\r\ndiv#print .article-title {\r\n display: flex;\r\n justify-content: center;\r\n text-align: center;\r\n align-items: center;\r\n}\r\n.article-subtitle {\r\n font-size: 1.5em;\r\n font-weight: 400;\r\n display: inline;\r\n text-align: justify;\r\n}\r\ndiv#print .article-subtitle:not([data-hidden]) {\r\n display: flex;\r\n justify-content: center;\r\n}\r\n.article-authors {\r\n font-weight: 400;\r\n break-after: always;\r\n font-size: 1em;\r\n text-decoration: none;\r\n margin-top: 20pt;\r\n margin-bottom: 20pt;\r\n -moz-hyphens: none;\r\n -webkit-hyphens: none;\r\n -ms-hyphens: none;\r\n hyphens: none;\r\n}\r\ndiv#print .article-authors {\r\n text-align: center;\r\n}\r\n.article-abstract {\r\n font-size: 0.9em;\r\n margin: 1cm 0 0;\r\n line-height: 0.999000;\r\n min-height: 1.5em;\r\n text-align: justify;\r\n}\r\n.article-part.article-abstract:before {\r\n content: '';\r\n}\r\n.article-abstract > p:first-child:before {\r\n content: 'Abstract. ';\r\n color: black;\r\n font-weight: 700;\r\n}\r\n.article-keywords {\r\n font-size: 0.9em;\r\n padding: 0 2.5em;\r\n margin: 15px 0 0;\r\n line-height: 1.2em;\r\n text-align: justify;\r\n}\r\n.article-part.metadata.article-keywords:before {\r\n content: 'Keywords: ';\r\n color: black;\r\n font-weight: 700;\r\n}\r\n.article-part.metadata {\r\n margin-top: 30px;\r\n margin-bottom: 20px;\r\n line-height: 18px;\r\n}\r\n.pagination-footnote:before,\r\n.pagination-footnote > * > *:first-child:before {\r\n font-weight: 400;\r\n font-size: 1em;\r\n text-align: center;\r\n font-style: normal;\r\n vertical-align: super;\r\n line-height: 0;\r\n}\r\n.pagination-footnote > * > *:first-child:before {\r\n margin-right: 5px;\r\n}\r\n.pagination-footnote > * > * {\r\n font-weight: 400;\r\n font-size: 1.3em;\r\n line-height: 1.35em;\r\n}\r\n.pagination-pagenumber {\r\n font-size: 1.25em;\r\n font-weight: 400;\r\n text-align: left !important;\r\n}\r\n.pagination-footnotes {\r\n padding-top: 25px;\r\n}\r\nfigure {\r\n font-style: italic;\r\n font-size: 1.25em;\r\n}\r\n.user-contents h1,\r\n.user-contents h2,\r\n.user-contents h3,\r\n.user-contents h4,\r\n.user-contents h5,\r\n.user-contents h6,\r\n.user-contents p,\r\n.user-contents dl,\r\n.user-contents blockquote,\r\n.user-contents code,\r\n.user-contents ol,\r\n.user-contents ul {\r\n margin-bottom: 12px;\r\n margin-top: 12px;\r\n}\r\n.user-contents h1,\r\n.user-contents h2,\r\n.user-contents h3,\r\n.user-contents h4,\r\n.user-contents h5,\r\n.user-contents h6 {\r\n hyphens: none;\r\n line-height: 1.5em;\r\n font-size: 1em;\r\n}\r\n.user-contents h1 {\r\n font-size: 1.4em;\r\n font-weight: 700;\r\n}\r\n.user-contents h2 {\r\n font-size: 1.3em;\r\n font-weight: 700;\r\n}\r\n.user-contents h3 {\r\n font-size: 1.2em;\r\n font-weight: 700;\r\n}\r\n.user-contents h4 {\r\n font-size: 1.1em;\r\n font-weight: 400;\r\n font-style: italic;\r\n}\r\n.user-contents h5 {\r\n font-size: 1.1em;\r\n font-weight: 400;\r\n font-variant: small-caps;\r\n}\r\n.user-contents h6 {\r\n font-size: 1.1em;\r\n font-weight: 400;\r\n text-decoration: underline;\r\n}\r\n.article-body h1:not(:empty):before {\r\n counter-increment: heading;\r\n /* add 1 to heading */\r\n \r\n content: counter(heading) \" \";\r\n width: 2em;\r\n display: inline-block;\r\n}\r\n.article-body h1:not(:empty) {\r\n counter-reset: subheading section;\r\n /* set section to 0 */\r\n}\r\n.article-body h2:not(:empty):before {\r\n content: counter(heading) \".\" counter(subheading) \" \";\r\n counter-increment: subheading subsection;\r\n width: 2em;\r\n display: inline-block;\r\n}\r\n.article-body h2:not(:empty) {\r\n counter-reset: section;\r\n}\r\n.article-body h3:not(:empty):before {\r\n content: counter(heading) \".\" counter(subheading) \".\" counter(section) \" \";\r\n counter-increment: section;\r\n width: 2em;\r\n display: inline-block;\r\n}\r\n.article-body h3:not(:empty) {\r\n counter-reset: subsection;\r\n}\r\ndiv#print .article-body,\r\n.pagination-footnote > * > * {\r\n font-size: 1em;\r\n}\r\n/*unordered lists (