From df37a05420d3a435b96a5521d0d30de79b6e1656 Mon Sep 17 00:00:00 2001 From: Junpei Kawamoto Date: Fri, 2 Dec 2016 23:39:12 -0500 Subject: [PATCH] Update the regex in util.split_docinfo so that it parses multi-line field bodies. Field Lists, which are used to define docinfo, allow multi-line field bodies, but util.split_docinfo didn't consider it. This commit updates the regex in that function so that it parses such multi-line field bodies. --- sphinx/util/__init__.py | 2 +- tests/test_util.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 9c5365aa7f..573882418e 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -545,7 +545,7 @@ def encode_uri(uri): def split_docinfo(text): - docinfo_re = re.compile('\A((?:\s*:\w+:.*?\n)+)', re.M) + docinfo_re = re.compile('\A((?:\s*:\w+:.*?\n(?:[ \t]+.*?\n)*)+)', re.M) result = docinfo_re.split(text, 1) if len(result) == 1: return '', result[0] diff --git a/tests/test_util.py b/tests/test_util.py index dbecfb1a26..d97329668d 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -41,3 +41,8 @@ def test_splitdocinfo(): docinfo, content = split_docinfo(source) assert docinfo == ':author: Georg Brandl\n:title: Manual of Sphinx\n' assert content == '\nHello world.\n' + + source = ":multiline: one\n\ttwo\n\tthree\n\nHello world.\n" + docinfo, content = split_docinfo(source) + assert docinfo == ":multiline: one\n\ttwo\n\tthree\n" + assert content == '\nHello world.\n'