emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Exporting C++ code block to html


From: Eric Schulte
Subject: Re: [O] Exporting C++ code block to html
Date: Sat, 28 Sep 2013 06:05:22 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Xavier Garrido <address@hidden> writes:

> Dear Orgers,
>
> I face a problem when I want to 'html' export a pretty simple org file : 
> test.org contains the following lines
>
> #+BEGIN_SRC c++
> int j= 1;
> #+END_SRC
>
> If I do
> emacs --batch -q --eval '(require (quote org))' --visit test.org \ 
> --funcall org-html-export-to-html
>

I had to do the following to re-create this error.

emacs --batch --eval "(progn (add-to-list 'load-path \"~/src/org-mode/lisp\") 
(require 'org) (add-to-list 'load-path \"~/src/org-mode/contrib/lisp\")(require 
'htmlize))" --visit /tmp/cpp-test.org --funcall org-html-export-to-html

>
> I get
> Loading vc-git...
> Loading cc-langs...
> Symbol's function definition is void: nil
>

With the above I get the same

>
> I have also activated the debug mode but the messages are quite
> cryptic for me (attached file). The point is that it only crashes with
> C/C++ languages but works with python, awk, sh, emacs-lisp ...
>
> I'm using orgmode 8.2-35 from the git repository.
>

I think this may be a bug in cc-mode when run in a batch Emacs session.
My guess is that the `c-standard-font-lock-fontify-region-function' is
never set.  You could either try to set this value manually, or report
this to the cc-mode maintainers, but I wouldn't be surprised if they ask
why you want fontification in a batch session.

Setting this variable manually from the command line with the following
fixes this problem for me.

emacs --batch --eval "(progn (add-to-list 'load-path \"~/src/org-mode/lisp\") 
(require 'org) (add-to-list 'load-path \"~/src/org-mode/contrib/lisp\")(require 
'htmlize) (setq c-standard-font-lock-fontify-region-function 
'font-lock-default-fontify-region))" --visit /tmp/cpp-test.org --funcall 
org-html-export-to-html

Cheers,

>
> Thanks for your help,
> Xavier
>
> oading vc-git...
> Loading cc-langs...
> Debugger entered--Lisp error: (void-function nil)
>   nil(1 12 nil)
>   c-font-lock-fontify-region(1 12 nil)
>   font-lock-fontify-region(1 12 nil)
>   byte-code("\212\303 \304\216\305ed  #\210\306 \210\307\211+\207" 
> [save-match-data-internal verbose font-lock-fontified match-data ((byte-code 
> "\30\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) 
> font-lock-fontify-region font-lock-after-fontify-buffer t] 4)
>   font-lock-default-fontify-buffer()
>   font-lock-fontify-buffer()
>   org-html-fontify-code("int j = 1;\n" "c++")
>   org-html-do-format-code("int j = 1;\n" "c++" nil t nil)
>   org-html-format-code((src-block (:language "c++" :switches nil :parameters 
> nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t 
> :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 
> :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 
> :contents-end 39 :post-blank 0 :parent (org-data nil #2)) #0))) 
> (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" 
> :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype 
> "xhtml-strict" :html-container "div" :html-html5-fancy nil 
> :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax 
> "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" 
> :html-head-include-default-style t :html-head-include-scripts t 
> :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules 
> "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") 
> :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") 
> ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; 
> ?>")) :html-inline-images t :creator "<a 
> href=\"http://www.gnu.org/software/emacs/\";>Emacs</a> 24.3.1 (<a 
> href=\"http://orgmode.org\";>Org</a> mode 8.2)" :with-latex t :author nil ...))
>   org-html-src-block((src-block (:language "c++" :switches nil :parameters 
> nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t 
> :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 
> :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 
> :contents-end 39 :post-blank 0 :parent (org-data nil #2)) #0))) nil 
> (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" 
> :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype 
> "xhtml-strict" :html-container "div" :html-html5-fancy nil 
> :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax 
> "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" 
> :html-head-include-default-style t :html-head-include-scripts t 
> :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules 
> "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") 
> :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") 
> ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; 
> ?>")) :html-inline-images t :creator "<a 
> href=\"http://www.gnu.org/software/emacs/\";>Emacs</a> 24.3.1 (<a 
> href=\"http://orgmode.org\";>Org</a> mode 8.2)" :with-latex t :author nil ...))
>   org-export-data((src-block (:language "c++" :switches nil :parameters nil 
> :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t 
> :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 
> :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 
> :contents-end 39 :post-blank 0 :parent (org-data nil #2)) #0))) 
> (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" 
> :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype 
> "xhtml-strict" :html-container "div" :html-html5-fancy nil 
> :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax 
> "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" 
> :html-head-include-default-style t :html-head-include-scripts t 
> :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules 
> "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") 
> :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") 
> ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; 
> ?>")) :html-inline-images t :creator "<a 
> href=\"http://www.gnu.org/software/emacs/\";>Emacs</a> 24.3.1 (<a 
> href=\"http://orgmode.org\";>Org</a> mode 8.2)" :with-latex t :author nil ...))
>   #[(element) "\302     \"\207" [element info org-export-data] 3]((src-block 
> (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines 
> nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil 
> :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent 
> (section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 
> :parent (org-data nil #2)) #0))))
>   mapconcat(#[(element) "\302   \"\207" [element info org-export-data] 3] 
> ((src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 
> :number-lines nil :preserve-indent nil :retain-labels t :use-labels t 
> :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 
> :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 
> :contents-end 39 :post-blank 0 :parent (org-data nil #3)) #1)))) "")
>   org-export-data((section (:begin 1 :end 39 :contents-begin 1 :contents-end 
> 39 :post-blank 0 :parent (org-data nil #0)) (src-block (:language "c++" 
> :switches nil :parameters nil :begin 1 :end 39 :number-lines nil 
> :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp 
> nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent #0))) 
> (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" 
> :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype 
> "xhtml-strict" :html-container "div" :html-html5-fancy nil 
> :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax 
> "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" 
> :html-head-include-default-style t :html-head-include-scripts t 
> :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules 
> "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") 
> :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") 
> ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; 
> ?>")) :html-inline-images t :creator "<a 
> href=\"http://www.gnu.org/software/emacs/\";>Emacs</a> 24.3.1 (<a 
> href=\"http://orgmode.org\";>Org</a> mode 8.2)" :with-latex t :author nil ...))
>   #[(element) "\302     \"\207" [element info org-export-data] 3]((section 
> (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent 
> (org-data nil #0)) (src-block (:language "c++" :switches nil :parameters nil 
> :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t 
> :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 
> :post-affiliated 1 :parent #0))))
>   mapconcat(#[(element) "\302   \"\207" [element info org-export-data] 3] 
> ((section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 
> :parent (org-data nil #1)) (src-block (:language "c++" :switches nil 
> :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil 
> :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 
> 1;\n" :post-blank 0 :post-affiliated 1 :parent #1)))) "")
>   org-export-data((org-data nil (section (:begin 1 :end 39 :contents-begin 1 
> :contents-end 39 :post-blank 0 :parent #0) (src-block (:language "c++" 
> :switches nil :parameters nil :begin 1 :end 39 :number-lines nil 
> :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp 
> nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent #1)))) 
> (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" 
> :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype 
> "xhtml-strict" :html-container "div" :html-html5-fancy nil 
> :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax 
> "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" 
> :html-head-include-default-style t :html-head-include-scripts t 
> :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules 
> "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") 
> :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") 
> ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; 
> ?>")) :html-inline-images t :creator "<a 
> href=\"http://www.gnu.org/software/emacs/\";>Emacs</a> 24.3.1 (<a 
> href=\"http://orgmode.org\";>Org</a> mode 8.2)" :with-latex t :author nil ...))
>   org-export-as(html nil nil nil nil)
>   org-export-to-file(html "./test.html" nil nil nil nil nil)
>   org-html-export-to-html()
>   call-interactively(org-html-export-to-html nil nil)
>   command-execute(org-html-export-to-html)
>   command-line-1(("--eval" "(require (quote org))" "--eval" "(setq 
> debug-on-error t)" "--visit" "test.org" "--funcall" 
> "org-html-export-to-html"))
>   command-line()
>   normal-top-level()

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



reply via email to

[Prev in Thread] Current Thread [Next in Thread]