mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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.
This commit is contained in:
parent
9cea699149
commit
df37a05420
@ -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]
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user