christopher-ramirez / secretary

Take the power of Jinja2 templates to OpenOffice and LibreOffice.
Other
190 stars 48 forks source link

Markdown filter and paragraph line break #63

Open jbjuin opened 6 years ago

jbjuin commented 6 years ago

Hi ! It seems that there is a problem with the mardown filter.

What I see

A line break in a markdown paragraph trigger the creation of a line break in the ODT.

fdsfdsf fdsf dsf fdsfdsf fdsfdsfdsf
fds fdsf fdsg gds gfdsg fdsg fds gfd

This generates a line break in the ODT which renders pretty badly with a justified text and a short line.

What I expect

My feeling is that a line break in a md paragraph should be rendered without line break in the ODT. In markdown only a "double space" at the end of a line in paragraph triggers a linebreak in the result. This avoid the text wrap in editor. You can just go at the line when you want and as soon as you do not double space you stay in the same paragraph.

Suggestion

I just discovered mistune a fast python markdown parser. With mistune one can write a Renderer to output the parsed markdown. I started writing an ODTRenderer (it's quite easy !) but then found out that secretary has a markdown filter and stopped.

Such renderer as a markdown filter logic replacement may be easier to maintain.

What is you position about dependencies ?

Do you accept pull requests on this project ? I may be interested to do one on this subject.

Anyway Secretary is pretty cool ! Thank you for your effort on this !

christopher-ramirez commented 6 years ago

Hello!

Thank you for this post.

In markdown only a "double space" at the end of a line in paragraph triggers a linebreak in the result.

Which version of Secretary are you using? There's was a regression bug that caused this. The latest version should not be affected.

What is you position about dependencies ?

New dependencies are OK as long as they do not depend on native libraries or some special settings on the host machine. PIL for example is a no-no.

Do you accept pull requests on this project ? I may be interested to do one on this subject.

Yes. Pull request are welcome.

Ragards

screwt commented 6 years ago

Hi i can reproduce this behavior with the libraries bellow:

Jinja2==2.10
markdown2==2.3.5
MarkupSafe==1.0
python-dateutil==2.7.2
secretary==0.2.19
six==1.11.0

Is the problem there?: https://github.com/christopher-ramirez/secretary/blob/4b4cd7dda58b89cf0e295829809bcfdbbd5bf333/secretary.py#L826

Seems ok with master branch, last release 0.2.19 is not ok.