typora-issues icon indicating copy to clipboard operation
typora-issues copied to clipboard

Converting link and image syntaxes

Open Crissov opened this issue 8 years ago • 6 comments

Commonmark specifies these types of link syntax, which Typora hence absolutely needs to support: #744

<[email protected]>

<scheme://link.destination/auto>

[link text](link_destination/inline)

[link text][link label] 
...
  [link label]: link_destination/reference/full

[link label][] 
...
  [link label]: link_destination/reference/collapsed

[link label] 
...
  [link label]: link_destination/reference/shortcut

Autolinks do not support an optional link title, but all other formats do. It follows the URL separated by whitespace and enclosed in either a balanced pair of parentheses, i.e. ( and ), or a pair of plain quotation marks, either double " or single '.

[link text](link_destination/inline "link title")
[link text](link_destination/inline 'link title')
[link text](link_destination/inline (link title))

  [link label]: link_destination/reference "link title"
  [link label]: link_destination/reference 'link title'
  [link label]: link_destination/reference (link title)

I wish Typora could convert between these formats where feasible, especially collapse link labels if possible. It should be able to do so per document, per block (e.g. paragraph or table), per selection and per link. It should probably move reference link definitions to the end of the document and, respectively, after the block or selection. Typora should be able to automatically sort reference link definitions either by their link labels or by their link destinations, remove duplicates and warn the user about conflicts: When there are two or more reference link definitions with the same link label, only the first one is used by Commonmark rules. Duplicate link destinations are valid but probably undesired most of the time (unless they are intentional placeholders), so Typora should make it simple to merge them.

Typora should be able to fill in the link title upon user request by fetching the link destination and parsing it, e.g. use the content of the title element for HTML documents. Similarly, image descriptions might be populated automatically, e.g. from the desc element of an SVG file or just from the file name sans extension.

Crissov avatar Oct 20 '17 10:10 Crissov

Share current condition:

  • [link label] is not supported.
  • (title) may have some bugs.

We should also consider "Converting" between different syntax styles

abnerlee avatar Jan 19 '18 16:01 abnerlee

I just want to put in another voice for adding the capability to hide/collapse the link labels. Especially when writing a document that contains many links, I find that having the labels appear at the end of each section (which is where I put my labels) makes things quite difficult/ugly to read.

Thanks for developing this useful tool!

ahsv avatar Feb 09 '18 06:02 ahsv

@abnerlee [link label][] (collapsed reference link) is not supported by Typora, indeed, and neither is [link label] (shortcut reference link).

@ahsv That sounds like a separate though related issue.

Crissov avatar Feb 09 '18 08:02 Crissov

@Crissov Sorry my previous comment seems incorrect, actually [link label][] is supported, [link label] (shortcut reference link) not supported yet.

abnerlee avatar Feb 09 '18 09:02 abnerlee

Indeed, so my response was incorrect as well.

Crissov avatar Feb 09 '18 10:02 Crissov

+1 for the conversion from Links to Reference Links, placed at the end of the document.

Often, Markdown Links disturb the reading flow, if viewed in Source Mode (the default for most users reading Markdown), and I prefer to put links at the end.

At the same time, I prefer to use Typora for HTML-> Markdown conversion. It would be awesome if Typora could support automatic conversion to reference links on Input (copy&paste).

*That said, I really like Typora, already, it is awesome and of course, I purchased a license.

Sieboldianus avatar Aug 26 '22 06:08 Sieboldianus