Converting local file links from md to html

al's Avatar

al

20 Mar, 2014 11:49 PM

I am trying to use MMD to maintain and update a set of static web pages, so I can develop them locally and then periodically upload to a work server. Trying to keep this very simple. The idea is to write content in markdown for each constituent page, and develop css file and top-matter separately, and just paste the latter in with a cat command. As well as external URLs, I have lots of cross-links between the pages of course. All the pages start as .md files. So far so cool, as I can preview the whole linked structure using Marked. Then with MMD I batch convert all the .md files to .html, and add the boilerplate. Good so far. Then we have the snag ... inside each html file, the references are to the .md files, not to the .html files !!

Have I missed something ? I looked at the command line options and none of them seemed to be "convert md references to html references". Guess I could do it with sed or something, but this issue might have already been solved...

  1. Support Staff 1 Posted by fletcher on 21 Mar, 2014 12:17 AM

    fletcher's Avatar

    I'm not sure I follow you.

    What is a "md reference"?

    Why not just link to the html version from the beginning?

    F-

  2. 2 Posted by al on 21 Mar, 2014 12:29 AM

    al's Avatar

    By md reference I mean the md file contains a link to a local file eg

    [some text](filename.md)

    This gets converted to
    <a href="filename.md">some text</a>

    whereas filename.md has become filename.html; so I want the html code to say

    <a href="filename.html">some text</a>

    .... oh, and I don't want to refer to the html file in the beginning, because I want to preview the whole suite of md files using Marked..

  3. Support Staff 3 Posted by fletcher on 21 Mar, 2014 01:07 AM

    fletcher's Avatar

    Ok...

    So why not make the link to filename.html from the beginning? I'm not
    sure what the link to filename.md is supposed to mean, if that's not
    where you actually want the link to end up.

    MMD basically assumes you know what you're doing. If you tell it to
    link to X, it links to X. It doesn't change X to Y because it wants to
    guess what you really meant.

    F-

  4. Support Staff 4 Posted by fletcher on 21 Mar, 2014 01:07 AM

    fletcher's Avatar

    I'm not sure I follow you.

    What is a "md reference"?

    Just link to the html in the first place.

    ;)

    F-

  5. 5 Posted by al on 21 Mar, 2014 07:38 AM

    al's Avatar

    Well I guess I will give up but will just explain the intention one more time, just so you don't think I'm completely nuts!

    Step-1. I am developing a set of interlinked documents entirely in md and previewing them in Marked. This works nicely. It requires all the pages being .md files, otherwise you jump to browser when you click on a link rather than staying in Marked. (BTW, this is also how I keep notes, using markdown as a kind of desktop wiki)

    Step-2. When that structure is ready, I want to add top matter and batch-convert all the md files to html files, and the md references to html references. Then I have the same linked-structure working as a set of browser-viewable web pages rather than a set of Marked-viewable md pages.

    Now of course I can link to the html in the first place, and convert the .md files to .html files one by one as I make them, and preview in the browser all the time. But then I lose the ability to preview everything in Marked first, which I like a lot.

    You are right of course that MMD can't guess your intention, but that's what switches are for, so you can tell a command your intention. I can do it by hand with a bit of sed or something I guess, so that's probably what I will do.

  6. Support Staff 6 Posted by fletcher on 21 Mar, 2014 01:32 PM

    fletcher's Avatar

    Gotcha.

    What you're describing is a feature/loophole in Marked, not anything related to MultiMarkdown per se.

    I think the best approach here is a sed script or something similar, as you mentioned.

    Thanks!

    Sent from my iPhone

  7. 7 Posted by DF on 22 Jul, 2014 11:01 PM

    DF's Avatar

    Al, were you able to figure out a general solution or sed script? I have a similar problem and am interested in the results. Thanks!

  8. fletcher closed this discussion on 09 Nov, 2018 04:47 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

11 Dec, 2022 09:57 PM
11 Dec, 2022 07:57 PM
26 Sep, 2022 02:40 AM
21 Jul, 2022 10:22 AM
11 Jan, 2022 02:33 PM

Recent Articles