kaushalmodi / ox-hugo

A carefully crafted Org exporter back-end for Hugo
https://ox-hugo.scripter.co
GNU General Public License v3.0
874 stars 132 forks source link

The org file with code blocks containing `{{% .. %}}` can't be rebuilt #680

Closed ChloeZhou1997 closed 1 year ago

ChloeZhou1997 commented 1 year ago

Actual Behavior

I am trying to use ox-hugo package in emacs to build my personal blog however I am encountering error message:“/Users/zhouqiaohui/Blog/content/en/post/emacs-learning/Emacs.md:1:1”: unrecognized character in shortcode action: U+002A ‘*’. Note: Parameters with non-alphanumeric args must be quoted when trying to export my personal init.el file to my personal page:

I have managed to discover once I removed the following block from my generated .md file the problem will be gone:

;; Follow Hugo links
(defun org-hugo-follow (link)
    "Follow Hugo link shortcodes"
    (org-link-open-as-file
     (string-trim "{{% ref test.org %}}" "{{% ref " "%}}")))

;; New link type for Org-Hugo internal links
(org-link-set-parameters
 "hugo"
 :complete (lambda ()
                         (concat "{{% ref */"
                                         (file-name-nondirectory
                                            (read-file-name "File: "))
                                         " %}}"))
 :follow #'org-hugo-follow)

If I only remove the function containing * *, the error message will still persist with shortcode " ".

Expected Behavior

I would expect the page to be built normally since all the special characters within "" are supposed to be built normally as what's said in Hugo document.

Someone has answered why the exported files will have such an error: https://discourse.gohugo.io/t/the-org-file-exported-from-ox-hugo-md-file-cant-be-rebuild/41119 . I am wondering if such an issue can be addressed.

kaushalmodi commented 1 year ago

@ChloeZhou1997 This issue got auto-closed when I merged the fix for this. But feel free to comment further if this issue is still unresolved for you.

Please wait for 5-6 hrs before a new version of ox-hugo containing this fix shows up on MELPA.