Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Would like to use Markdown formatting, but with one feature borrowed from BBCode input formatter

2

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
  • I like your badge better, just wanted to try my hand at it so to speak.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited August 2014

    That design looks very cool for a logo too , for a witch burning cult, or the Torch movement, or even Sports company.. Sports team the lightning Torch :D

  • peregrineperegrine MVP
    edited August 2014

    is it too late to copyright, so I can collect royalties?

    It could also double as a "smote" badge.

    as in "he smote thee"

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    No, but it only takes effect as soon as someone makes a mint from it. Then you have to fight them in court and prove you thought of it first....

  • DoyceTDoyceT Model Questioner ✭✭✭
    edited August 2014

    You guys are great. :)

    So I noticed one slightly annoying problem - when someone quotes the poem, the 'soft line breaks' are not honored within the quote.

    It looks as though that's a result of the way the quotes addon is written. Specifically, these lines (270 to 275 in quotes.js):

             case 'Markdown':
             case 'Display':
             case 'Text':   // Plain
                var Append = '> '+Data.Quote.authorname+" said:\n";
                Append = Append+'> '+Data.Quote.body.replace(/(\n)/g, "$1> ")+"\n";
                break;
    

    It seems like I need to put a couple more blank spaces in there to get the soft line breaks to show in quotes, but I'm not 100% sure where. Just before the $1?

  • Yes, that should work (you'll have to try it out to be sure, though).

    Maybe you could even put it in the plugin with

    public function PostController_Render_Before($Sender) {
        $Sender->RemoveJsFile('quotes.js');
        $Sender->AddJsFile('quotes.js', 'plugins/MarkdownMarkup');
    }
    

    and

    public function DiscussionController_Render_Before($Sender) {
        $Sender->RemoveJsFile('quotes.js');
        $Sender->AddJsFile('quotes.js', 'plugins/MarkdownMarkup');
    }
    

    ...to overwrite the original quotes.js.

    Let's just hope it has a higher precedence...

  • x00x00 MVP
    edited August 2014

    html is integral to markdown therefore any solution must be mindful of this. The last thing you want is out of place br/p tags all over.

    grep is your friend.

  • You should consider why they removed that code from the core in the first place...

    grep is your friend.

  • BleistivtBleistivt Moderator
    edited August 2014

    I'd guess they removed it because it broke existing comments formatting and the behaviour was unexpected for users.

    What this plugin does is basically just like someone went and added two spaces to the end of every line.

    HTML will ignore the extra whitespace and Markdown should not add an extra break before a new paragraph.

    Still, it should be tested extensively, especially markdown tables.

  • Yes your solution is better, the other solution added br directly which is probably why they took it out.

    grep is your friend.

  • DoyceTDoyceT Model Questioner ✭✭✭
    edited August 2014

    True, if someone were using this on a forum where the users had major markdown kung-fu, I definitely wouldn't recommend it.

    In my case, I've got people who are doing victory laps if they can correctly format a bullet list. I'm leading them on the first baby steps of "future proof your writing by using plain text."

    I've decided not to screw with the quotes.js - it's enough of an edge case (and it doesn't misbehave all the time, even now) that I don't want to screw with it - it's a good opportunity for them to learn how to do a line break properly by inserting the two spaces themselves. Baby steps...

  • LincLinc Detroit Admin
    edited August 2014

    @Bleistivt said:
    There was a change in master some time ago to respect soft linebreaks in Markdown, but it was reverted

    You are following closely :) I made an error when implementing soft line breaks and upgrading to latest Markdown library and was asked to revert the change until I have time to do it properly (which will be before 2.3).

    @Bleistivt said:
    I'd guess they removed it because it broke existing comments formatting and the behaviour was unexpected for users.

    No, this is absolutely the default behavior I want in our Markdown implementation. It isn't just poets - it drives everyone nuts to not have easy single line breaks when posting on a forum. It also makes quoting hit or miss - without the extra line break, your reply gets wrapped into the quote. The issue is strictly the unrelated issues I introduced with my first attempt that needed to be undone ASAP (e.g. code formatting had extra line breaks added).

  • DoyceTDoyceT Model Questioner ✭✭✭

    @Linc said:
    ... until I have time to do it properly (which will be before 2.3).

    That's great news. I'd always rather be relying on core functions. :)

  • LincLinc Detroit Admin

    In my continuing quest to be more transparent I've added this as an issue against 2.3: https://github.com/vanilla/vanilla/issues/2045

  • @linc have you considered switching to parsedown?

    It seems to be a lot faster and has an option to enable normal linebreaks built in (setBreaksEnabled).

  • LincLinc Detroit Admin
    edited August 2014

    @Bleistivt said:
    linc have you considered switching to parsedown?

    We have considered switching libraries entirely, yes; I'll add that as a reminder on the task. I don't think we've made a final decision yet.

  • Hey guys, I've built on the MarkdownMarkup plugin posted earlier in this thread to get it to work with previews and messages as well in case anyone's interested: https://github.com/29th/vanilla-markdownmarkup

  • R_JR_J Ex-Fanboy Munich Admin
  • LincLinc Detroit Admin
    edited February 2015

    Soft line breaks has been implemented in core.

Sign In or Register to comment.