From 49877e2e95f23012856db676b48b234f9fbb9eab Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Mon, 3 Jan 2022 23:31:30 -0500 Subject: [PATCH 1/6] Rename an internal function name for consistency The "maybe" function names *end* with `-maybe`. --- ox-hugo.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ox-hugo.el b/ox-hugo.el index 72c15535..13bcde08 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -2425,7 +2425,7 @@ and rewrite link paths to make blogging more seamless." "")))) ;;;;; Helpers -(defun org-hugo--maybe-copy-resources (info) +(defun org-hugo--copy-resources-maybe (info) "Copy resources to the bundle directory if needed. INFO is a plist used as a communication channel." @@ -2929,7 +2929,7 @@ INFO is a plist holding export options." BODY is the result of the export. INFO is a plist holding export options." ;; Copy the page resources to the bundle directory. - (org-hugo--maybe-copy-resources info) + (org-hugo--copy-resources-maybe info) ;; (message "[ox-hugo body filter] ITEM %S" (org-entry-get (point) "ITEM")) ;; (message "[ox-hugo body filter] TAGS: %S" (org-entry-get (point) "TAGS")) ;; (message "[ox-hugo body filter] ALLTAGS: %S" (org-entry-get (point) "ALLTAGS")) From 325f21464a5421faa3584347d683870e89033483 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 4 Jan 2022 00:28:42 -0500 Subject: [PATCH 2/6] Support `tex:dvisvgm` export option This option exports inline and block LaTeX equations as SVG files. ox-hugo then takes care of copying the exported SVG files to the site's `static/ltximg/` directory. NOTE: The user will need to take care of deleting all the old SVG files which are no longer used. Fixes https://github.com/kaushalmodi/ox-hugo/issues/327. --- ox-blackfriday.el | 40 ++++++++++++++++++- ox-hugo.el | 17 ++++++++ test/site/content-org/all-posts.org | 21 ++++++++++ ...e9e5d17c9e7a6e0fb64dba06c0d3466b8d9542.svg | 36 +++++++++++++++++ ...ee782e7b4ae762ba5504ce2f6f7515c733c34c.svg | 14 +++++++ .../posts/equations-exported-to-svg.md | 29 ++++++++++++++ ...e9e5d17c9e7a6e0fb64dba06c0d3466b8d9542.svg | 36 +++++++++++++++++ ...ee782e7b4ae762ba5504ce2f6f7515c733c34c.svg | 14 +++++++ 8 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 test/site/content-org/ltximg/all-posts_bfe9e5d17c9e7a6e0fb64dba06c0d3466b8d9542.svg create mode 100644 test/site/content-org/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg create mode 100644 test/site/content/posts/equations-exported-to-svg.md create mode 100644 test/site/static/ltximg/all-posts_bfe9e5d17c9e7a6e0fb64dba06c0d3466b8d9542.svg create mode 100644 test/site/static/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg diff --git a/ox-blackfriday.el b/ox-blackfriday.el index 8fe5b7b2..d5646775 100644 --- a/ox-blackfriday.el +++ b/ox-blackfriday.el @@ -60,6 +60,11 @@ Note that this variable is *only* for internal use.") (figure . "Figure")) ;Note that `figure' is not an actual Org element "Alist of strings used to represent various Org elements.") +(defvar org-blackfriday--ltximg-directory "ltximg/" + "Sub directory created inside the site's static directory for LaTeX images. + +This sub directory is created when an export option like +`tex:dvisvgm' is used.") ;;; User-Configurable Variables @@ -798,6 +803,35 @@ exported instead: (org-trim (replace-regexp-in-string "^" " " contents)))))))) ;;;; Latex Environment +(defun org-blackfriday--update-ltximg-path (html-str) + "Update the path to latex exported images directory. + +For example, this function converts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/site/content-org/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg b/test/site/content-org/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg new file mode 100644 index 00000000..f6db325e --- /dev/null +++ b/test/site/content-org/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/site/content/posts/equations-exported-to-svg.md b/test/site/content/posts/equations-exported-to-svg.md new file mode 100644 index 00000000..d118aa73 --- /dev/null +++ b/test/site/content/posts/equations-exported-to-svg.md @@ -0,0 +1,29 @@ ++++ +title = "Equations exported to SVG (dvisvgm)" +description = "Exporting LaTeX equations as SVG images." +tags = ["equations", "dvisvgm"] +draft = false ++++ + +`ox-hugo` Issue #[327](https://github.com/kaushalmodi/ox-hugo/issues/327) + +Example of an inline equation: \[ a + b \] + +Example of a block equation: + +\begin{equation*}
+C = W\log_{2} (1+\mathrm{SNR})
+\end{equation*}
+ + + +1 + + + +
+ +Referencing to equation labels does not work when LaTeX +equations are exported as images. + +
diff --git a/test/site/static/ltximg/all-posts_bfe9e5d17c9e7a6e0fb64dba06c0d3466b8d9542.svg b/test/site/static/ltximg/all-posts_bfe9e5d17c9e7a6e0fb64dba06c0d3466b8d9542.svg new file mode 100644 index 00000000..dc087a6f --- /dev/null +++ b/test/site/static/ltximg/all-posts_bfe9e5d17c9e7a6e0fb64dba06c0d3466b8d9542.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/site/static/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg b/test/site/static/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg new file mode 100644 index 00000000..f6db325e --- /dev/null +++ b/test/site/static/ltximg/all-posts_ceee782e7b4ae762ba5504ce2f6f7515c733c34c.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file From bb4f43399d82190b143773bb0e1e4c13c0a11166 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 4 Jan 2022 00:37:49 -0500 Subject: [PATCH 3/6] Make latex available on GHA --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae55beac..a98613cf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,7 @@ jobs: - uses: purcell/setup-emacs@master with: version: ${{ matrix.emacs_version }} + - uses: xu-cheng/latex-action@v2 # For Org tests with `tex:dvisvgm` export option # Don't run "make doc"; it's finicky as it could fail on running the getJSON command in hugo. # - name: make doc # run: make --no-print-directory doc # Just ensure that "make doc" doesn't fail for any reason.. this is *not* used to do Org->Markdown doc conversion From ace73db73d5a1e4fe86cf0714d6772cda31cc274 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 4 Jan 2022 00:42:43 -0500 Subject: [PATCH 4/6] Another attempt to make dvisvgm tests works on GHA --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a98613cf..b96a7e30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,12 @@ jobs: - uses: purcell/setup-emacs@master with: version: ${{ matrix.emacs_version }} - - uses: xu-cheng/latex-action@v2 # For Org tests with `tex:dvisvgm` export option + # https://github.com/xu-cheng/texlive-action#example + - uses: xu-cheng/texlive-action/small@v1 # For Org tests with `tex:dvisvgm` export option + with: + run: | + apk add make + make # Don't run "make doc"; it's finicky as it could fail on running the getJSON command in hugo. # - name: make doc # run: make --no-print-directory doc # Just ensure that "make doc" doesn't fail for any reason.. this is *not* used to do Org->Markdown doc conversion From 7738056cc2a67c7a883d2800a6a5e10d7a90cf0c Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 4 Jan 2022 00:48:15 -0500 Subject: [PATCH 5/6] Another attempt (num 2) to make dvisvgm tests works on GHA --- .github/workflows/test.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b96a7e30..aaed7e51 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,11 +32,7 @@ jobs: with: version: ${{ matrix.emacs_version }} # https://github.com/xu-cheng/texlive-action#example - - uses: xu-cheng/texlive-action/small@v1 # For Org tests with `tex:dvisvgm` export option - with: - run: | - apk add make - make + - uses: xu-cheng/texlive-action/full@v1 # For Org tests with `tex:dvisvgm` export option # Don't run "make doc"; it's finicky as it could fail on running the getJSON command in hugo. # - name: make doc # run: make --no-print-directory doc # Just ensure that "make doc" doesn't fail for any reason.. this is *not* used to do Org->Markdown doc conversion From e4722d0be5b39082455fe23a006714b286492749 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 4 Jan 2022 01:12:49 -0500 Subject: [PATCH 6/6] Disable the dvisvgm test during `make test` I am unable to make latex + dvisvgm installation work on GHA Re-enable this test once https://github.com/xu-cheng/texlive-action/issues/6 is resolved. --- .github/workflows/test.yml | 2 -- test/site/content-org/all-posts.org | 2 +- test/site/content/posts/equations-exported-to-svg.md | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aaed7e51..ae55beac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,8 +31,6 @@ jobs: - uses: purcell/setup-emacs@master with: version: ${{ matrix.emacs_version }} - # https://github.com/xu-cheng/texlive-action#example - - uses: xu-cheng/texlive-action/full@v1 # For Org tests with `tex:dvisvgm` export option # Don't run "make doc"; it's finicky as it could fail on running the getJSON command in hugo. # - name: make doc # run: make --no-print-directory doc # Just ensure that "make doc" doesn't fail for any reason.. this is *not* used to do Org->Markdown doc conversion diff --git a/test/site/content-org/all-posts.org b/test/site/content-org/all-posts.org index 646594ea..b65e09b5 100644 --- a/test/site/content-org/all-posts.org +++ b/test/site/content-org/all-posts.org @@ -3521,7 +3521,7 @@ spacing: \[a\;b\] \[a\:b\] \[a\!b\] -** Equations exported to SVG (dvisvgm) :dvisvgm: +** Equations exported to SVG (dvisvgm) :dvisvgm:dont_export_during_make_test: :PROPERTIES: :EXPORT_FILE_NAME: equations-exported-to-svg :EXPORT_OPTIONS: tex:dvisvgm diff --git a/test/site/content/posts/equations-exported-to-svg.md b/test/site/content/posts/equations-exported-to-svg.md index d118aa73..60c05f51 100644 --- a/test/site/content/posts/equations-exported-to-svg.md +++ b/test/site/content/posts/equations-exported-to-svg.md @@ -1,7 +1,7 @@ +++ title = "Equations exported to SVG (dvisvgm)" description = "Exporting LaTeX equations as SVG images." -tags = ["equations", "dvisvgm"] +tags = ["equations", "dvisvgm", "dont-export-during-make-test"] draft = false +++