aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/__init__.py13
-rw-r--r--markdown/blockprocessors.py2
-rw-r--r--markdown/commandline.py6
-rw-r--r--tests/misc/some-test.html4
-rw-r--r--tests/options/lazy_ol_off.html18
-rw-r--r--tests/options/lazy_ol_off.txt17
-rw-r--r--tests/options/test.cfg2
7 files changed, 48 insertions, 14 deletions
diff --git a/markdown/__init__.py b/markdown/__init__.py
index 2bc7061..9b964b7 100644
--- a/markdown/__init__.py
+++ b/markdown/__init__.py
@@ -63,6 +63,7 @@ class Markdown:
'tab_length' : 4,
'enable_attributes' : True,
'smart_emphasis' : True,
+ 'lazy_ol' : True,
}
output_formats = {
@@ -96,6 +97,7 @@ class Markdown:
* tab_length: Length of tabs in the source. Default: 4
* enable_attributes: Enable the conversion of attributes. Default: True
* smart_emphsasis: Treat `_connected_words_` intelegently Default: True
+ * lazy_ol: Ignore number of first item of ordered lists. Default: True
"""
@@ -353,16 +355,7 @@ def markdown(text, *args, **kwargs):
Keyword arguments:
* text: Markdown formatted text as Unicode or ASCII string.
- * extensions: A list of extensions or extension names (may contain config args).
- * safe_mode: Disallow raw html. One of "remove", "replace" or "escape".
- * output_format: Format of output. Supported formats are:
- * "xhtml1": Outputs XHTML 1.x. Default.
- * "xhtml": Outputs latest supported version of XHTML (currently XHTML 1.1).
- * "html4": Outputs HTML 4
- * "html": Outputs latest supported version of HTML (currently HTML 4).
- Note that it is suggested that the more specific formats ("xhtml1"
- and "html4") be used as "xhtml" or "html" may change in the future
- if it makes sense at that time.
+ * Any arguments accepted by the Markdown class.
Returns: An HTML document as a string.
diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py
index 5949c00..cc1d2a8 100644
--- a/markdown/blockprocessors.py
+++ b/markdown/blockprocessors.py
@@ -346,7 +346,7 @@ class OListProcessor(BlockProcessor):
# This is a new list so create parent with appropriate tag.
lst = util.etree.SubElement(parent, self.TAG)
# Check if a custom start integer is set
- if self.STARTSWITH !='1':
+ if not self.parser.markdown.lazy_ol and self.STARTSWITH !='1':
lst.attrib['start'] = self.STARTSWITH
self.parser.state.set('list')
diff --git a/markdown/commandline.py b/markdown/commandline.py
index 3f2e009..caf9288 100644
--- a/markdown/commandline.py
+++ b/markdown/commandline.py
@@ -49,6 +49,9 @@ def parse_options():
help="print debug messages")
parser.add_option("-x", "--extension", action="append", dest="extensions",
help = "load extension EXTENSION", metavar="EXTENSION")
+ parser.add_option("-n", "--no_lazy_ol", dest="lazy_ol",
+ action='store_false', default=True,
+ help="Observe number of first item of ordered lists.")
(options, args) = parser.parse_args()
@@ -65,7 +68,8 @@ def parse_options():
'safe_mode': options.safe,
'extensions': options.extensions,
'encoding': options.encoding,
- 'output_format': options.output_format}, options.verbose
+ 'output_format': options.output_format,
+ 'lazy_ol': options.lazy_ol}, options.verbose
def run():
"""Run Markdown from the command line."""
diff --git a/tests/misc/some-test.html b/tests/misc/some-test.html
index 92e7262..b78683f 100644
--- a/tests/misc/some-test.html
+++ b/tests/misc/some-test.html
@@ -51,7 +51,7 @@ ok
with a bunch of items</li>
<li>
<p>Mostly fruits</p>
-<ol start="3">
+<ol>
<li>Apple</li>
<li>Pare</li>
</ol>
@@ -65,4 +65,4 @@ Another code example
* Lists and similar stuff
&gt; Should be ignored
-</code></pre>
+</code></pre> \ No newline at end of file
diff --git a/tests/options/lazy_ol_off.html b/tests/options/lazy_ol_off.html
new file mode 100644
index 0000000..bff1970
--- /dev/null
+++ b/tests/options/lazy_ol_off.html
@@ -0,0 +1,18 @@
+<p>A numbered list from daringfireball:</p>
+<ol start="3">
+<li>Bird</li>
+<li>McHale</li>
+<li>Parish</li>
+</ol>
+<p>Again:</p>
+<ol start="3">
+<li>Bird</li>
+<li>McHale</li>
+<li>Parish</li>
+</ol>
+<p>Now starting with 1:</p>
+<ol>
+<li>Bird</li>
+<li>McHale</li>
+<li>Parish</li>
+</ol> \ No newline at end of file
diff --git a/tests/options/lazy_ol_off.txt b/tests/options/lazy_ol_off.txt
new file mode 100644
index 0000000..611f3a6
--- /dev/null
+++ b/tests/options/lazy_ol_off.txt
@@ -0,0 +1,17 @@
+A numbered list from daringfireball:
+
+3. Bird
+1. McHale
+8. Parish
+
+Again:
+
+3. Bird
+1. McHale
+8. Parish
+
+Now starting with 1:
+
+1. Bird
+1. McHale
+8. Parish
diff --git a/tests/options/test.cfg b/tests/options/test.cfg
new file mode 100644
index 0000000..d0d3368
--- /dev/null
+++ b/tests/options/test.cfg
@@ -0,0 +1,2 @@
+[lazy_ol_off]
+lazy_ol = False