Commits

Georg Brandl committed 9cc7e32

Make the ``start-after`` and ``end-before`` options to the ``literalinclude`` directive work correctly if not used together.

Comments (0)

Files changed (4)

 Release 0.6.5 (in development)
 ==============================
 
+* Make the ``start-after`` and ``end-before`` options to the
+  ``literalinclude`` directive work correctly if not used together.
+
 * #321: Fix link generation in the LaTeX builder.
 
 

sphinx/directives/code.py

             use = not startafter
             res = []
             for line in lines:
-                if not use and startafter in line:
+                if not use and startafter and startafter in line:
                     use = True
-                elif use and endbefore in line:
+                elif use and endbefore and endbefore in line:
                     use = False
                     break
                 elif use:

tests/root/includes.txt

    :start-after: coding: utf-8
    :end-before: class Foo
 
+.. literalinclude:: literal.inc
+   :start-after: utf-8
+
+.. literalinclude:: literal.inc
+   :end-before: class Foo
+
 Test if dedenting before parsing works.
 
 .. highlight:: python

tests/test_markup.py

 from docutils import frontend, utils, nodes
 from docutils.parsers import rst
 
-from sphinx import addnodes
 from sphinx.util import texescape
 from sphinx.writers.html import HTMLWriter, SmartyPantsHTMLTranslator
 from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator