Giter Site home page Giter Site logo

notlmn / copy-as-markdown Goto Github PK

View Code? Open in Web Editor NEW
304.0 8.0 45.0 528 KB

🖱 Browser extension to copy hyperlinks, images, and selected text as Markdown with GFM support

License: MIT License

JavaScript 100.00%
markdown html-to-markdown browser-extension chrome-extension firefox-addon

copy-as-markdown's Introduction

Copy as Markdown

Browser extension to copy hyperlinks, images, and selected text as Markdown

Install

Screenshot

Copy as Markdown

Features

The extension allows you to copy selected text on a page as Markdown with support for features including the following

  • Ability to copy links, images, and selected text as Markdown.
  • Linked images, will have options to individually select link or images.
  • Formatted text such as italic, bold, strike-through, and inline code.
  • Unordered and ordered lists, with task lists support.
  • Tables, with respect to GFM.
  • Fenced code blocks, with language detection using info strings.

Known Issues

Note: When copying links and images, Chrome doesn’t let you extract images alt text or anchors text content to be used in Markdown, instead the links themselves are used as link title. Firefox doesn’t have this limitation though.

Permissions

The extension requires the following permission from you for working.

  1. contextMenus: to show option when right-clicking.
  2. activeTab: to be able to access content on page.
  3. clipboardWrite: to be able to write data to clipboard (we still can’t read from your clipboard).

Credits

Inspired by this tweet from @nicolo-ribaudo, and publishing made possible by @yakov116.

Related

License

MIT © Laxman Damera

copy-as-markdown's People

Contributors

higurashi-kagome avatar notlmn avatar yakov116 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

copy-as-markdown's Issues

There are unnecessary spaces when copying a list.

steps to reproduce issue

copy something like:

<ul>
<li>something</li>
<li>something</li>
<li>...</li>
</ul>

actual behavior:

-   something
-   something
-   ...

expected behavior

- something
- something
- ...

Multiple line codeblocks with triple backticks

When copying conversation from chat.openai.com ChatGPT / GPT4 , I believe multiple improvements could be made ( e.g. #33 ),

but one that I believe also would help on many other sides with codeblocks that are easy to copy and paste:

Current behaviour:

> after copy&paste of codeblock
> 
> `multi
> line
> code
> is surrounded by single backticks`
> unfortunately

Expected behaviour:

> after copy-as-markdown
> 
> ```
> multi line
> line code/text
> is surrounded by
>  triple backticks
> ```

P.S. I used > indentation because otherwise I don't know how to put triple backticks inside triple backticks in Markdown

"Copy selection as markdown" does not work in Firefox.

The "copy as markdown" feature is not working, though that would be the most useful feature for me ( "Copy image as markdown" and "Copy link as markdown" work). I am using

Browser: Firefox 73.0.1
OS: Fedora 31 or Windows

I tried it on:

  1. a page with an advanced layout:
    https://start.fedoraproject.org/
  • Select an entire entry including the image
  • Copy selection as markdown (fails)
  1. a page with a simple layout:
    https://wiki.minetest.org/main/list_of_minetest_mobs.html
  • Go to the "Simple Mobs" section.
  • Select an area starting before and ending after the image of the DM.
  • Copy selection as markdown (fails)
  • Select an area only containing text
  • Copy selection as markdown (fails)

Strikethrough Support

Turndown supports Strikethrough. When doing a Strikethrough, you should be able to use 2 tilde characters before and after.

~~sample~~
renders as
sample

This does not appear to be supported using the copy as markdown feature. I had the following HTML that I had copied that didn't convert:

<strike>sample</strike>

Copying Markdown from a web page and pasting it into a note causes extra characters to appear.

Copying Markdown from a web page and pasting it into a note causes extra characters to appear.
Chrome 120 | FireFox 120
Windows 10 19044
Extension latest version

The sample web page content is as follows:

<html><body>
<!--StartFragment--><strong>型号:</strong>
   <span class="value"><a href="https://www.zol.com.cn/BMO_codes/BMO">BMO</a>-593</span>
   
  <div class="panel-block">
  <strong>上市日期:</strong>
   <span class="value">2022-10-25</span>
</div>
<div class="panel-block">
  <strong>长度:</strong>
   <span class="value">125 公分</span>
</div><!--EndFragment-->
</body>
</html>

Steps to reproduce:

  1. Use the extension to copy the above code into Markdown;
  2. Paste into Markdown notes;
  3. If you look at the actual effect, there will be extra characters;

image
Hello! Is there any way to prevent this extra character from appearing after pasting it into a note?

Copy as Markdown sometimes missing from Firefox context menu

I haven't been able to reproduce this reliably, sorry. Just noting observations and a workaround.

Sometimes when I select text in a page, then right click to copy-as-markdown, the menu item "Copy selection as Markdown" is missing from Firefox's context menu.

I have made sure the extension is allowed in private windows (though this happens on non-private windows).


What I have found fixes this, is to disable and then re-enable the extension, then reload the web page.


After reload and selecting the same text, the menu item is available and the copy-as-markdown works as usual.

(thank you for this extension, I use it a lot!)

Can't access options

Can't access options
Hi all, I am using Copy as Markdown in Brave Browser. I cannot seem to get to the options menu as it doesn't display completely. Just the first line appears. How can I see and change the options (maybe directly in the files), to get a shortcut to copy as Markdown?

Ability to copy with stripped links?

Thanks for creating this plugin, looks very promising.

I wonder if you could add an option / menu item / setting to copy markdown selection without links. For example instead of

### [](https://github.com/notlmn/copy-as-markdown#known-issues)Known Issues

I'd like to have just

### Known Issues

Sometimes links get in a way and reduce readability.

Mobile support: Add contextual menu on toolbar icon click (instead of linking to the github)

Thank you very much for this awesome extension!

On mobile, there is there are some browsers such as Kiwi which support installing any Chrome extension. The issue is that it does not populate the contextual menu as it does on desktop, hence the only way to interact with extensions on mobile is by clicking on the extension's toolbar icon.

Currently, copy-as-markdown directly redirects to this github repo on click, but a simple solution would be to add a simple menu on icon click that simply displays the same options as the right-click contextual menu + a link to this github.

link title is not right

So far I haven't found any better copy as markdown extension, but still, it has the following issue.

By right click on the following link
<a href="https://github.com/notlmn/copy-as-markdown">copy as markdown repository</a>
and selecting copy link as markdown option, it copies this:
[https://github.com/notlmn/copy-as-markdown](https://github.com/notlmn/copy-as-markdown)
whereas it should copy this:
[copy as markdown repository](https://github.com/notlmn/copy-as-markdown)

Copy issues when plain text

When copying just plain text, it does not appear to copy anything. So, if there's nothing special to convert to Markdown, it won't copy.

Firefox extension wraps strike-through text with single tilde instead double tilde

For example, when copying this text from the README of this project:

Formatted text such as italic, bold, strike-through, and inline code.

... it should produce this markdown:

- Formatted text such as _italic_, **bold**, ~~strike-through~~, and `inline code`.

... but current produces this markdown:

- Formatted text such as _italic_, **bold**, ~strike-through~, and `inline code`.

When using https://euangoddard.github.io/clipboard2markdown/ with the same example, that page will produce "correct" markdown.

I know that there are different flavors of markdown. But I find it a bit strange that this extension and the mentioned website produce different markdown, since both projects seem to be based on https://github.com/mixmark-io/turndown

According to https://github.com/mixmark-io/turndown/blob/48f9bace01a14f7f2ed4cf6052e0a89ba190bb3a/dist/to-markdown.js#L207 , turndown should indeed produce the double-tilde variant for strike-through text.

adding shortcut key functions to commands

Hi! friend! Your extension is great!

Hi! friend! Can you consider adding shortcut key functions to commands, so that you don't always have to open the right-click menu to select commands, so work efficiency will be greatly improved.

Thanks again for a great extension!

Chrome 120...
Windows 10

Features for ChatGPT / GPT4 dialogs

When copying conversation from chat.openai.com ChatGPT / GPT4 , I believe multiple improvements could be made.

E.g. when copying conversation it could separate "User:" and "Assistant:" somewhow (e.g. with ----- ?), and annotate whose which part is, e.g.:

-----
User:

Hello!
-----
Assistant:

Hello dear user, how can I help you?
-----

Chrome extension has been desactivated !!!

Download the crx file and drop it into the the Chrome tab chrome://extensions.

Problem : Chrome has desactivated my extension immediately !

It's only possible to use Chrome extension available or puiblished on Chrome Store !

Could you publish this extension on Chrome Store ?

Support for hr element

The Markdown code like this:

....

----

....
Preview

....


....

Copy As Markdown get this:

....

-

....

Thanks.

Support for LaTeX formula

Hope to support copying latex formula as markdown. When the web page contains latex formula, it seems that there is something incompatible when using copy-as-markdown. One example is shown as follows, the left is the web page while the right is the markdown text converted by copy-as-markdown.

image

Copy page link as markdown with title

I'm not sure if this is the place for a feature request, but it would be great if this extension provided a way to copy the current page as a markdown link using the page title for the link name.

Optionally copy as HTML

This is the best plugin of its kind, thanks a lot for making it available and maintaining it. It really saves me a lot of time, and mostly MD is the format I need in my daily work. Only rarely, I need links in HTML, e.g. in emails and sometimes in forums or ticketing systems.

That's why I wonder if it were possible to add an option (with limited features) to copy links (and maybe images) in HTML format? All the other features (styling support, etc.) are not required, though. Just plain links, and since this plugin has all the infrastructure in place, this extra feature might be a reasonable enhancement, rather than installing yet another plugin for HTML links.

Shortcut not working ?

I tried setting multiple shortcuts to see if it works.
I couldn't. Not sure what the problem is.

Keyboard Shortcut

The Chrome extension supports setting a shortcut to activate the extension but I can't find a way to set a keyboard shortcut for "copy link as markdown".
Is it possible to add that ability to the extension?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.