Skip to content

Commit

Permalink
move domexporter functions into epub folder
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswilm committed Dec 10, 2024
1 parent a4be94a commit e85e0a6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {DOMSerializer} from "prosemirror-model"
import {RenderCitations} from "../../citations/render"
import {get} from "../../common"
import {BIBLIOGRAPHY_HEADERS, CATS} from "../../schema/i18n"
import {RenderCitations} from "../../../citations/render"
import {get} from "../../../common"
import {BIBLIOGRAPHY_HEADERS, CATS} from "../../../schema/i18n"

/*
WARNING: DEPRECATED!
Base exporter class for dom-based exports. This is the deprecated way of creating exports.
The epub and html book export filters go over a DOM of a document which they change little
by little, and they are all based on the BaseDOMExporter class.
The epub book export filter goes over a DOM of a document which they change little
by little, and it is based on the DOMExporter class.
New exporters should instead by walking the doc.content tree.
This is how all document exporters work, including the new HTML/EPUB exporter.
This is how all document exporters work, including the new EPUB exporter.
*/

export class DOMExporter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {getTimestamp} from "../../../exporter/epub/tools"
import {mathliveOpfIncludes} from "../../../mathlive/opf_includes"
import {BIBLIOGRAPHY_HEADERS} from "../../../schema/i18n"
import {bookTerm} from "../../i18n"
import {DOMExporter} from "../dom_export"
import {getMissingChapterData, uniqueObjects} from "../tools"
import {getMissingChapterData} from "../tools"
import {DOMExporter} from "./dom_export"
import {
epubBookCopyrightTemplate,
epubBookCoverTemplate,
Expand All @@ -22,7 +22,8 @@ import {
modifyImages,
orderLinks,
setLinks,
styleEpubFootnotes
styleEpubFootnotes,
uniqueObjects
} from "./tools"

import {RenderCitations} from "../../../citations/render"
Expand Down
19 changes: 19 additions & 0 deletions fiduswriter/book/static/js/modules/books/exporter/epub/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,22 @@ export const modifyImages = htmlEl => {

return images
}

export const uniqueObjects = array => {
const results = []

for (let i = 0; i < array.length; i++) {
let willCopy = true
for (let j = 0; j < i; j++) {
if (JSON.stringify(array[i]) === JSON.stringify(array[j])) {
willCopy = false
break
}
}
if (willCopy) {
results.push(array[i])
}
}

return results
}
19 changes: 0 additions & 19 deletions fiduswriter/book/static/js/modules/books/exporter/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,3 @@ export const getMissingChapterData = (
)
return returnData
}

export const uniqueObjects = array => {
const results = []

for (let i = 0; i < array.length; i++) {
let willCopy = true
for (let j = 0; j < i; j++) {
if (JSON.stringify(array[i]) === JSON.stringify(array[j])) {
willCopy = false
break
}
}
if (willCopy) {
results.push(array[i])
}
}

return results
}

0 comments on commit e85e0a6

Please sign in to comment.