Giter Site home page Giter Site logo

Comments (2)

RickStrahl avatar RickStrahl commented on May 24, 2024

If you embed a file that is more than a couple of levels removed from the current one, the link will be embedded as a fixed path. Arguably this should be a file://xxx/ path, but frankly that's not going to work any better unless the file exists in that path, so really that's a non-issue with a fully qualified physical path.

As to relative path embedding:

If you want relative paths you can add configuration into your root folder or the YAML header of the document that specifies a root path. More info here:

When this is set MM searches up the hierarchy for files and uses that path as the / root folder for creating relative paths.

Otherwise, anything further back than 2 parent paths up from the current path is considered an absolute path.

Ultimately if you're working on a project that has 'root' you should add one of these marker files into the root folder of the project - that's the most reliable way to get clean project relative paths.

from markdownmonster.

jbridgy avatar jbridgy commented on May 24, 2024

If you embed a file that is more than a couple of levels removed from the current one, the link will be embedded as a fixed path. Arguably this should be a file://xxx/ path, but frankly that's not going to work any better unless the file exists in that path, so really that's a non-issue with a fully qualified physical path.

The main issue is that command Insert link (Ctrl+K) of MM does not convert an absolute Windows file path to a relative URL whenever possible and probably most users strongly dislike doing this tedious conversion manually.
In the original post I forgot to point out that the behavior of Insert link depends on how the local file path is entered into the Link: field. There are two cases:

  1. The local file path is entered directly by typing or pasting.
  2. The local file path is entered indirectly by the ... button.

The example in the original post refers to case 1. In this case MM never converts an absolute local path to a relative one. After all it converts the spaces to %20 when you press the Paste Link button.
image

In case 2 the behavior of MM is better. It converts an absolute local path to a relative one if the directory of the current file contains the linked file.
image
image

So reconciling these two cases should actually be the first improvement.

When this is set MM searches up the hierarchy for files and uses that path as the / root folder for creating relative paths.

Otherwise, anything further back than 2 parent paths up from the current path is considered an absolute path.

Why do you restrict the conversion?
I suggest to make a file path relative whenever possible, that is as already mentioned above, relative to the current file if the linked file and the current file formally reside on the same volume. By "formally" I mean, that the linked file is not required to be existent when you create the link.
Maybe Insert link (Ctrl+K) should have an option like use absolute path to suppress the conversion in rare special cases.

Ultimately if you're working on a project that has 'root' you should add one of these marker files into the root folder of the project - that's the most reliable way to get clean project relative paths.

This route is MM-specific. Therefore it is impractical for my environment and presumably for most others.

from markdownmonster.

Related Issues (20)

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.