christopher-ramirez/secretary

Markdown and line breaks

ak4nv opened this issue · 8 comments

ak4nv commented

After this manipulation I get an escaped line breaks (\n converts to \\n) and then I see \n as text in my odt file instead of new line. Also \n\n converts to \\n\\n.
I'm not sure about \t but I think it has the same issue.

Hello! Thank you for reporting this. I will be checking it today and hope to have a fix asap.

Hello! May you please provide a more in depth explanation of the issue at hand. I quite don't understand what you are reporting.

ak4nv commented

@christopher-ramirez Try to pass this text through the markdown filter:

ОАК от 08.09.2017: Лейк 7.9х10^9/л; Hb х 136г/л; Эр 3,96 х 10^12/л; Тром 174 х 10^9/л
ОАМ от 08.09.2017: Цвет- сол.жел. Уд.вес 1015 Белок- отриц Рh 6.0
Группа крови: 0 (1) СсДЕе
Б\Х от 08.09.2017 Сах.крови 4.9; Мочевина 3.5; Билирубин 10.3

Заведующий отделением: Медведников А.А.
_врач Захаров Антон Геннадьевич_

I can see the output is as spectated with the provided sample. Can you please clarify the issue?

See this markdown output.

ak4nv commented

@christopher-ramirez I'm sorry, I mean try to pass through the markdown filter in odt template. I've made a repo on github for explain this issue.
The result you can see on this screenshot.

Hello! I cloned your repo and tried the sample.

The code, as cloned, raised an Unicode exception. So I checked out the markdown text and I could saw it was the same that I tried already. So this was not the issue.

Then I had a look into the template, and found the issue. In the template you originally have the following filter order {{ text|e|markdown }}. In Secretary, for markdown to work as expected, the filter output should be marked as safe. So, the correct way to output the final formatted text is {{ text|markdown|safe }}.

Hope this resolves your issue.

PD.: As of Secretary 0.2.18, marking the markdown filter output "as safe" with |safe filter is not longer needed.

ak4nv commented

@christopher-ramirez Thanks for quick answer!
I guess I've catched the bug. Try to clone this repo again and run test.py
The difference between python versions. You use python2 (I think), but I use python3.5
I've run this code in python2 and it works fine! But in python3 I've gotten the result as on the screenshot above.

Hello I could reproduce the issue on Py3. I will check your fix and merge it.

Thanks for your help.