-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support line break handling for RST output #32
Labels
Comments
Interestingly, you get a different behaviour if you use a wrapper to wrap the string in a class: import pytablewriter
class Wrapper:
def __init__(self, child) -> None:
self.child = child
def __str__(self) -> str:
return self.child
rst_tooltip = ".. raw:: html\n\n <span title=\"Tooltip\">Hello</span>"
writer = pytablewriter.RstGridTableWriter()
writer.headers = ["Header", "Header"]
writer.type_hints = [pytablewriter.String, pytablewriter.String]
writer.value_matrix = [
[Wrapper(rst_tooltip), "N/A"]
]
with open("test.rst", "w") as fout:
writer.stream = fout
writer.write_table() Which gives you: .. table::
+----------------------------------------------------+------+
| Header |Header|
+====================================================+======+
|.. raw:: html
<span title="Tooltip">Hello</span>|N/A |
+----------------------------------------------------+------+ Which doesn't strip the newlines, but also doesn't format the cells correctly either and isn't valid reST. I expected these to produce the same result. |
One (incomplete) idea would be to:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RST tables can handle cells with line breaks in them. It would be nice if pytablewriter supported them, rather than discarding them all.
The text was updated successfully, but these errors were encountered: