Skip to content
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

Markdown and line breaks #47

Closed
ak4nv opened this issue Sep 11, 2017 · 8 comments
Closed

Markdown and line breaks #47

ak4nv opened this issue Sep 11, 2017 · 8 comments

Comments

@ak4nv
Copy link
Contributor

ak4nv commented Sep 11, 2017

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.

@christopher-ramirez
Copy link
Owner

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

@christopher-ramirez
Copy link
Owner

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
Copy link
Contributor Author

ak4nv commented Sep 20, 2017

@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

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

@christopher-ramirez
Copy link
Owner

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

See this markdown output.

@ak4nv
Copy link
Contributor Author

ak4nv commented Sep 22, 2017

@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.

@christopher-ramirez
Copy link
Owner

christopher-ramirez commented Sep 22, 2017

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
Copy link
Contributor Author

ak4nv commented Sep 23, 2017

@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.

@christopher-ramirez
Copy link
Owner

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

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants