ardumont / org2jekyll

Blogging with org-mode and jekyll without alien yaml headers.
GNU General Public License v2.0
71 stars 19 forks source link

Publish org-roam articles #82

Open sati-bodhi opened 1 year ago

sati-bodhi commented 1 year ago

Hello,

Can you please provide the following information?

Thanks in advance.

bug?

I would like to use org2jekyll in conjunction with org-roam to publish some of my notes. All org-roam nodes start with a :PROPERTIES: drawer, which somehow fails the test of org2jekyll-get-options-from-buffer and returns nil, breaking the publish function.

M-x org2jekyll-bug-report

Edebug: org2jekyll-get-options-from-buffer
org2jekyll-get-options-from-buffer

Result: #<buffer 2022-12-15-still_face.org>

Result: #<buffer 2022-12-15-still_face.org>

Result: "/home/sati/org/roam/rainshoots/2022-12-15-still_fa..."

Result: #<buffer 2022-12-15-still_face.org>

Result: 1 (#o1, #x1, ?\C-a)

Result: 1 (#o1, #x1, ?\C-a)

Result: "^#\\+\\(.+\\):[    ]+\\(.*\\)$"

Result: (closure (t) nil (edebug-enter 'edebug-anon637 (list) #'(lambda nil (edebug-after (edebug-before 0) 5 (buffer-substring-no-properties (edebug-after (edebug-before 1) 2 (line-beginning-position)) (edebug-after (edebug-before 3) 4 (line-end-position)))))))

Result: 1 (#o1, #x1, ?\C-a)

Result: 13 (#o15, #xd, ?\C-m)

Result: ":PROPERTIES:"

Result: ":PROPERTIES:"

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: org2jekyll-publish-page

Result: org2jekyll-publish-page

Result: "/home/sati/org/roam/rainshoots/2022-12-15-still_fa..."

Result: 1 (#o1, #x1, ?\C-a)

Result: 1 (#o1, #x1, ?\C-a)

Result: "^#\\+\\(.+\\):[    ]+\\(.*\\)$"

Result: (closure (t) nil (edebug-enter 'edebug-anon637 (list) #'(lambda nil (edebug-after (edebug-before 0) 5 (buffer-substring-no-properties (edebug-after (edebug-before 1) 2 (line-beginning-position)) (edebug-after (edebug-before 3) 4 (line-end-position)))))))

Result: 1 (#o1, #x1, ?\C-a)

Result: 13 (#o15, #xd, ?\C-m)

Result: ":PROPERTIES:"

Result: ":PROPERTIES:"

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: nil

Result: "'2022-12-15-still_face.org' is not an article, pub..."

org2jekyll - Publish ‘’web‘’ project (images, css, js, etc...) done.
Result: t

Result: "'2022-12-15-still_face.org' is not an article, pub..."

org2jekyll - ’2022-12-15-still_face.org’ is not an article, publication skipped!
Result: "org2jekyll - ’2022-12-15-still_face.org’ is not an..."

Result: "org2jekyll - ’2022-12-15-still_face.org’ is not an..."

Result: "org2jekyll - ’2022-12-15-still_face.org’ is not an..."

Please:
- Describe your problem with clarity and conciceness (cf. https://www.gnu.org/software/emacs/manual/html_node/emacs/Understanding-Bug-Reporting.html)
- Explicit your installation choice (melpa, marmalade, el-get, tarball, git clone...).
- A sample of your configuration.
- Report the following message trace inside your issue.

System information:
- system-type: gnu/linux
- locale-coding-system: utf-8-unix
- emacs-version: GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
 of 2022-11-25
- org version: 9.6
- org2jekyll version: 0.2.7
- org2jekyll path: /home/sati/.emacs.d/.local/straight/build-28.2/org2jekyll/org2jekyll.el

Expected behavior

Article is published to jekyll _posts folder, as expected.

Actual behavior

Error:

’2022-12-15-still_face.org’ is not an article, publication skipped!

Steps to reproduce the behavior

Publish an article in org-roam with the relevant file headings.

Improvments?

What do you want?

Tweak the org2jekyll-get-options-from-buffer function to allow more flexibility.

Why is it better?

Users can build their blog using org-roam.

Thanks for sharing!

Cheers,

sati-bodhi commented 1 year ago

A quick hack fixes the problem. Just search for the next # after (point-min).

(defun org2jekyll-get-options-from-buffer ()
  "Return special lines at the beginning of current buffer."
  (let ((special-line-regex "^#\\+\\(.+\\):[ \t]+\\(.*\\)$")
        (get-current-line (lambda ()
                            (buffer-substring-no-properties (line-beginning-position)
                                                            (line-end-position))))
        (options-plist))
    (save-excursion
      (goto-char (point-min))
      (search-forward "#")
      (catch 'break
        (while (string-match special-line-regex (funcall get-current-line))
          (let ((current-line (funcall get-current-line)))
            (unless (s-blank-str-p (match-string 2 current-line))
              (setq options-plist (plist-put options-plist
                                             (->> current-line
                                               (match-string 1)
                                               downcase
                                               (concat ":")
                                               intern)
                                             (match-string 2 current-line)))))
          (unless (= 0 (forward-line))
            (throw 'break nil))))
      options-plist)))