Refined-github: 'Copy to Markdown' improvements

Created on 23 Jun 2017  路  12Comments  路  Source: sindresorhus/refined-github

Related to #486 and #487

  • [x] Images with a width or height attribute set needs to be converted back to an <img> as Markdown images can't have a width/height
  • [ ] Mentions should not be converted to links
  • [x] Copying a rendered emoji (馃敟馃敟馃敟) in Chrome on macOS results in: <g-emoji alias="fire" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f525.png" ios-version="6.0" title=":fire:">馃敟</g-emoji><g-emoji alias="fire" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f525.png" ios-version="6.0" title=":fire:">馃敟</g-emoji><g-emoji alias="fire" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f525.png" ios-version="6.0" title=":fire:">馃敟</g-emoji> We should strip out all the junk and just copy the character.
enhancement

Most helpful comment

I've disabled this functionality temporarily now (will be published automatically in about 3 hours) until we can implement an alternative way to activate it. I agree now that it should not be the default copy behavior.

I've also been experiencing it making copy not work at all randomly. @bfred-it Seems like https://github.com/sindresorhus/refined-github/pull/636 didn't totally fix it after all.

All 12 comments

  • [ ] Copying the a whole code block (and nothing else) should not include markdown. e.g. triple click this on a Mac:
chicken.chicken = chicken(chicken).then(chicken)

Results in

```source-js
chicken.chicken = chicken(chicken).then(chicken)
\```

Edit: this is hard. Triple click selects a bunch of tags, including the start of the following <p>

  • [x] #130 should be copied as:
https://github.com/sindresorhus/refined-github/issues/130

instead of

[#130](https://github.com/sindresorhus/refined-github/issues/130)

but perhaps it's not worth the trouble (also because I'm using the current behavior to post shortened URLs for others to see)

  • [x] Exclude elements outside .markdown-body. The copy event is triggered on the element that contains the selection start, but if your selection ends outside, it will also include a bunch of other unrelated elements.

Mentions should not be converted to links

Are you sure about that? If I mention @sindresorhus and then someone copies this text, I'm not sure if the intent would be to notify you again.

  • [x] No line breaks or numbers when selecting any list partially (i.e. when <ol> and <ul> are not technically selected):

  • Juan

  • to
  • tree
  1. hey
  2. bee
  3. see
  4. dee
  5. e
  • one
  • multiline
    text
  • three

Are you sure about that? If I mention @sindresorhus and then someone copies this text, I'm not sure if the intent would be to notify you again.

Agreed. Didn't think about that.

Hi, I'm facing some issues with this feature, often I want to copy sample code from readmes etc, and now it is coping with the whole markdown syntax. Can we make this feature optional or at least detect if the text we want to copy is code block?

@sindresorhus we could leave the standard copy alone and instead show a "copy as markdown" button next to selections.

@bfred-it Yeah maybe. Or we could use a different keyboard shortcut like Cmd+Option+C.

I was just searching through the issue tracker to try to find a way to disable this selectively, and was indeed thinking a keyboard shortcut would be the way to go.

My use case is copying commands from READMEs; if I Ctrl+C them now, I get backticks, which of course confuse my shell.

Yeah, I've had this extension removed for a week or so now and my github happiness has increased significantly. It's a PITA to have enabled with this, especially, _especially_, the amount of times I copy simple things like yarn add <package> or just a package name from the npm to convert myself into yarn syntax and I get markdown syntax with linebreaks and all.

I've disabled this functionality temporarily now (will be published automatically in about 3 hours) until we can implement an alternative way to activate it. I agree now that it should not be the default copy behavior.

I've also been experiencing it making copy not work at all randomly. @bfred-it Seems like https://github.com/sindresorhus/refined-github/pull/636 didn't totally fix it after all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fregante picture fregante  路  3Comments

hkdobrev picture hkdobrev  路  3Comments

sompylasar picture sompylasar  路  3Comments

mareksuscak picture mareksuscak  路  3Comments

shivapoudel picture shivapoudel  路  3Comments