One thing I find myself doing more than occasionally is copying the OP's code (or even another answer's code) and editing it to correct it, rather than writing the whole thing from scratch in my own coding style.

However, when copying the block of code, it does not copy the four spaces to the left that are required in Markdown to render properly. This can get irritating for longer blocks of code, where I have to then insert the appropriate number of spaces for each line.

... Okay, so I've just found out that selecting the code I've just pasted and clicking the "Code block" button will indent it by four spaces. Good to know, but still...

I'm just wondering if copying text can result in it being formatted in Markdown. For instance if I copy the following:

This is some text, with bold, and...

a code block!

Then it would paste as the required Markdown.

I can see this being achievable by having the HTML be something like:

<p>This is some text, with <span class="h">**</span><strong>bold</strong><span class="h">**</span>, and...</p>
<pre><code><span class="h">    </span>a code block!</code></pre>

Where .h {display:none}

I dunno, it just seems like it'd be easier than clicking Edit to get at the Markdown source. Sorry if this seems like a dumb idea! XD

  • 1
    I think this could be useful when copy-pasting documentation from GitHub too for manual references since they also use Markdown. Then again, both in GitHub and in here, getting the source is just a click away. – Benjamin Gruenbaum Jun 14 '13 at 1:10
  • I think paste, re-select, and Ctrl+K is probably fast enough. – Ry- Jun 14 '13 at 2:04

You must log in to answer this question.

Browse other questions tagged .