*** org-mode/lisp/ox-html.el 2024-08-05 17:15:57.628595589 +0200
--- org-mode-multipage/lisp/ox-html.el 2024-08-05 17:11:54.979585435 +0200
***************
*** 4,9 ****
--- 4,11 ----
;; Author: Carsten Dominik
;; Jambunathan K
+ ;; multipage export by Orm Finnendahl
+ ;;
;; Maintainer: TEC
;; Keywords: outlines, hypermedia, calendar, text
***************
*** 82,88 ****
--- 84,94 ----
(latex-fragment . org-html-latex-fragment)
(line-break . org-html-line-break)
(link . org-html-link)
+ (multipage-inner-template . org-html-multipage-inner-template)
+ (multipage-template . org-html-multipage-template)
(node-property . org-html-node-property)
+ (org-data . org-html-transcode-org-data)
+ ;;; (org-page . org-html-transcode-org-page)
(paragraph . org-html-paragraph)
(plain-list . org-html-plain-list)
(plain-text . org-html-plain-text)
***************
*** 108,118 ****
--- 114,126 ----
(verse-block . org-html-verse-block))
:filters-alist '((:filter-options . org-html-infojs-install-script)
(:filter-parse-tree . org-html-image-link-filter)
+ (:multipage-split . org-html-multipage-split)
(:filter-final-output . org-html-final-function))
:menu-entry
'(?h "Export to HTML"
((?H "As HTML buffer" org-html-export-as-html)
(?h "As HTML file" org-html-export-to-html)
+ (?m "As HTML Multipage files" org-html-export-to-multipage)
(?o "As HTML file and open"
(lambda (a s v b)
(if a (org-html-export-to-html t s v b)
***************
*** 134,141 ****
(:html-head "HTML_HEAD" nil org-html-head newline)
(:html-head-extra "HTML_HEAD_EXTRA" nil org-html-head-extra newline)
(:subtitle "SUBTITLE" nil nil parse)
! (:html-head-include-default-style
! nil "html-style" org-html-head-include-default-style)
(:html-head-include-scripts nil "html-scripts" org-html-head-include-scripts)
(:html-allow-name-attribute-in-anchors
nil nil org-html-allow-name-attribute-in-anchors)
--- 142,148 ----
(:html-head "HTML_HEAD" nil org-html-head newline)
(:html-head-extra "HTML_HEAD_EXTRA" nil org-html-head-extra newline)
(:subtitle "SUBTITLE" nil nil parse)
! (:html-head-include-default-style nil "html-style" org-html-head-include-default-style)
(:html-head-include-scripts nil "html-scripts" org-html-head-include-scripts)
(:html-allow-name-attribute-in-anchors
nil nil org-html-allow-name-attribute-in-anchors)
***************
*** 158,163 ****
--- 165,190 ----
(:html-mathjax-options nil nil org-html-mathjax-options)
(:html-mathjax-template nil nil org-html-mathjax-template)
(:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format)
+ (:html-multipage-clear-export-directory nil "html-multipage-clear-export-directory"
+ org-html-multipage-clear-export-directory)
+ (:html-multipage-export-directory
+ nil "html-multipage-export-directory" org-html-multipage-export-directory)
+ (:html-multipage-head-include-default-style
+ nil "html-multipage-include-default-style" org-html-multipage-head-include-default-style)
+ (:html-multipage-join-empty-bodies
+ nil "html-multipage-join-empty-bodies" org-html-multipage-join-empty-bodies)
+ (:html-multipage-nav-format nil nil org-html-multipage-nav-format)
+ (:html-multipage-numbered-filenames nil "html-multipage-numbered-filenames"
+ org-html-multipage-numbered-filenames)
+ (:html-multipage-open nil "html-multipage-open" org-html-multipage-open)
+ (:html-multipage-postamble-position
+ nil "html-multipage-postamble-position" org-html-multipage-postamble-position)
+ (:html-multipage-preamble-position
+ nil "html-multipage-preamble-position" org-html-multipage-preamble-position)
+ (:html-multipage-split-hooks nil nil org-html-multipage-split-hooks)
+ (:html-multipage-split-level nil "html-multipage-split-level" org-html-multipage-split-level)
+ (:html-multipage-toc-to-top nil "html-multipage-toc-to-top" org-html-multipage-toc-to-top)
+ (:html-numbered-link-format nil nil org-html-numbered-link-format)
(:html-postamble-format nil nil org-html-postamble-format)
(:html-preamble-format nil nil org-html-preamble-format)
(:html-prefer-user-labels nil nil org-html-prefer-user-labels)
***************
*** 171,179 ****
nil nil org-html-table-use-header-tags-for-first-column)
(:html-tag-class-prefix nil nil org-html-tag-class-prefix)
(:html-text-markup-alist nil nil org-html-text-markup-alist)
(:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix)
(:html-toplevel-hlevel nil nil org-html-toplevel-hlevel)
! (:html-use-infojs nil nil org-html-use-infojs)
(:html-validation-link nil nil org-html-validation-link)
(:html-viewport nil nil org-html-viewport)
(:html-inline-images nil nil org-html-inline-images)
--- 198,207 ----
nil nil org-html-table-use-header-tags-for-first-column)
(:html-tag-class-prefix nil nil org-html-tag-class-prefix)
(:html-text-markup-alist nil nil org-html-text-markup-alist)
+ (:html-toc-title nil "html-toc-title" org-html-toc-title)
(:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix)
(:html-toplevel-hlevel nil nil org-html-toplevel-hlevel)
! (:html-use-infojs nil nil org-export-html-use-infojs)
(:html-validation-link nil nil org-html-validation-link)
(:html-viewport nil nil org-html-viewport)
(:html-inline-images nil nil org-html-inline-images)
***************
*** 186,191 ****
--- 214,221 ----
(:html-klipse-css nil nil org-html-klipse-css)
(:html-klipse-js nil nil org-html-klipse-js)
(:html-klipse-selection-script nil nil org-html-klipse-selection-script)
+ ;;; (:multipage-split nil nil org-html-multipage-split)
+ ;;; (:multipage nil nil org-html-multipage)
(:infojs-opt "INFOJS_OPT" nil nil)
;; Redefine regular options.
(:creator "CREATOR" nil org-html-creator-string)
***************
*** 462,467 ****
--- 492,720 ----
:package-version '(Org . "9.5")
:type 'string)
+ (defcustom org-html-multipage-style-default
+ ""
+ "The default style specification for exported HTML files.
+ You can use `org-html-head' and `org-html-head-extra' to add to
+ this style. If you don't want to include this default style,
+ customize `org-html-head-include-default-style'."
+ :group 'org-export-html
+ :package-version '(Org . "9.8")
+ :type 'string)
;;; User Configuration Variables
***************
*** 486,492 ****
(home LINK_HOME :html-link-home))
"JavaScript options, long form for script, default values.")
! (defcustom org-html-use-infojs 'when-configured
"Non-nil when Sebastian Rose's Java Script org-info.js should be active.
This option can be nil or t to never or always use the script.
It can also be the symbol `when-configured', meaning that the
--- 739,745 ----
(home LINK_HOME :html-link-home))
"JavaScript options, long form for script, default values.")
! (defcustom org-export-html-use-infojs 'when-configured
"Non-nil when Sebastian Rose's Java Script org-info.js should be active.
This option can be nil or t to never or always use the script.
It can also be the symbol `when-configured', meaning that the
***************
*** 501,506 ****
--- 754,766 ----
(const :tag "When configured in buffer" when-configured)
(const :tag "Always" t)))
+ ;; (defcustom org-html-multipage nil
+ ;; "Boolean indicating multipage export."
+ ;; :group 'org-export-html
+ ;; :version "29.4"
+ ;; :package-version '(Org . "9.8")
+ ;; :type 'boolean)
+
(defcustom org-html-infojs-options
(mapcar (lambda (x) (cons (car x) (nth 2 x))) org-html-infojs-opts-table)
"Options settings for the INFOJS JavaScript.
***************
*** 849,854 ****
--- 1109,1129 ----
:group 'org-export-html
:type 'boolean)
+ (defcustom org-html-numbered-link-format
+ '("Chapter %s"
+ "Section %s"
+ "Fig. %s")
+ "Format for the labels of numbered links.
+
+ The first string is used for links to Chapters, the second for
+ links to Sections and the third for links to Figures. %s will be
+ replaced by the number of the reference. The strings get
+ translated using org-html--translate."
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'list)
+
;;;; Links :: Inline images
(defcustom org-html-inline-images t
***************
*** 1384,1389 ****
--- 1659,1673 ----
(list (string :tag "Language")
(string :tag "Format string"))))
+ (defcustom org-html-toc-title "Table of Contents"
+ "The string tp be used for the title of the table of contents. It
+ will be passed to org-html-translate."
+ :group 'org-export-html
+ :package-version '(Org . "9.8")
+ :version "29.4"
+ :type 'string
+ :safe #'stringp)
+
(defcustom org-html-validation-link
"Validate"
"Link to HTML validation service."
***************
*** 1522,1529 ****
--- 1806,1954 ----
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
+
+ (defcustom org-html-multipage-clear-export-directory t
+ "Boolean. If non-nil remove all .html files from the export
+ directory before exporting."
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'boolean)
+
+ (defcustom org-html-multipage-export-directory "html"
+ "The default directory for exported HTML files."
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'string)
+
+ (defcustom org-html-multipage-head-include-default-style t
+ "Non-nil means include the default style in exported HTML files.
+ The actual style is defined in `org-html-style-default' and
+ should not be modified. Use `org-html-head' to use your own
+ style information."
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'boolean)
+
+ (defcustom org-html-multipage-join-empty-bodies t
+ "Recursively join subheadlines, if a headline doesn't contain any
+ text before its Subheadline.
+
+ Example:
+
+ * Headline 1
+ ** Subheadline 1.1
+ *** Subsubheadline 1.1.1
+ Text of Subsubheadline 1.1.1
+
+ will be put on the same HTML page if this option is set,
+ otherwise Headline 1 And Subheadline 1.1 will be put on a
+ separate HTML page with empty content.
+ "
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'boolean)
+
+ (defcustom org-html-multipage-nav-format
+ '("
%s
"
+ "Next: %s , "
+ "Previous: %s , "
+ "Up: %s , "
+ "Home: %s ")
+ "Snippets used to insert the NEXT, PREV, HOME and UP links in
+ multipage output. The list contains format strings for the HTML
+ div and the navigation elements. The %s in the HTML div will
+ receive a concatenated string of the navigation elements. The
+ first %s in the navigation elements will receive the link,
+ the second the title"
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'list)
+
+ (defcustom org-html-multipage-numbered-filenames t
+ "Boolean indicating whether filenames in multipage export should
+ get their headline-numbering prepended. Note: This option is
+ independent of the num: option and the backend guarantees that
+ filenames are unique in any case."
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'boolean)
+
+ (defcustom org-html-multipage-open 'nil
+ "If and where to open the top page of the multipage html after
+ export."
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type '(choice (const browser) (const buffer) (const nil)))
+
+ (defcustom org-html-multipage-postamble-position 'bottom
+ "The position of the postamble in the html output.
+
+ bottom - at the bottom of the page, directly before
+
+ text-content - at the top of the text-content.
+
+ "
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type '(choice (const top) (const text-content)))
+
+ (defcustom org-html-multipage-split-hooks nil
+ "list of additional custom functions to be called during the
+ export after multipage splitting has taken place and before
+ transcoding with info as input.
+ "
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'list)
+
+ (defcustom org-html-multipage-split-level 'toc
+ "How to split the ORG file into multiple HTML pages.
+
+ toc - split each entry of the toc into a separate page.
+
+ number - a number indicating the maximum headline-level for
+ splitting.
+ "
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type '(choice (const toc) (number :tag "Headline Level" 3)))
+
+ (defcustom org-html-multipage-toc-to-top t
+ "If t links in the TOC will always point to the top of the page,
+ otherwise it will link directly to the referenced headline
+ element."
+ :group 'org-export-html
+ :version "29.4"
+ :package-version '(Org . "9.8")
+ :type 'boolean)
+
;;;###autoload
(put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
+ (put 'org-html-multipage-head-include-default-style 'safe-local-variable 'booleanp)
+ (put 'org-html-multipage-join-empty-bodies 'safe-local-variable 'booleanp)
(defcustom org-html-head ""
"Org-wide head definitions for exported HTML files.
***************
*** 1873,1890 ****
(defun org-html-footnote-section (info)
"Format the footnote section.
INFO is a plist used as a communication channel."
! (pcase (org-export-collect-footnote-definitions info)
(`nil nil)
(definitions
- (format
- (plist-get info :html-footnotes-section)
- (org-html--translate "Footnotes" info)
(format
! "\n%s\n"
! (mapconcat
! (lambda (definition)
! (pcase definition
! (`(,n ,label ,def)
;; Do not assign number labels as they appear in Org mode
;; - the footnotes are re-numbered by
;; `org-export-get-footnote-number'. If the label is not
--- 2298,2315 ----
(defun org-html-footnote-section (info)
"Format the footnote section.
INFO is a plist used as a communication channel."
! (pcase (org-export-collect-footnote-definitions info (plist-get info :tl-headline))
(`nil nil)
(definitions
(format
! (plist-get info :html-footnotes-section)
! (org-html--translate "Footnotes" info)
! (format
! "\n%s\n"
! (mapconcat
! (lambda (definition)
! (pcase definition
! (`(,n ,label ,def)
;; Do not assign number labels as they appear in Org mode
;; - the footnotes are re-numbered by
;; `org-export-get-footnote-number'. If the label is not
***************
*** 1911,1918 ****
(if (not inline?) contents
(format "
\n"))))
--- 2942,2974 ----
(defun org-html--toc-text (toc-entries)
"Return innards of a table of contents, as a string.
TOC-ENTRIES is an alist where key is an entry title, as a string,
! second element a flag whether the entry gets a
! class=\"toc-hidden\" attribute and the third element is its
! relative level, as an integer."
! (let* ((prev-level (1- (cddar toc-entries)))
(start-level prev-level))
(concat
(mapconcat
(lambda (entry)
(let ((headline (car entry))
! (hidden (cadr entry))
! (level (cddr entry)))
(concat
! (format
! (let* ((cnt (- level prev-level))
! (times (if (> cnt 0) (1- cnt) (- cnt))))
! (setq prev-level level)
! (concat
! (org-html--make-string
! times (cond ((> cnt 0) (format "\n
\n"
+ (concat "\n" (org-html-close-tag "br" nil info) "\n"
+ "%s\n"))
+ (org-export-data subtitle info))
+ "")))))
+ contents
+ (format "%s>\n" (nth 1 (assq 'content (plist-get info :html-divs))))
+ ;; Possibly use the Klipse library live code blocks.
+ (when (plist-get info :html-klipsify-src)
+ (concat ""))
+ (when (eq org-html-multipage-postamble-position 'bottom)
+ (org-html--build-pre/postamble 'postamble info))
+ ;; Closing document.
+ "\n"))
+
+ (defun org-html-multipage-inner-template (contents info)
+ "Return body of document string after HTML conversion.
+ CONTENTS is the transcoded contents string. INFO is a plist
+ holding export options.
+
+ DATA contains the subtree of the parse tree of the section to be
+ exported for multipage export.
+ "
+ ;; Navigation
+ (let* ((data (plist-get info :tl-headline))
+ (section-nav-lookup
+ (alist-get
+ data
+ (plist-get info :section-nav-lookup))))
+ (format "
%s\n
%s
%s
"
+ (org-html-nav-left section-nav-lookup)
+ (concat
+ ;; Document contents.
+ contents
+ ;; Footnotes section.
+ (or (org-html-footnote-section info) "")
+ ;; Postamble.
+ (unless (eq org-html-multipage-postamble-position 'bottom)
+ (org-html--build-pre/postamble 'postamble info)))
+ (org-html-nav-right section-nav-lookup))))
+
+ (defun org-html-transcode-org-data (data content info)
+ "Transcode the top org-data node of the org file to export.
+
+ It is called by `org-export-as' after all necessary information
+ has been added to info and the final parse-tree has been
+ generated. Multipage information has already been collected by
+ calling `org-html-multipage-filter' in `org-export-annotate-info'
+ using the :multipage-split property.
+
+ INFO is a plist used as a communication channel."
+ (message "transcoding data!")
+ (if (plist-get info :multipage)
+ ;;; for multipage output we don't need data and content as all
+ ;;; information is already collected in info.
+ (org-html-transcode-multipage info)
+ (org-export-transcode-org-data data content info)))
(provide 'ox-html)
***************
*** 4100,4102 ****
--- 5485,5489 ----
;; End:
;;; ox-html.el ends here
+
+