prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [BUG] Chinese document layout has a link error.
  <!--
  Thank you for your contribution!
  
  Please review https://github.com/mars-project/mars/blob/master/CONTRIBUTING.rst before opening an issue.
  -->
  
  **Describe the bug**
  A clear and concise description of what the bug is.
  
  Chinese document layout has a connection error.
  doc link:[https://mars-project.readthedocs.io/zh_CN/latest/tensor/overview.html](https://mars-project.readthedocs.io/zh_CN/latest/tensor/overview.html)
  
  
  ![image](https://user-images.githubusercontent.com/20548053/54252653-9e94d900-4586-11e9-998f-3b677dd2b460.png)
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `docs/source/norm_zh.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 # Copyright 1999-2018 Alibaba Group Holding Ltd.
  4 #
  5 # Licensed under the Apache License, Version 2.0 (the "License");
  6 # you may not use this file except in compliance with the License.
  7 # You may obtain a copy of the License at
  8 #
  9 #      http://www.apache.org/licenses/LICENSE-2.0
  10 #
  11 # Unless required by applicable law or agreed to in writing, software
  12 # distributed under the License is distributed on an "AS IS" BASIS,
  13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 # See the License for the specific language governing permissions and
  15 # limitations under the License.
  16 
  17 """
  18 This file folds Chinese po files by hacking babel.messages.pofile.normalize
  19 using jieba text segment library instead of regex
  20 """
  21 
  22 import datetime
  23 import os
  24 
  25 from babel.messages import pofile
  26 from babel.messages.pofile import escape
  27 
  28 
  29 def _zh_len(s):
  30     """
  31     Calculate text length in Chinese
  32     """
  33     try:
  34         return len(s.encode('gb2312'))
  35     except ValueError:
  36         return len(s)
  37 
  38 
  39 def _zh_split(s):
  40     """
  41     Split text length in Chinese
  42     """
  43     import jieba
  44     try:
  45         s.encode('ascii')
  46         has_zh = False
  47     except ValueError:
  48         has_zh = True
  49 
  50     if has_zh:
  51         return list(jieba.cut(s))
  52     else:
  53         return pofile.WORD_SEP.split(s)
  54 
  55 
  56 # code modified from babel.messages.pofile (hash 359ecffca479dfe032d0f7210d5cd8160599c816)
  57 def _normalize(string, prefix='', width=76):
  58     r"""Convert a string into a format that is appropriate for .po files.
  59     >>> print(normalize('''Say:
  60     ...   "hello, world!"
  61     ... ''', width=None))
  62     ""
  63     "Say:\n"
  64     "  \"hello, world!\"\n"
  65     >>> print(normalize('''Say:
  66     ...   "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
  67     ... ''', width=32))
  68     ""
  69     "Say:\n"
  70     "  \"Lorem ipsum dolor sit "
  71     "amet, consectetur adipisicing"
  72     " elit, \"\n"
  73     :param string: the string to normalize
  74     :param prefix: a string that should be prepended to every line
  75     :param width: the maximum line width; use `None`, 0, or a negative number
  76                   to completely disable line wrapping
  77     """
  78 
  79     if width and width > 0:
  80         prefixlen = _zh_len(prefix)
  81         lines = []
  82         for line in string.splitlines(True):
  83             if _zh_len(escape(line)) + prefixlen > width:
  84                 chunks = _zh_split(line)
  85                 chunks.reverse()
  86                 while chunks:
  87                     buf = []
  88                     size = 2
  89                     while chunks:
  90                         l = _zh_len(escape(chunks[-1])) - 2 + prefixlen  # noqa: E741
  91                         if size + l < width:
  92                             buf.append(chunks.pop())
  93                             size += l
  94                         else:
  95                             if not buf:
  96                                 # handle long chunks by putting them on a
  97                                 # separate line
  98                                 buf.append(chunks.pop())
  99                             break
  100                     lines.append(u''.join(buf))
  101             else:
  102                 lines.append(line)
  103     else:
  104         lines = string.splitlines(True)
  105 
  106     if len(lines) <= 1:
  107         return escape(string)
  108 
  109     # Remove empty trailing line
  110     if lines and not lines[-1]:
  111         del lines[-1]
  112         lines[-1] += '\n'
  113     return u'""\n' + u'\n'.join([(prefix + escape(line)) for line in lines])
  114 
  115 
  116 def main():
  117     try:
  118         import jieba  # noqa: F401
  119     except ImportError:
  120         return
  121 
  122     pofile.normalize = _normalize
  123     for root, dirs, files in os.walk('.'):
  124         if 'zh' not in root:
  125             continue
  126         for f in files:
  127             if not f.endswith('.po'):
  128                 continue
  129             path = os.path.join(root, f)
  130 
  131             # only modify recent-changed files
  132             modify_time = datetime.datetime.fromtimestamp(os.path.getmtime(path))
  133             if (datetime.datetime.now() - modify_time).total_seconds() > 1800:
  134                 continue
  135 
  136             with open(path, 'rb') as inpf:
  137                 catalog = pofile.read_po(inpf)
  138             with open(path, 'wb') as outf:
  139                 pofile.write_po(outf, catalog)
  140 
  141 
  142 if __name__ == '__main__':
  143     main()
  144
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/docs/source/norm_zh.py b/docs/source/norm_zh.py
  --- a/docs/source/norm_zh.py
  +++ b/docs/source/norm_zh.py
  @@ -130,7 +130,7 @@
   
               # only modify recent-changed files
               modify_time = datetime.datetime.fromtimestamp(os.path.getmtime(path))
  -            if (datetime.datetime.now() - modify_time).total_seconds() > 1800:
  +            if (datetime.datetime.now() - modify_time).total_seconds() > 120:
                   continue
   
               with open(path, 'rb') as inpf:
  
verification_info: {"golden_diff": "diff --git a/docs/source/norm_zh.py b/docs/source/norm_zh.py\n--- a/docs/source/norm_zh.py\n+++ b/docs/source/norm_zh.py\n@@ -130,7 +130,7 @@\n \n             # only modify recent-changed files\n             modify_time = datetime.datetime.fromtimestamp(os.path.getmtime(path))\n-            if (datetime.datetime.now() - modify_time).total_seconds() > 1800:\n+            if (datetime.datetime.now() - modify_time).total_seconds() > 120:\n                 continue\n \n             with open(path, 'rb') as inpf:\n", "issue": "[BUG] Chinese document layout has a link error.\n<!--\r\nThank you for your contribution!\r\n\r\nPlease review https://github.com/mars-project/mars/blob/master/CONTRIBUTING.rst before opening an issue.\r\n-->\r\n\r\n**Describe the bug**\r\nA clear and concise description of what the bug is.\r\n\r\nChinese document layout has a connection error.\r\ndoc link:[https://mars-project.readthedocs.io/zh_CN/latest/tensor/overview.html](https://mars-project.readthedocs.io/zh_CN/latest/tensor/overview.html)\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/20548053/54252653-9e94d900-4586-11e9-998f-3b677dd2b460.png)\r\n\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# Copyright 1999-2018 Alibaba Group Holding Ltd.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"\nThis file folds Chinese po files by hacking babel.messages.pofile.normalize\nusing jieba text segment library instead of regex\n\"\"\"\n\nimport datetime\nimport os\n\nfrom babel.messages import pofile\nfrom babel.messages.pofile import escape\n\n\ndef _zh_len(s):\n    \"\"\"\n    Calculate text length in Chinese\n    \"\"\"\n    try:\n        return len(s.encode('gb2312'))\n    except ValueError:\n        return len(s)\n\n\ndef _zh_split(s):\n    \"\"\"\n    Split text length in Chinese\n    \"\"\"\n    import jieba\n    try:\n        s.encode('ascii')\n        has_zh = False\n    except ValueError:\n        has_zh = True\n\n    if has_zh:\n        return list(jieba.cut(s))\n    else:\n        return pofile.WORD_SEP.split(s)\n\n\n# code modified from babel.messages.pofile (hash 359ecffca479dfe032d0f7210d5cd8160599c816)\ndef _normalize(string, prefix='', width=76):\n    r\"\"\"Convert a string into a format that is appropriate for .po files.\n    >>> print(normalize('''Say:\n    ...   \"hello, world!\"\n    ... ''', width=None))\n    \"\"\n    \"Say:\\n\"\n    \"  \\\"hello, world!\\\"\\n\"\n    >>> print(normalize('''Say:\n    ...   \"Lorem ipsum dolor sit amet, consectetur adipisicing elit, \"\n    ... ''', width=32))\n    \"\"\n    \"Say:\\n\"\n    \"  \\\"Lorem ipsum dolor sit \"\n    \"amet, consectetur adipisicing\"\n    \" elit, \\\"\\n\"\n    :param string: the string to normalize\n    :param prefix: a string that should be prepended to every line\n    :param width: the maximum line width; use `None`, 0, or a negative number\n                  to completely disable line wrapping\n    \"\"\"\n\n    if width and width > 0:\n        prefixlen = _zh_len(prefix)\n        lines = []\n        for line in string.splitlines(True):\n            if _zh_len(escape(line)) + prefixlen > width:\n                chunks = _zh_split(line)\n                chunks.reverse()\n                while chunks:\n                    buf = []\n                    size = 2\n                    while chunks:\n                        l = _zh_len(escape(chunks[-1])) - 2 + prefixlen  # noqa: E741\n                        if size + l < width:\n                            buf.append(chunks.pop())\n                            size += l\n                        else:\n                            if not buf:\n                                # handle long chunks by putting them on a\n                                # separate line\n                                buf.append(chunks.pop())\n                            break\n                    lines.append(u''.join(buf))\n            else:\n                lines.append(line)\n    else:\n        lines = string.splitlines(True)\n\n    if len(lines) <= 1:\n        return escape(string)\n\n    # Remove empty trailing line\n    if lines and not lines[-1]:\n        del lines[-1]\n        lines[-1] += '\\n'\n    return u'\"\"\\n' + u'\\n'.join([(prefix + escape(line)) for line in lines])\n\n\ndef main():\n    try:\n        import jieba  # noqa: F401\n    except ImportError:\n        return\n\n    pofile.normalize = _normalize\n    for root, dirs, files in os.walk('.'):\n        if 'zh' not in root:\n            continue\n        for f in files:\n            if not f.endswith('.po'):\n                continue\n            path = os.path.join(root, f)\n\n            # only modify recent-changed files\n            modify_time = datetime.datetime.fromtimestamp(os.path.getmtime(path))\n            if (datetime.datetime.now() - modify_time).total_seconds() > 1800:\n                continue\n\n            with open(path, 'rb') as inpf:\n                catalog = pofile.read_po(inpf)\n            with open(path, 'wb') as outf:\n                pofile.write_po(outf, catalog)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "docs/source/norm_zh.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# Copyright 1999-2018 Alibaba Group Holding Ltd.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"\nThis file folds Chinese po files by hacking babel.messages.pofile.normalize\nusing jieba text segment library instead of regex\n\"\"\"\n\nimport datetime\nimport os\n\nfrom babel.messages import pofile\nfrom babel.messages.pofile import escape\n\n\ndef _zh_len(s):\n    \"\"\"\n    Calculate text length in Chinese\n    \"\"\"\n    try:\n        return len(s.encode('gb2312'))\n    except ValueError:\n        return len(s)\n\n\ndef _zh_split(s):\n    \"\"\"\n    Split text length in Chinese\n    \"\"\"\n    import jieba\n    try:\n        s.encode('ascii')\n        has_zh = False\n    except ValueError:\n        has_zh = True\n\n    if has_zh:\n        return list(jieba.cut(s))\n    else:\n        return pofile.WORD_SEP.split(s)\n\n\n# code modified from babel.messages.pofile (hash 359ecffca479dfe032d0f7210d5cd8160599c816)\ndef _normalize(string, prefix='', width=76):\n    r\"\"\"Convert a string into a format that is appropriate for .po files.\n    >>> print(normalize('''Say:\n    ...   \"hello, world!\"\n    ... ''', width=None))\n    \"\"\n    \"Say:\\n\"\n    \"  \\\"hello, world!\\\"\\n\"\n    >>> print(normalize('''Say:\n    ...   \"Lorem ipsum dolor sit amet, consectetur adipisicing elit, \"\n    ... ''', width=32))\n    \"\"\n    \"Say:\\n\"\n    \"  \\\"Lorem ipsum dolor sit \"\n    \"amet, consectetur adipisicing\"\n    \" elit, \\\"\\n\"\n    :param string: the string to normalize\n    :param prefix: a string that should be prepended to every line\n    :param width: the maximum line width; use `None`, 0, or a negative number\n                  to completely disable line wrapping\n    \"\"\"\n\n    if width and width > 0:\n        prefixlen = _zh_len(prefix)\n        lines = []\n        for line in string.splitlines(True):\n            if _zh_len(escape(line)) + prefixlen > width:\n                chunks = _zh_split(line)\n                chunks.reverse()\n                while chunks:\n                    buf = []\n                    size = 2\n                    while chunks:\n                        l = _zh_len(escape(chunks[-1])) - 2 + prefixlen  # noqa: E741\n                        if size + l < width:\n                            buf.append(chunks.pop())\n                            size += l\n                        else:\n                            if not buf:\n                                # handle long chunks by putting them on a\n                                # separate line\n                                buf.append(chunks.pop())\n                            break\n                    lines.append(u''.join(buf))\n            else:\n                lines.append(line)\n    else:\n        lines = string.splitlines(True)\n\n    if len(lines) <= 1:\n        return escape(string)\n\n    # Remove empty trailing line\n    if lines and not lines[-1]:\n        del lines[-1]\n        lines[-1] += '\\n'\n    return u'\"\"\\n' + u'\\n'.join([(prefix + escape(line)) for line in lines])\n\n\ndef main():\n    try:\n        import jieba  # noqa: F401\n    except ImportError:\n        return\n\n    pofile.normalize = _normalize\n    for root, dirs, files in os.walk('.'):\n        if 'zh' not in root:\n            continue\n        for f in files:\n            if not f.endswith('.po'):\n                continue\n            path = os.path.join(root, f)\n\n            # only modify recent-changed files\n            modify_time = datetime.datetime.fromtimestamp(os.path.getmtime(path))\n            if (datetime.datetime.now() - modify_time).total_seconds() > 120:\n                continue\n\n            with open(path, 'rb') as inpf:\n                catalog = pofile.read_po(inpf)\n            with open(path, 'wb') as outf:\n                pofile.write_po(outf, catalog)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "docs/source/norm_zh.py"}]}