convert lots of md files to html with one command?

tomjohnson1492's Avatar

tomjohnson1492

17 Nov, 2014 07:28 AM

Suppose I have 30 markdown files in a folder. I want to run a command to bulk convert them to HTML. In Pandoc, I could use something like find . -name \*.md -type f -exec pandoc -s -o {}.html {} \;. What can I use with Multimarkdown to accomplish a similar thing? I want to avoid converting each file individually.

Also, how do I specify that I need head matter included?

  1. Support Staff 1 Posted by fletcher on 17 Nov, 2014 07:14 PM

    fletcher's Avatar

    If you read the MultiMarkdown User's guide:

    http://fletcher.github.io/MultiMarkdown-4/using_mmd
    

    or look at the command line help:

     multimarkdown -h
    

    you will see how to use MultiMarkdown. In particular, you can read about the batch mode that lets you handle multiple files.

    I'm not sure what you mean by needing "head matter included."

    Fletcher

  2. 2 Posted by tomjohnson1492 on 17 Nov, 2014 07:21 PM

    tomjohnson1492's Avatar

    Thanks for your response. The MMD user guide says that batch conversion is
    done with this:

    multimarkdown -b file1.txt file2.txt file3.txt

    However, I don't want to specify all the files that I want included in the
    batch conversion. I have approximately 30 or more files here. I want to
    enter something like this:

    multimarkdown -b

    Then ideally multimarkdown would look through all the files contained in
    the folder and convert them from markdown to html. However, when I run this
    command, Terminal just hangs.

    Am I required to specify each file that I want included in batch processing?

    Thanks for your help,

    Tom

    ---------------------
    801-822-2241
    blog: idratherbewriting.com
    twitter: tomjohnson

  3. Support Staff 3 Posted by fletcher on 17 Nov, 2014 07:26 PM

    fletcher's Avatar

    I recommend that you find some good resources on using the command line.
      It's very powerful and worth learning about if you want to improve
    your efficiency with most things you can do on a computer:

    multimarkdown -b *.txt

    Your idea of:

    multimarkdown -b

    is an incomplete command, since you didn't specify any filenames.

    Fletcher

  4. 4 Posted by tomjohnson1492 on 17 Nov, 2014 07:41 PM

    tomjohnson1492's Avatar

    Thank you. That works. (Also, yes, I need to increase my knowledge of
    command line syntax....)

    One more question, if you don't mind. I need the HTML file to include
    header information, such as <html><body>. Is there any argument to add
    there that would get this header info included in the html output?

    Tom

    ---------------------
    801-822-2241
    blog: idratherbewriting.com
    twitter: tomjohnson

  5. Support Staff 5 Posted by fletcher on 17 Nov, 2014 08:06 PM

    fletcher's Avatar

    Again -- if you look in the User's Guide, or in the help on the command
    line, there is an option to force a full HTML document including <head>,
    etc.

    The User's guide is by no means perfect, but it really does have a lot
    of useful information in it that may prove helpful to you.

    F-

  6. 6 Posted by tomjohnson1492 on 17 Nov, 2014 09:01 PM

    tomjohnson1492's Avatar

    Great! Thank you. I had looked in the help before but didn't realize that
    the full or force a complete document was the option I needed. (It makes
    sense though.)

    Here's the full working command:

    multimarkdown -f -b *.md

    Thanks for developing such a great tool. This is going to revolutionize my
    DITA workflow (hopefully).

    Tom

    ---------------------
    801-822-2241
    blog: idratherbewriting.com
    twitter: tomjohnson

  7. Support Staff 7 Posted by fletcher on 17 Nov, 2014 09:14 PM

    fletcher's Avatar

    Glad it's working!

    F-

  8. fletcher closed this discussion on 17 Nov, 2014 09:14 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