summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-01-30 18:49:42 +0100
committerGeorg Brandl <georg@python.org>2010-01-30 18:49:42 +0100
commit4449fb14d18b3492a50d2cef7dd962ad5ddfa185 (patch)
tree684b7d439094cdb3da4638ef9de896abc09d96db
parent4c805648268995c0d69690af769aacea7879e089 (diff)
downloadsphinx-4449fb14d18b3492a50d2cef7dd962ad5ddfa185.tar.gz
Make the ``start-after`` and ``end-before`` options to the ``literalinclude`` directive work correctly if not used together.
-rw-r--r--CHANGES3
-rw-r--r--sphinx/directives/code.py4
-rw-r--r--tests/root/includes.txt6
-rw-r--r--tests/test_markup.py1
4 files changed, 11 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index 66aee244..2db62edb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
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.
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index ffb9ce4d..f5a8f8af 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -155,9 +155,9 @@ class LiteralInclude(Directive):
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:
diff --git a/tests/root/includes.txt b/tests/root/includes.txt
index b58463f5..4fe13ed6 100644
--- a/tests/root/includes.txt
+++ b/tests/root/includes.txt
@@ -44,6 +44,12 @@ Literalinclude options
: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
diff --git a/tests/test_markup.py b/tests/test_markup.py
index d29f6f91..0133a9d8 100644
--- a/tests/test_markup.py
+++ b/tests/test_markup.py
@@ -16,7 +16,6 @@ from util import *
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