Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add yank (copy) markdown link of current tab #4240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
johanna-a wants to merge 1 commit into philc:master
base: master
Choose a base branch
Loading
from johanna-a:add_yank_markdown

Conversation

@johanna-a
Copy link

@johanna-a johanna-a commented Mar 30, 2023

This adds a new command, copyCurrentMarkdown, with a default keybinding ym, to copy a link to the current tab in markdown format, i.e. "title".

Description

Firstly, this has been suggested and implemented before, see PR #2054.
However, that pull request was never merged.
Having a way to copy a link in markdown format is implemented in other projects for keyboard-based browsing, for example qutebrowser. It is typically something a user expects to be able to do easily.
It relates to issues #131 #889 #2474 #3611 #4133

pawmar, MichelJe, glostis, JulianDeal, ooloth, 80avin, arnfaldur, ewnd9, hesselmonk, and mantzu132 reacted with thumbs up emoji
This adds a new command, copyCurrentMarkdown, with a default keybinding
`ym`, to copy a link to the current tab in markdown format, i.e.
"[title](url)".
Copy link

ooloth commented Oct 30, 2023

I'd love to see this ym PR merged! It would be a big help for my note-taking workflow.

Copy link

@scotho3 scotho3 left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fantastic! Nice simple addition.

Copy link
Owner

philc commented Jan 25, 2024
edited
Loading

Could everyone who's interested in this elaborate on your use cases?

  1. Are you pasting this information into your markdown files, into Github, into social media sites?
  2. Why just Markdown? Why not HTML -- or rich text, so the link can be copied into editors like Google Docs or Slack?
  3. Do you ever want the title and not the URL? Many of the older bugs which were referenced were requesting a shortcut to copy the title of the page, not the combination of title and URL.
  4. Why is this needed for the current page only, and not for link hints? Note that there is an existing command yf (LinkHints.activateModeToCopyLinkUrl) which copies a link URL to the clipboard. Should there be a similar command to copy the link+title to the clipboard?

I'm concerned about adding a feature which is too narrow.

Note that @gdh1995 has an implementation where the format of the copied text / URL can be customized, which allows the command to cover all use cases. If we went with a similar approach, then the command should probably be called copyCurrentUrlAndTitle (even if the default formatter is Markdown), rather than copyCurrentMarkdown.

Copy link

ooloth commented Jan 27, 2024

Could everyone who's interested in this elaborate on your use cases?

  1. Pasting into markdown notes (Obsidian)
  2. Additional powers sound fun (though would be used rarely)
  3. No
  4. Copying markdown links for link hints instead of having to visit those pages first would be great

Copy link

boesi commented Feb 1, 2024

Could everyone who's interested in this elaborate on your use cases?

1. Are you pasting this information into your markdown files, into Github, into social media sites?
2. Why just Markdown? Why not HTML -- or rich text, so the link can be copied into editors like Google Docs or Slack?

Right now I use a simple Word file for notes - so HTML would be great. But for my workflow, the clipboard needs to have the content type text/html.

3. Do you ever want the title and not the URL? Many of the older bugs which were referenced were requesting a shortcut to copy the title of the page, not the combination of title and URL.

I use the command copyCurrentTitle to create the link in Word by hand. I think I wouldn't need it, if there was a command copyCurrentInfo

4. Why is this needed for the current page only, and not for link hints? Note that there is an existing command `yf` (`LinkHints.activateModeToCopyLinkUrl`) which copies a link URL to the clipboard. Should there be a similar command to copy the link+title to the clipboard?

I need this for the current page and link hints.

PS: I know Word is terrible in every way, but for now this is the easiest solution for me.

Copy link

glostis commented Feb 1, 2024

Could everyone who's interested in this elaborate on your use cases?

  1. I'm often pasting links text editors that supports Markdown syntax, and I feel that using the page title is more readable than just pasting the link.
  2. Markdown-compatible text editors are quite common: Github issues/PRs, Slack (you need to activate an option for this), Google Docs (you need to activate an option for this), JIRA. I generally feel more "in control" when using plain text as opposed to rich text.
  3. No, when I paste a page title, I always want the URL with it.
  4. Having it for link hints would be great as well!

Copy link

80avin commented Feb 8, 2024
edited
Loading

My use-case is also to paste it into Slack or rich text documents (google Docs/Sheet, confluence, etc) or markdown editors.

I think a better way would be to copy rich text (text/html) instead of the markdown as text/plain.
Most markdown editors support pasting rich text links and automatically convert them into markdown links or whatever format they support.

Using native clipboard API, I can do it easily as

const data = [new ClipboardItem({
 'text/html': new Blob([`<a href="${document.location.href}">${document.title}</a>`], {type: 'text/html'}),
 'text/plain': new Blob([document.title], {type: 'text/plain'})
})]
navigator.clipboard.write(data)

Pasting this clipboard item into most markdown/rich-text editors works and they render it as they like. It further has the advantage of using Ctrl+Shift+V to paste as plain text.

Copy link

zzeitt commented Mar 23, 2024

Use VimiumC like this:

map ye copyWindowInfo format="[[${url}][${title}]]" type="tab"

Ref: https://github.com/gdh1995/vimium-c/wiki/Substitute-URLs-and-text-during-commands#copy-information-of-tabs

Note: Change format as per your need.

Copy link

srackham commented Oct 8, 2024

This would be a great feature. I like the generic approach taken by VimiumC: for example by allowing a format argument for the copyCurrentUrl command. This would allow the creation of a custom mapping with something like e.g.

 map ym copyCurrentUrl format='[%t](%u)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@scotho3 scotho3 scotho3 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /