Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export org as html file with syntax highlighting error via htmlize and emacs-tree-sitter #74

Closed
linw1995 opened this issue Nov 27, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@linw1995
Copy link

Reproduce the problem with the smallest example

There is the init.el file below.
And run emacs -Q -l init.el to set up the environment for reproducing the problem.

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq-default use-package-always-defer t)

(use-package htmlize
   :straight t)

(use-package tree-sitter
  :straight t
  :hook
  ((python-mode . tree-sitter-hl-mode)))

(use-package tree-sitter-langs
  :straight t
  :demand)

The test file test.org.

#+BEGIN_SRC python
  def hello(name):
      return f"hello {name}"

  hello("world")
#+END_SRC

Run emacs -Q -l init.el test.org and input <C-c C-e h h> to export org file as HTML file.
But it produces an error jit-lock-fontify-now: Wrong type argument: number-or-marker-p, nil

run with toggle-debug-on-error to get the backtrace of this error.

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  jit-lock--run-functions(1 60)
  jit-lock-fontify-now(1 60)
  org-font-lock-ensure()
  org-html-fontify-code("def hello(name):\n    return f\"hello {name}\"\n\nhello..." "python")
  org-html-do-format-code("def hello(name):\n    return f\"hello {name}\"\n\nhello..." "python" nil t nil nil)
  org-html-format-code((src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    retur..." :post-blank 0 :post-affiliated 1 ...)) (:export-options nil :back-end #s(org-export-backend :name html :parent nil :transcoders (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :options (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :filters (... ... ...) :blocks nil :menu (104 "Export to HTML" ...)) :translate-alist ((bold . org-html-bold) (center-block . org-html-center-block) (clock . org-html-clock) (code . org-html-code) (drawer . org-html-drawer) (dynamic-block . org-html-dynamic-block) (entity . org-html-entity) (example-block . org-html-example-block) (export-block . org-html-export-block) (export-snippet . org-html-export-snippet) (fixed-width . org-html-fixed-width) (footnote-definition . org-html-footnote-definition) (footnote-reference . org-html-footnote-reference) (headline . org-html-headline) (horizontal-rule . org-html-horizontal-rule) (inline-src-block . org-html-inline-src-block) (inlinetask . org-html-inlinetask) (inner-template . org-html-inner-template) (italic . org-html-italic) (item . org-html-item) (keyword . org-html-keyword) (latex-environment . org-html-latex-environment) (latex-fragment . org-html-latex-fragment) (line-break . org-html-line-break) (link . org-html-link) (node-property . org-html-node-property) ...) :exported-data #<hash-table eq 0/4001 0x1ff133784a4f> :input-buffer "test.org" :input-file "/Users/linw1995/Documents/..." :html-doctype "xhtml-strict" :html-container "div" :description nil :keywords nil :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" ...))
  org-html-src-block((src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    retur..." :post-blank 0 :post-affiliated 1 ...)) nil (:export-options nil :back-end #s(org-export-backend :name html :parent nil :transcoders (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :options (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :filters (... ... ...) :blocks nil :menu (104 "Export to HTML" ...)) :translate-alist ((bold . org-html-bold) (center-block . org-html-center-block) (clock . org-html-clock) (code . org-html-code) (drawer . org-html-drawer) (dynamic-block . org-html-dynamic-block) (entity . org-html-entity) (example-block . org-html-example-block) (export-block . org-html-export-block) (export-snippet . org-html-export-snippet) (fixed-width . org-html-fixed-width) (footnote-definition . org-html-footnote-definition) (footnote-reference . org-html-footnote-reference) (headline . org-html-headline) (horizontal-rule . org-html-horizontal-rule) (inline-src-block . org-html-inline-src-block) (inlinetask . org-html-inlinetask) (inner-template . org-html-inner-template) (italic . org-html-italic) (item . org-html-item) (keyword . org-html-keyword) (latex-environment . org-html-latex-environment) (latex-fragment . org-html-latex-fragment) (line-break . org-html-line-break) (link . org-html-link) (node-property . org-html-node-property) ...) :exported-data #<hash-table eq 0/4001 0x1ff133784a4f> :input-buffer "test.org" :input-file "/Users/linw1995/Documents/..." :html-doctype "xhtml-strict" :html-container "div" :description nil :keywords nil :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" ...))
  org-export-data((src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    retur..." :post-blank 0 :post-affiliated 1 ...)) (:export-options nil :back-end #s(org-export-backend :name html :parent nil :transcoders (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :options (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :filters (... ... ...) :blocks nil :menu (104 "Export to HTML" ...)) :translate-alist ((bold . org-html-bold) (center-block . org-html-center-block) (clock . org-html-clock) (code . org-html-code) (drawer . org-html-drawer) (dynamic-block . org-html-dynamic-block) (entity . org-html-entity) (example-block . org-html-example-block) (export-block . org-html-export-block) (export-snippet . org-html-export-snippet) (fixed-width . org-html-fixed-width) (footnote-definition . org-html-footnote-definition) (footnote-reference . org-html-footnote-reference) (headline . org-html-headline) (horizontal-rule . org-html-horizontal-rule) (inline-src-block . org-html-inline-src-block) (inlinetask . org-html-inlinetask) (inner-template . org-html-inner-template) (italic . org-html-italic) (item . org-html-item) (keyword . org-html-keyword) (latex-environment . org-html-latex-environment) (latex-fragment . org-html-latex-fragment) (line-break . org-html-line-break) (link . org-html-link) (node-property . org-html-node-property) ...) :exported-data #<hash-table eq 0/4001 0x1ff133784a4f> :input-buffer "test.org" :input-file "/Users/linw1995/Documents/..." :html-doctype "xhtml-strict" :html-container "div" :description nil :keywords nil :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" ...))
  #f(compiled-function (element) #<bytecode 0x1726fed925d5f7c7>)((src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    return f\"hello {name}\"\n\nhello..." :post-blank 0 :post-affiliated 1 :parent (section (:begin 1 :end 90 :contents-begin 1 :contents-end 90 :post-blank 0 :post-affiliated 1 :parent (org-data nil #31)) #1))))
  mapconcat(#f(compiled-function (element) #<bytecode 0x1726fed925d5f7c7>) ((src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    return f\"hello {name}\"\n\nhello..." :post-blank 0 :post-affiliated 1 :parent (section (:begin 1 :end 90 :contents-begin 1 :contents-end 90 :post-blank 0 :post-affiliated 1 :parent (org-data nil #33)) . #2)))) "")
  org-export-data((section (:begin 1 :end 90 :contents-begin 1 :contents-end 90 :post-blank 0 :post-affiliated 1 :parent (org-data nil #1)) (src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    retur..." :post-blank 0 :post-affiliated 1 ...))) (:export-options nil :back-end #s(org-export-backend :name html :parent nil :transcoders (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :options (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :filters (... ... ...) :blocks nil :menu (104 "Export to HTML" ...)) :translate-alist ((bold . org-html-bold) (center-block . org-html-center-block) (clock . org-html-clock) (code . org-html-code) (drawer . org-html-drawer) (dynamic-block . org-html-dynamic-block) (entity . org-html-entity) (example-block . org-html-example-block) (export-block . org-html-export-block) (export-snippet . org-html-export-snippet) (fixed-width . org-html-fixed-width) (footnote-definition . org-html-footnote-definition) (footnote-reference . org-html-footnote-reference) (headline . org-html-headline) (horizontal-rule . org-html-horizontal-rule) (inline-src-block . org-html-inline-src-block) (inlinetask . org-html-inlinetask) (inner-template . org-html-inner-template) (italic . org-html-italic) (item . org-html-item) (keyword . org-html-keyword) (latex-environment . org-html-latex-environment) (latex-fragment . org-html-latex-fragment) (line-break . org-html-line-break) (link . org-html-link) (node-property . org-html-node-property) ...) :exported-data #<hash-table eq 0/4001 0x1ff133784a4f> :input-buffer "test.org" :input-file "/Users/linw1995/Documents/..." :html-doctype "xhtml-strict" :html-container "div" :description nil :keywords nil :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" ...))
  #f(compiled-function (element) #<bytecode 0x1726fed925d5f7c7>)((section (:begin 1 :end 90 :contents-begin 1 :contents-end 90 :post-blank 0 :post-affiliated 1 :parent (org-data nil #1)) (src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    return f\"hello {name}\"\n\nhello..." :post-blank 0 :post-affiliated 1 :parent #1))))
  mapconcat(#f(compiled-function (element) #<bytecode 0x1726fed925d5f7c7>) ((section (:begin 1 :end 90 :contents-begin 1 :contents-end 90 :post-blank 0 :post-affiliated 1 :parent (org-data nil . #2)) (src-block (:language "python" :switches nil :parameters nil :begin 1 :end 90 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "def hello(name):\n    return f\"hello {name}\"\n\nhello..." :post-blank 0 :post-affiliated 1 :parent #3)))) "")
  org-export-data((org-data nil (section (:begin 1 :end 90 :contents-begin 1 :contents-end 90 :post-blank 0 :post-affiliated 1 :parent #1) (src-block ...))) (:export-options nil :back-end #s(org-export-backend :name html :parent nil :transcoders (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :options (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) :filters (... ... ...) :blocks nil :menu (104 "Export to HTML" ...)) :translate-alist ((bold . org-html-bold) (center-block . org-html-center-block) (clock . org-html-clock) (code . org-html-code) (drawer . org-html-drawer) (dynamic-block . org-html-dynamic-block) (entity . org-html-entity) (example-block . org-html-example-block) (export-block . org-html-export-block) (export-snippet . org-html-export-snippet) (fixed-width . org-html-fixed-width) (footnote-definition . org-html-footnote-definition) (footnote-reference . org-html-footnote-reference) (headline . org-html-headline) (horizontal-rule . org-html-horizontal-rule) (inline-src-block . org-html-inline-src-block) (inlinetask . org-html-inlinetask) (inner-template . org-html-inner-template) (italic . org-html-italic) (item . org-html-item) (keyword . org-html-keyword) (latex-environment . org-html-latex-environment) (latex-fragment . org-html-latex-fragment) (line-break . org-html-line-break) (link . org-html-link) (node-property . org-html-node-property) ...) :exported-data #<hash-table eq 0/4001 0x1ff133784a4f> :input-buffer "test.org" :input-file "/Users/linw1995/Documents/..." :html-doctype "xhtml-strict" :html-container "div" :description nil :keywords nil :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" ...))
  org-export-as(html nil nil nil (:output-file "test.html"))
  org-export-to-file(html "test.html" nil nil nil nil nil)
  org-html-export-to-html(nil nil nil nil)
  org-export-dispatch(nil)
  funcall-interactively(org-export-dispatch nil)
  call-interactively(org-export-dispatch nil nil)
  command-execute(org-export-dispatch)

It will fix this problem but will export an HTML file without the syntax highlighting if I disable the htmlize or emacs-tree-sitter.

@shackra shackra added the bug Something isn't working label Nov 28, 2020
@ubolonton
Copy link
Collaborator

This is interesting. The same versions of org and htmlize work in my config, but not in this minimal config. I'll have to investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants