浏览代码

Allow one comment line before the first headline.

When the export skips the text before the first headline, we now
include the comment line before the first headline, if any.
This makes sure that we can specify an anchor for this headline.
Carsten Dominik 16 年之前
父节点
当前提交
33744b0de5
共有 3 个文件被更改,包括 9 次插入4 次删除
  1. 4 3
      doc/org.texi
  2. 4 0
      lisp/ChangeLog
  3. 1 1
      lisp/org-exp.el

+ 4 - 3
doc/org.texi

@@ -2435,9 +2435,10 @@ convenient to put them into a comment line. For example
 @end example
 
 @noindent In HTML export (@pxref{HTML export}), such targets will become
-named anchors for direct access through @samp{http} links@footnote{Note
-that text before the first headline is usually not exported, so the
-first such target should be after the first headline.}.
+named anchors for direct access through @samp{http} links@footnote{Note that
+text before the first headline is usually not exported, so the first such
+target should be after the first headline, or in the line directly before the
+first headline.}.
 
 If no dedicated target exists, Org will search for the words in the
 link.  In the above example the search would be for @samp{my target}.

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2008-11-21  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-exp.el (org-export-preprocess-string): Allow one comment
+	line before the first headline to always be included.  This is
+	to not miss a commented target.
+
 	* org-mouse.el (org-mouse-insert-item): Call
 	`org-indent-to-column' instead of `indent-to', for XEmacs
 	compatibility.

+ 1 - 1
lisp/org-exp.el

@@ -1469,7 +1469,7 @@ on this string to produce the exported version."
       ;; Get the correct stuff before the first headline
       (when (plist-get parameters :skip-before-1st-heading)
 	(goto-char (point-min))
-	(when (re-search-forward "^\\*+[ \t]" nil t)
+	(when (re-search-forward "\\(^#.*\n\\)^\\*+[ \t]" nil t)
 	  (delete-region (point-min) (match-beginning 0))
 	  (goto-char (point-min))
 	  (insert "\n")))