alminium / redmine_redcarpet_formatter

Another Markdown Wiki Formatter for Redmine based on Redcarpet markdown processor.
GNU General Public License v2.0
135 stars 38 forks source link

Support for hard-wrapping of linebreaks in text with Redcarpet :hard_wrap option #22

Closed lammel closed 11 years ago

lammel commented 11 years ago

Redcarpet supports the :hard_warp option, which is used by default in the GitHub Flavored Markdown.

This would allow to automatically wrap text to the next line when a linebreak ends the line. This is usually what the user expects. Markdown by default does not wrap the lines, but rather ignores the linebreak unless a empty line follows the linewrap.

A simple example would be:

Date for Meeting: 2013-01-12 Location: Amsterdam

I would expect to have Location:... be written on the next line, not concatenated to the first line.

I would ask for adding support to make use of this option by default. Feedback welcome.

Option from redcarpet HTML renderer:

:hard_wrap - insert HTML `<br>` tags inside on paragraphs where the origin
    Markdown document had newlines (by default, Markdown ignores these
    newlines).
mikoto20000 commented 11 years ago

Hum, I checked the Githhub wiki I think your sample written one line. Please see this wiki:

https://github.com/mikoto20000/test/wiki/test

However enabled option is too easy. I already comited hard_wrap support on "hardwrap-#22" branch. Could you try it?

lammel commented 11 years ago

Awesome! Just tested it with the hardwrap-#22 branch. My local changes for intra emphasis are also already in there, so everything is working as expected now.

This will help newcomers a lot, as it renders as you would expect for 80% of the use cases (we probably can't reach 100% anyway).

I also verified other parts of our wiki, they still render correctly. So no side-effects seen so far.

Many thanks for your fast response and coding!

lammel commented 11 years ago

We are using the hardwrap-#22 branch in production now since 1 week. No issues so far. If there are no objections from you/others it would be fine to merge to master and close this issue (and the branch)

Thanks a lot!

mikoto20000 commented 11 years ago

Thanks for your testing.

Unfortunately, this change influent all user and current user's wiki will be broken. So, I need to add configuration option for on/off hardwrap. After I implement the option, I'll merge it to master.

mikoto20000 commented 11 years ago

I added hard wrap option to plugin setting at hardwrap-#22 branch. Could you try it?

lammel commented 11 years ago

Just tried, I changed the default in init.rb to '0' for hard_warp though. It didn't seem to work (always enabled) while it was set to '1'. But that would be the default you'd like to use anyway.

So works great, I can easily toggle hardwrapping now, and keep me beloved default of hardwrap enabled of course.

Thanks!

mikoto20000 commented 11 years ago

It didn't seem to work (always enabled) while it was set to '1'.

Did you config by Administration > Plugins > Redcarpet Markdown Wiki formatter > Configure?

lammel commented 11 years ago

Yes of course, toggling it, did not change the format of a test wikipage. I even tried with restarting (I'm using puma to run redmine), just in case there is too much caching going on.

But after changing the default in init.rb everything worked as expected. So disabling hardwrap in the plugin config really disabled rendering (without restarting redmine).

So works great now. My diff is only:

diff --git a/init.rb b/init.rb
index c62fc2d..5109350 100644
--- a/init.rb
+++ b/init.rb
@@ -29,7 +29,7 @@ Redmine::Plugin.register :redmine_redcarpet_formatter do
   wiki_format_provider 'markdown',
Redmine::WikiFormatting::Markdown::Formatter, Redmine

   settings :default => {
-    'enable_hardwrap' => '1',
+    'enable_hardwrap' => '0',
   }, :partial =>'settings/redmine_redcarpet_formatter_settings'

 end

Roland Lammel QuikIT - IT Lösungen - flexibel und schnell Web: http://www.quikit.at Email: info@quikit.at

"Enjoy your job, make lots of money, work within the law. Choose any two."

2013/4/3 mikoto20000 notifications@github.com

It didn't seem to work (always enabled) while it was set to '1'.

Did you config by Administration > Plugins > Redcarpet Markdown Wiki formatter > Configure?

— Reply to this email directly or view it on GitHubhttps://github.com/alminium/redmine_redcarpet_formatter/issues/22#issuecomment-15807682 .