From ce4c30ebe56d4cd66810bca48824d8841e7b130d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 16 Jul 2013 09:44:59 -0600 Subject: [PATCH] support inline comments w/o breaking paragraphs * lisp/org-element.el (org-element-parse-buffer): Strip inline comments as a pre-processing step before exporting. --- lisp/org-element.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 8d64657..d69d9ba 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4092,13 +4092,19 @@ or objects within the parse tree. This function assumes that current major mode is `org-mode'." (save-excursion - (goto-char (point-min)) - (org-skip-whitespace) - (org-element--parse-elements - (point-at-bol) (point-max) - ;; Start in `first-section' mode so text before the first - ;; headline belongs to a section. - 'first-section nil granularity visible-only (list 'org-data nil)))) + (let ((save (buffer-string))) + (unwind-protect + (progn + (goto-char (point-min)) + (delete-matching-lines "^ *# .[^\n]*\n") + (org-skip-whitespace) + (org-element--parse-elements + (point-at-bol) (point-max) + ;; Start in `first-section' mode so text before the first + ;; headline belongs to a section. + 'first-section nil granularity visible-only (list 'org-data nil))) + (delete-region (point-min) (point-max)) + (insert save))))) (defun org-element-parse-secondary-string (string restriction &optional parent) "Recursively parse objects in STRING and return structure. -- 1.8.3.2