diff --git a/test/setup-ox-hugo.el b/test/setup-ox-hugo.el index 4d8b0302..6f8cd422 100644 --- a/test/setup-ox-hugo.el +++ b/test/setup-ox-hugo.el @@ -189,6 +189,11 @@ to be installed.") (setq ox-hugo-missing-packages '()))) (error "The environment variable OX_HUGO_TMP_DIR needs to be set")) +;; Fixes for Org mode that haven't yet been released to GNU Elpa +(when ox-hugo-install-org-from-elpa + (add-to-list 'load-path (concat ox-hugo-site-git-root "test/")) + (require 'upstream-org-fixes)) + (require 'oc-csl nil :noerror) ;Auto-register csl processor (require 'org-ref) diff --git a/test/site/content-org/all-posts.org b/test/site/content-org/all-posts.org index eb9d9db7..d16e832a 100644 --- a/test/site/content-org/all-posts.org +++ b/test/site/content-org/all-posts.org @@ -2651,11 +2651,13 @@ TOML front-matter. But the big integer "10040216507682529280" which would need more than 64-bits to be stored as a signed integer is left as a string in the TOML front-matter. -** Custom front matter value via Elisp :elisp: +** Custom front matter value via Elisp :elisp:noexport: :PROPERTIES: :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :attendees (xeijin/conv-chkbox-items-to-front-matter "Attendees") :EXPORT_AUTHOR: xeijin :END: +<2022-12-13 Tue> These tests fail to run on the CI in Org 9.6 due to +[[https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=10e857d42859a55b23cd4206ffce3ebd0f678583][this change]]. For now, remove these tests from CI. *** Meeting 1 :PROPERTIES: :EXPORT_FILE_NAME: custom-fm-convert-chkbox-list-to-fm-1 diff --git a/test/site/content/dir-locals-test/dir-locals-test.md b/test/site/content/dir-locals-test/dir-locals-test.md index 3e21d5e8..91aa7286 100644 --- a/test/site/content/dir-locals-test/dir-locals-test.md +++ b/test/site/content/dir-locals-test/dir-locals-test.md @@ -46,4 +46,4 @@ creator: "Dummy creator string" `This is verbatim` but this is wrapped in the `kbd` tag. As `org-hugo-preserve-filling` is set to `nil`, the column filling in the Org source is not preserved in the exported Markdown. -This text is auto inserted at the end of the exported Markdown. +This text is auto inserted at the end of the exported Markdown. \ No newline at end of file diff --git a/test/site/content/posts/footnote-with-src-block.md b/test/site/content/posts/footnote-with-src-block.md index c1b05a72..ad50a87c 100644 --- a/test/site/content/posts/footnote-with-src-block.md +++ b/test/site/content/posts/footnote-with-src-block.md @@ -12,4 +12,4 @@ Testing code in a footnote with a `#+begin_src` directive.[^fn:1] [^fn:1]: ```elisp (emacs-version) (org-version) - ``` + ``` \ No newline at end of file diff --git a/test/site/content/posts/footnotes-1.md b/test/site/content/posts/footnotes-1.md index 66fc2a7e..eaba33f5 100644 --- a/test/site/content/posts/footnotes-1.md +++ b/test/site/content/posts/footnotes-1.md @@ -10,4 +10,4 @@ This is some text[^fn:1]. _Note to self: You **cannot** name an Org heading 'Footnotes'; that's reserved by Org to store all the footnotes._ -[^fn:1]: First footnote +[^fn:1]: First footnote \ No newline at end of file diff --git a/test/site/content/posts/footnotes-2.md b/test/site/content/posts/footnotes-2.md index 13259667..1612ef25 100644 --- a/test/site/content/posts/footnotes-2.md +++ b/test/site/content/posts/footnotes-2.md @@ -7,4 +7,4 @@ draft = false This is some text[^fn:1]. -[^fn:1]: Second footnote +[^fn:1]: Second footnote \ No newline at end of file diff --git a/test/site/content/posts/footnotes-bind-to-preceding-word.md b/test/site/content/posts/footnotes-bind-to-preceding-word.md index 0e50ff60..ee9a00bf 100644 --- a/test/site/content/posts/footnotes-bind-to-preceding-word.md +++ b/test/site/content/posts/footnotes-bind-to-preceding-word.md @@ -166,4 +166,4 @@ a a [^fn:1]. B b b. abcde a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a [^fn:1]. B b b. -[^fn:1]: First footnote +[^fn:1]: First footnote \ No newline at end of file diff --git a/test/site/content/posts/footnotes-in-a-row.md b/test/site/content/posts/footnotes-in-a-row.md index 8b5ab041..e7e779ac 100644 --- a/test/site/content/posts/footnotes-in-a-row.md +++ b/test/site/content/posts/footnotes-in-a-row.md @@ -8,4 +8,4 @@ draft = false This is some text[^fn:1], [^fn:2]. [^fn:1]: First footnote -[^fn:2]: Second footnote +[^fn:2]: Second footnote \ No newline at end of file diff --git a/test/site/content/posts/multi-line-footnote-blackfriday.md b/test/site/content/posts/multi-line-footnote-blackfriday.md index 1ed955fd..e4ecda20 100644 --- a/test/site/content/posts/multi-line-footnote-blackfriday.md +++ b/test/site/content/posts/multi-line-footnote-blackfriday.md @@ -6,4 +6,4 @@ draft = false This is some text[^fn:1]. -[^fn:1]: This is a long footnote. It is so long that it gets auto-filled over multiple lines. But even then it should be handled fine. +[^fn:1]: This is a long footnote. It is so long that it gets auto-filled over multiple lines. But even then it should be handled fine. \ No newline at end of file diff --git a/test/site/content/posts/multi-line-footnote-goldmark.md b/test/site/content/posts/multi-line-footnote-goldmark.md index f8cf42b3..bb94038b 100644 --- a/test/site/content/posts/multi-line-footnote-goldmark.md +++ b/test/site/content/posts/multi-line-footnote-goldmark.md @@ -8,4 +8,4 @@ draft = false This is some text[^fn:1]. [^fn:1]: This is a long footnote. It is so long that it gets auto-filled - over multiple lines. But even then it should be handled fine. + over multiple lines. But even then it should be handled fine. \ No newline at end of file diff --git a/test/site/content/posts/multi-line-footnote-japanese.md b/test/site/content/posts/multi-line-footnote-japanese.md index 2e0aff7e..b05a6c9b 100644 --- a/test/site/content/posts/multi-line-footnote-japanese.md +++ b/test/site/content/posts/multi-line-footnote-japanese.md @@ -16,4 +16,4 @@ Here is a footnote entirely in English[^fn:3]. [^fn:2]: English on line 1 の Japanese on line 2 [^fn:3]: This is a long footnote. It is so long that it gets auto-filled - over multiple lines. But even then it should be handled fine. + over multiple lines. But even then it should be handled fine. \ No newline at end of file diff --git a/test/site/content/posts/multi-ref-same-footnote.md b/test/site/content/posts/multi-ref-same-footnote.md index e191ba66..f670513d 100644 --- a/test/site/content/posts/multi-ref-same-footnote.md +++ b/test/site/content/posts/multi-ref-same-footnote.md @@ -9,4 +9,4 @@ This is some text[^fn:1]. This is some text[^fn:1]. This is some text[^fn:1]. -[^fn:1]: First footnote +[^fn:1]: First footnote \ No newline at end of file diff --git a/test/site/content/writing-hugo-blog-in-org-file-export.md b/test/site/content/writing-hugo-blog-in-org-file-export.md index 61952fa6..fa4c347c 100644 --- a/test/site/content/writing-hugo-blog-in-org-file-export.md +++ b/test/site/content/writing-hugo-blog-in-org-file-export.md @@ -44,4 +44,4 @@ Variables_ section below. [//]: # "Exported with love from a post written in Org mode" -[//]: # "- https://github.com/kaushalmodi/ox-hugo" +[//]: # "- https://github.com/kaushalmodi/ox-hugo" \ No newline at end of file diff --git a/test/site/content/writing-hugo-blog-in-org-subtree-export.md b/test/site/content/writing-hugo-blog-in-org-subtree-export.md index 23d0faed..cf850de1 100644 --- a/test/site/content/writing-hugo-blog-in-org-subtree-export.md +++ b/test/site/content/writing-hugo-blog-in-org-subtree-export.md @@ -43,4 +43,4 @@ Variables_ section below. [//]: # "Exported with love from a post written in Org mode" -[//]: # "- https://github.com/kaushalmodi/ox-hugo" +[//]: # "- https://github.com/kaushalmodi/ox-hugo" \ No newline at end of file diff --git a/test/upstream-org-fixes.el b/test/upstream-org-fixes.el new file mode 100644 index 00000000..262a45f4 --- /dev/null +++ b/test/upstream-org-fixes.el @@ -0,0 +1,180 @@ +;; Fixes for Org mode that haven't yet been released to GNU Elpa + +;; https://lists.gnu.org/r/emacs-orgmode/2023-01/msg00287.html +;; https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a52d0f091 +(defun fixed/org-export-as + (backend &optional subtreep visible-only body-only ext-plist) + "Transcode current Org buffer into BACKEND code. + +BACKEND is either an export back-end, as returned by, e.g., +`org-export-create-backend', or a symbol referring to +a registered back-end. + +If narrowing is active in the current buffer, only transcode its +narrowed part. + +If a region is active, transcode that region. + +When optional argument SUBTREEP is non-nil, transcode the +sub-tree at point, extracting information from the headline +properties first. + +When optional argument VISIBLE-ONLY is non-nil, don't export +contents of hidden elements. + +When optional argument BODY-ONLY is non-nil, only return body +code, without surrounding template. + +Optional argument EXT-PLIST, when provided, is a property list +with external parameters overriding Org default settings, but +still inferior to file-local settings. + +Return code as a string." + (when (symbolp backend) (setq backend (org-export-get-backend backend))) + (org-export-barf-if-invalid-backend backend) + (org-fold-core-ignore-modifications + (save-excursion + (save-restriction + ;; Narrow buffer to an appropriate region or subtree for + ;; parsing. If parsing subtree, be sure to remove main + ;; headline, planning data and property drawer. + (cond ((org-region-active-p) + (narrow-to-region (region-beginning) (region-end))) + (subtreep + (org-narrow-to-subtree) + (goto-char (point-min)) + (org-end-of-meta-data) + ;; Make the region include top heading in the subtree. + ;; This way, we will be able to retrieve its export + ;; options when calling + ;; `org-export--get-subtree-options'. + (when (bolp) (backward-char)) + (narrow-to-region (point) (point-max)))) + ;; Initialize communication channel with original buffer + ;; attributes, unavailable in its copy. + (let* ((org-export-current-backend (org-export-backend-name backend)) + (info (org-combine-plists + (org-export--get-export-attributes + backend subtreep visible-only body-only) + (org-export--get-buffer-attributes))) + (parsed-keywords + (delq nil + (mapcar (lambda (o) (and (eq (nth 4 o) 'parse) (nth 1 o))) + (append (org-export-get-all-options backend) + org-export-options-alist)))) + tree modified-tick) + ;; Update communication channel and get parse tree. Buffer + ;; isn't parsed directly. Instead, all buffer modifications + ;; and consequent parsing are undertaken in a temporary copy. + (org-export-with-buffer-copy + (font-lock-mode -1) + ;; Run first hook with current back-end's name as argument. + (run-hook-with-args 'org-export-before-processing-hook + (org-export-backend-name backend)) + (org-export-expand-include-keyword) + (org-export--delete-comment-trees) + (org-macro-initialize-templates org-export-global-macros) + (org-macro-replace-all org-macro-templates parsed-keywords) + ;; Refresh buffer properties and radio targets after previous + ;; potentially invasive changes. + (org-set-regexps-and-options) + (org-update-radio-target-regexp) + (setq modified-tick (buffer-chars-modified-tick)) + ;; Possibly execute Babel code. Re-run a macro expansion + ;; specifically for {{{results}}} since inline source blocks + ;; may have generated some more. Refresh buffer properties + ;; and radio targets another time. + (when org-export-use-babel + (org-babel-exp-process-buffer) + (org-macro-replace-all '(("results" . "$1")) parsed-keywords) + (unless (eq modified-tick (buffer-chars-modified-tick)) + (org-set-regexps-and-options) + (org-update-radio-target-regexp)) + (setq modified-tick (buffer-chars-modified-tick))) + ;; Run last hook with current back-end's name as argument. + ;; Update buffer properties and radio targets one last time + ;; before parsing. + (goto-char (point-min)) + (save-excursion + (run-hook-with-args 'org-export-before-parsing-hook + (org-export-backend-name backend))) + (unless (eq modified-tick (buffer-chars-modified-tick)) + (org-set-regexps-and-options) + (org-update-radio-target-regexp)) + (setq modified-tick (buffer-chars-modified-tick)) + ;; Update communication channel with environment. + (setq info + (org-combine-plists + info (org-export-get-environment backend subtreep ext-plist))) + ;; Pre-process citations environment, i.e. install + ;; bibliography list, and citation processor in INFO. + (org-cite-store-bibliography info) + (org-cite-store-export-processor info) + ;; De-activate uninterpreted data from parsed keywords. + (dolist (entry (append (org-export-get-all-options backend) + org-export-options-alist)) + (pcase entry + (`(,p ,_ ,_ ,_ parse) + (let ((value (plist-get info p))) + (plist-put info + p + (org-export--remove-uninterpreted-data value info)))) + (_ nil))) + ;; Install user's and developer's filters. + (setq info (org-export-install-filters info)) + ;; Call options filters and update export options. We do not + ;; use `org-export-filter-apply-functions' here since the + ;; arity of such filters is different. + (let ((backend-name (org-export-backend-name backend))) + (dolist (filter (plist-get info :filter-options)) + (let ((result (funcall filter info backend-name))) + (when result (setq info result))))) + ;; Parse buffer. + (setq tree (org-element-parse-buffer nil visible-only)) + ;; Prune tree from non-exported elements and transform + ;; uninterpreted elements or objects in both parse tree and + ;; communication channel. + (org-export--prune-tree tree info) + (org-export--remove-uninterpreted-data tree info) + ;; Call parse tree filters. + (setq tree + (org-export-filter-apply-functions + (plist-get info :filter-parse-tree) tree info)) + ;; Now tree is complete, compute its properties and add them + ;; to communication channel. + (setq info (org-export--collect-tree-properties tree info)) + ;; Process citations and bibliography. Replace each citation + ;; and "print_bibliography" keyword in the parse tree with + ;; the output of the selected citation export processor. + (org-cite-process-citations info) + (org-cite-process-bibliography info) + ;; Eventually transcode TREE. Wrap the resulting string into + ;; a template. + (let* ((body (org-element-normalize-string + (or (org-export-data tree info) ""))) + (inner-template (cdr (assq 'inner-template + (plist-get info :translate-alist)))) + (full-body (org-export-filter-apply-functions + (plist-get info :filter-body) + (if (not (functionp inner-template)) body + (funcall inner-template body info)) + info)) + (template (cdr (assq 'template + (plist-get info :translate-alist)))) + (output + (if (or (not (functionp template)) body-only) full-body + (funcall template full-body info)))) + ;; Call citation export finalizer. + (setq output (org-cite-finalize-export output info)) + ;; Remove all text properties since they cannot be + ;; retrieved from an external process. Finally call + ;; final-output filter and return result. + (org-no-properties + (org-export-filter-apply-functions + (plist-get info :filter-final-output) + output info))))))))) +(advice-add 'org-export-as :override #'fixed/org-export-as) +;; (advice-remove 'org-export-as #'fixed/org-export-as) + + +(provide 'upstream-org-fixes)