The rst-adjust function in rst.el misinterprets comments as section
headings. The attached patch file, diffed against the
/trunk/docutils/tools/editors/emacs/rst directory of the repository,
provides a test case illustrating the issue and a solution.
Basically, the current emacs script interprets comments following text or
directives as a section mark-up when this is actually a comment. Any line
consisting of 2 dots followed by 0 or more white-space should be considered
a comment and not a form of mark-up. The quintessential example is the use
of a parameterized contents directive with the rst-toc-update command to
populate the TOC in the document as a comment, which is the example given
in the test case:
1 Section 1
2 Section 2
One would expect a rst-adjust command executed at the specified cursor
position to promote Section 1 to the same level as Subtitle. Instead, in
the current code, it promotes it to ..... underscore, which is not in this
document. Again, the given patch corrects this by excluding lines of the
form \\.\\.[ \t]*$ from the search for section headings in
I am assuming this will not affect existing documents because I believe the
case of comment following text or directive to be rare but that this patch
should bring the emacs mode more in line with what how the docutils
actually interprets the given text.
Log in to post a comment.