picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Linebreak (METAKEY + RETURN) in Nextcloud (19.0.1) Text App creates backslash at line ends in rendered html pages #566

Closed herrtreffler closed 3 years ago

herrtreffler commented 3 years ago

As @daftmilk mentioned in this issue Linebreaks in Texteditor do not conform to Markdown-Syntax the Nextcloud Text app indicates line-breaks with a "\" in the end of a line. I used the nl2br twig (3.x) filter in the themes index.twig file, which creates a html <br /> tag, but leaves the "\" character on line ends. Is there another Pico or Twig filter to replace the backslashs with a space or are changes in the config.yml necessary? I tried to chain | nl2br with | replace({"\\n":""}) but with no effort.

PhrozenByte commented 3 years ago

I'm afraid Nextcloud's Text app isn't supported due to a lot of other, even more severe issues (like removing YAML Front Matters). There are plans to improve the situation, however, in the meantime I recommend using a different text editor, like https://apps.nextcloud.com/apps/files_markdown or https://apps.nextcloud.com/apps/files_texteditor

Besides: "\\n" actually reads as \ and n, not your intended \ and \n - \ is the escape character, thus \\ actually results in \. Try |replace({"\\\n": ""}) instead, it should do what you intend. However, I wouldn't chain it with |nl2br but directly transform it to <br />, resulting in |replace({"\\\n": "<br />"}).

By the way: This issue should rather be in https://github.com/nextcloud/cms_pico, this repo is about "pure" Pico :smile:

herrtreffler commented 3 years ago

😄 Damn. I was scared like hell to open my first issue on github, mostly beeing afraid to post it at the wrong place (which I did) or write off-topic-spam (like I do now). Feel free to move it to the right repo. I guess I'm not able to transfer it, do I?

Nevertheless your fix |replace({"\\\n": "<br />"}) did the job just perfect. Actually my intend was to use the text editor app, which comes as a preset in my NC installation, as a WYSWYG editor where users don't have to think about markup language. Even it limits Picos theme functionality, my basic website idea works even without YAML Front Matter. Or in other words: Pico is just awesome. I will return the favour for sure. 👍

PhrozenByte commented 3 years ago

:smile: Damn. I was scared like hell to open my first issue on github, mostly beeing afraid to post it at the wrong place (which I did) or write off-topic-spam (like I do now). Feel free to move it to the right repo. I guess I'm not able to transfer it, do I?

Unfortunately we can't transfer the issue there. But no worries, it's not that of a big deal :smile: Don't hesitate to open another issue if you have any question.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: