hnakamur / FormatLink-Firefox

A Firefox web-extension to copy the URL and the title or the selected text to clipboard
https://addons.mozilla.org/ja/firefox/addon/format-link3/
MIT License
45 stars 8 forks source link

Format Link for Firefox

Why do I need it?

To format the link of the active tab instantly to use in Markdown, reST, HTML, Text, Textile or other formats.

How to use

You can use keyboard shortcuts, context menus, or the toolbar button of Format Link extension to copy a link in the specified format. Before doing that, you can optionally select some text which may or may not contain a link.

keyboard shortcut

The keyboard shortcut for "Copy a link in the default format" is shortcut for clicking the toolbar button. The link is copied in the default format and the popup is shown under the toolbar button.

Also there are shortcuts for copying in the link in the corresponding format regardless of the default format.

See Manage extension shortcuts in Firefox | Firefox Help for showing and changing keyboard shortcuts.

context menu

Open the context menu and select the "Format Link as XXX" menu item. "XXX" in the menu item label changes as you change the default format by clicking the "Set as default" button in the popup page for the toolbar button.

If you want to disable the context menu option, you can uncheck the "Context Menus" checkbox.

If you check the "Create submenus" in the options page and save the options, submenus for each format are created under the "Format Link" context menu group.

toolbar button

When you press the toolbar button of "Format Link", the link is copied in the default format, the popup page becomes open, and the formatted text is shown in the text area.

If you want to copy the link in different format, you can press one of the radio buttons.

Also if you want to change the default format, you can press the "Set as default" button.

Flexible settings

You can modify formats in [Tools] -> [Extensions] -> Clik "Options" link in "Format Link" Extension. In format settings, you can use the mini template language.

Here are examples:

[{{text.s("\\[","\\[").s("\\]","\\]")}}]({{url.s("\\)","%29")}})
{{text}} <{{url}}>`_
<a href="https://github.com/hnakamur/FormatLink-Firefox/blob/main/{{url.s("\"","&quot;")}}">{{text.s("<","&lt;")}}</a>
{{text}}\n{{url}}
"{{title.s("\"","&quot;").s("\\[","&#91;")}}":{{url}}
\\href\{{{url}}\}\{{{text}}\}

Global variable replacements

You can preprocess value of each variable before applying above formats.

For example, you can replace opening and close double quotes in text variable with ASCII doublequote by settings text variable global replacements to {{text.s("[“”]","\"")}} or {{text.s("[\\u201c\\u201d]","\"")}}.

KNOWN LIMITATIONS

License

MIT License. Source codes are hosted at Github

Credits

Icon

I synthesized two icons (a pencil and a link) to produce icon.png.

Extension

This extension "Format Link" are inspired by extensions below: