SO-Oz / pagedown

Automatically exported from code.google.com/p/pagedown
Other
0 stars 0 forks source link

"Add heading" with no selected text doesn't add heading. #79

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Type in "balpha is awesome at "
2. Hit Ctrl-H or "Add header"

What is the expected output? What do you see instead?

balpha is awesome at ## Heading ##

(as opposed to)

balpha is awesome at

## Heading ##

What version of the product are you using? On what operating system?

Repro'd on Discourse and SE.

Please provide any additional information below.

I _think_ it would be enough to change 
https://code.google.com/p/pagedown/source/browse/Markdown.Editor.js#2182 so 
that chunkStart and chunkEnd also add newlines, perhaps like so:

        // If we clicked the button with no selected text, we just
        // make a level 2 hash header around some default text.
        if (!chunk.selection) {
            chunk.startTag = "\n\n## ";
            chunk.selection = this.getString("headingexample");
            chunk.endTag = " ##\n\n";
            return;
        }

(Sorry, I don't have Mercurial or Node installed right now.)

Original issue reported on code.google.com by badpazzword@gmail.com on 22 Sep 2014 at 9:28