فهرست منبع

Fix bug with including org-file during export.

Stefan Vollmar writes:

>  taking up a nice suggestion from Sebastian Rose, I want to
>  present some org source with proper syntax highlighting. However,
>  there is a problem when using "BEGIN_SRC" blocks it seems.
>
>  If one puts this org contents into a file "test.org":
>
>  * One Headline
>  Some Text
>  #+BEGIN_SRC python
>  print "some output"
>  #+END_SRC
>  * Another headline
>  More text
>
>  and renders it from another org-file with:
>
>  #+INCLUDE: "./test.org" src org
>
>  everything will be fine (beautiful, infact) up to and including
>  the print-line - the rest of the org file is not rendered as
>  source but interpreted.
Carsten Dominik 16 سال پیش
والد
کامیت
52af11ac17
2فایلهای تغییر یافته به همراه11 افزوده شده و 1 حذف شده
  1. 4 0
      lisp/ChangeLog
  2. 7 1
      lisp/org-exp.el

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2009-06-23  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-exp.el (org-get-file-contents): Protect org-like lines in
+	included files.
+	(org-export-format-source-code-or-example): Remove newlines.
+
 	* org-latex.el (org-export-latex-links): Check for no-description
 	marking.
 

+ 7 - 1
lisp/org-exp.el

@@ -2099,6 +2099,12 @@ is a string, prepend it to the first line instead of PREFIX."
 	(insert (or prefix1 prefix))
 	(setq prefix1 nil)
 	(beginning-of-line 2)))
+    (buffer-string)
+    (goto-char (point-min))
+    (while (re-search-forward "^\\(\\*\\|[ \t]*#\\)" nil t)
+      (goto-char (match-beginning 0))
+      (insert ",")
+      (end-of-line 1))
     (buffer-string)))
 
 (defun org-get-and-remove-property (listvar prop)
@@ -2230,7 +2236,7 @@ INDENT was the original indentation of the block."
 			    (set-buffer-modified-p nil)
 			    (org-export-htmlize-region-for-paste
 			     (point-min) (point-max))))
-		    (if (string-match "<pre\\([^>]*\\)>\n?" rtn)
+		    (if (string-match "<pre\\([^>]*\\)>\n*" rtn)
 			(setq rtn (replace-match
 				   (format "<pre class=\"src src-%s\">" lang)
 				   t t rtn))))