Browse Source

org-lparse.el & co: Bring over few commits (contd.)

Bring over following commits:
- dfcb6fae
- 767f5188
- ca49e893
- 728611fa
- b2408c00
- 97d107d9
Jambunathan K 13 years ago
parent
commit
7e31ecdb22
2 changed files with 29 additions and 17 deletions
  1. 26 15
      contrib/lisp/org-lparse.el
  2. 3 2
      contrib/lisp/org-xhtml.el

+ 26 - 15
contrib/lisp/org-lparse.el

@@ -563,6 +563,7 @@ and then converted to \"doc\" then org-lparse-backend is set to
 	(setq params (format "(%s)" params)))
 	(setq params (format "(%s)" params)))
       (ignore-errors (read params)))))
       (ignore-errors (read params)))))
 
 
+(defvar org-heading-keyword-regexp-format) ; defined in org.el
 (defvar org-lparse-special-blocks '("list-table" "annotation"))
 (defvar org-lparse-special-blocks '("list-table" "annotation"))
 (defun org-do-lparse (arg &optional hidden ext-plist
 (defun org-do-lparse (arg &optional hidden ext-plist
 			  to-buffer body-only pub-dir)
 			  to-buffer body-only pub-dir)
@@ -674,6 +675,7 @@ version."
 	 (current-dir (if buffer-file-name
 	 (current-dir (if buffer-file-name
 			  (file-name-directory buffer-file-name)
 			  (file-name-directory buffer-file-name)
 			default-directory))
 			default-directory))
+	 (auto-insert nil) ; Avoid any auto-insert stuff for the new file
 	 (buffer (if to-buffer
 	 (buffer (if to-buffer
 		     (cond
 		     (cond
 		      ((eq to-buffer 'string)
 		      ((eq to-buffer 'string)
@@ -684,6 +686,12 @@ version."
 			  (and f (functionp f) (funcall f filename)))
 			  (and f (functionp f) (funcall f filename)))
 			filename))))
 			filename))))
 	 (org-levels-open (make-vector org-level-max nil))
 	 (org-levels-open (make-vector org-level-max nil))
+	 (dummy (mapc
+		 (lambda(p)
+		   (let* ((val (plist-get opt-plist p))
+			  (val (org-xml-encode-org-text-skip-links val)))
+		     (setq opt-plist (plist-put opt-plist p val))))
+		 '(:date :author :keywords :description)))
 	 (date (plist-get opt-plist :date))
 	 (date (plist-get opt-plist :date))
 	 (date (cond
 	 (date (cond
 		((and date (string-match "%" date))
 		((and date (string-match "%" date))
@@ -704,8 +712,9 @@ version."
 			   "UNTITLED")))
 			   "UNTITLED")))
 	 (dummy (setq opt-plist (plist-put opt-plist :title title)))
 	 (dummy (setq opt-plist (plist-put opt-plist :title title)))
 	 (html-table-tag (plist-get opt-plist :html-table-tag))
 	 (html-table-tag (plist-get opt-plist :html-table-tag))
-	 (quote-re0   (concat "^[ \t]*" org-quote-string "\\>"))
-	 (quote-re    (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)"))
+	 (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
+	 (quote-re (format org-heading-keyword-regexp-format
+			   org-quote-string))
 	 (org-lparse-dyn-current-environment nil)
 	 (org-lparse-dyn-current-environment nil)
 	 ;; Get the language-dependent settings
 	 ;; Get the language-dependent settings
 	 (lang-words (or (assoc (plist-get opt-plist :language)
 	 (lang-words (or (assoc (plist-get opt-plist :language)
@@ -1038,7 +1047,7 @@ version."
 			 t t line))))))
 			 t t line))))))
 
 
 	  (cond
 	  (cond
-	   ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
+	   ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line)
 	    ;; This is a headline
 	    ;; This is a headline
 	    (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
 	    (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
 					 level-offset))
 					 level-offset))
@@ -1450,18 +1459,20 @@ Possible conversions are set in `org-export-html-protect-char-alist'."
 
 
 (defun org-xml-encode-org-text-skip-links (string)
 (defun org-xml-encode-org-text-skip-links (string)
   "Prepare STRING for HTML export.  Apply all active conversions.
   "Prepare STRING for HTML export.  Apply all active conversions.
-If there are links in the string, don't modify these."
-  (let* ((re (concat org-bracket-link-regexp "\\|"
-		     (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
-	 m s l res)
-    (while (setq m (string-match re string))
-      (setq s (substring string 0 m)
-	    l (match-string 0 string)
-	    string (substring string (match-end 0)))
-      (push (org-xml-encode-org-text s) res)
-      (push l res))
-    (push (org-xml-encode-org-text string) res)
-    (apply 'concat (nreverse res))))
+If there are links in the string, don't modify these.  If STRING
+is nil, return nil."
+  (when string
+    (let* ((re (concat org-bracket-link-regexp "\\|"
+		       (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
+	   m s l res)
+      (while (setq m (string-match re string))
+	(setq s (substring string 0 m)
+	      l (match-string 0 string)
+	      string (substring string (match-end 0)))
+	(push (org-xml-encode-org-text s) res)
+	(push l res))
+      (push (org-xml-encode-org-text string) res)
+      (apply 'concat (nreverse res)))))
 
 
 (defun org-xml-encode-org-text (s)
 (defun org-xml-encode-org-text (s)
   "Apply all active conversions to translate special ASCII to HTML."
   "Apply all active conversions to translate special ASCII to HTML."

+ 3 - 2
contrib/lisp/org-xhtml.el

@@ -1274,11 +1274,11 @@ make any modifications to the exporter file.  For example,
 	     "%s
 	     "%s
 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
 	       \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
 	       \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
-<html xmlns=\"http://www.w3.org/1999/xhtml\"
-lang=\"%s\" xml:lang=\"%s\">
+<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">
 <head>
 <head>
 <title>%s</title>
 <title>%s</title>
 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
+<meta name=\"title\" content=\"%s\"/>
 <meta name=\"generator\" content=\"Org-mode\"/>
 <meta name=\"generator\" content=\"Org-mode\"/>
 <meta name=\"generated\" content=\"%s\"/>
 <meta name=\"generated\" content=\"%s\"/>
 <meta name=\"author\" content=\"%s\"/>
 <meta name=\"author\" content=\"%s\"/>
@@ -1300,6 +1300,7 @@ lang=\"%s\" xml:lang=\"%s\">
 	     language language
 	     language language
 	     (plist-get opt-plist :title)
 	     (plist-get opt-plist :title)
 	     charset
 	     charset
+	     (plist-get opt-plist :title)
 	     (plist-get opt-plist :effective-date)
 	     (plist-get opt-plist :effective-date)
 	     (plist-get opt-plist :author)
 	     (plist-get opt-plist :author)
 	     (plist-get opt-plist :description)
 	     (plist-get opt-plist :description)