I am unable to get new lines to appear in my generated html page when using libdoc on Robotframework.
MyResource.resource
*** Settings ***
Documentation
... Testing for new lines
... Here is a second one
...
... And new paragraph\n
... New line in the new paragraph
*** Keywords ***
Test Case for checking documentation
[Documentation]
... First line which goes on and on for quite some time\n
... Second line cause the first was too long
...
... New Paragraph
... Another new line for the new paragraph
... | Test | Table |
... | Works | fine |
... V Look at that line V
... ---
... My list
... - item 1
... - item 2
No Operation
HTML source code
<script type="text/javascript">
libdoc = {"name": "MyResource", "doc": "<p>Testing for new lines Here is a second one</p>\n<p>And new paragraph New line in the new paragraph</p>", "version": "", "generated": "2021-11-24 11:10:06", "type": "RESOURCE", "scope": "GLOBAL", "docFormat": "HTML", "source": "MyResource.resource", "lineno": 1, "tags": [], "inits": [], "keywords": [{"name": "Test Case for checking documentation", "args": [], "doc": "<p>First line which goes on and on for quite some time Second line cause the first was too long</p>\n<p>New Paragraph Another new line for the new paragraph</p>\n<table border=\"1\">\n<tr>\n<td>Test</td>\n<td>Table</td>\n</tr>\n<tr>\n<td>Works</td>\n<td>fine</td>\n</tr>\n</table>\n<p>V Look at that line V</p>\n<hr>\n<p>My list</p>\n<ul>\n<li>item 1</li>\n<li>item 2</li>\n</ul>", "shortdoc": "First line which goes on and on for quite some time Second line cause the first was too long", "tags": [], "source": "MyResource.resource", "lineno": 10}], "dataTypes": {"enums": [], "typedDicts": []}}
</script>
My execution line:
libdoc .\MyResource.resource MyResoure.html
Running RobotFramework version 4.1.2
I have tried the following:
My expected output
Testing for new lines
Here is a second one
Newlines embedded in a line of documentation have no effect on the rendering of the paragraph. Here are relevant quotes from the user guide section titled Documentation Formatting:
As explained in the Paragraphs section below, the single newline in
Second paragraph, this time\nwith multiple lines.
does not actually affect how that paragraph is rendered.
and:
All regular text in the formatted HTML documentation is represented as paragraphs. In practice, lines separated by a single newline will be combined in a paragraph regardless whether the newline is added manually or automatically.
A bug report was submitted back in 2014, and was closed with a comment that the behavior won't be changed. A feature request to support linebreaks was submitted in late 2021 and was also rejected.
It's unfortunate since embedded newlines in the early versions of robot framework actually caused linebreaks.