有没有办法为其他`.md`文件编译的GitHub创建一个`README.md`文件? [英] Is there a way to create a `README.md` file for GitHub that compiles from other `.md` files?

查看:137
本文介绍了有没有办法为其他`.md`文件编译的GitHub创建一个`README.md`文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为其他的 .md 文件编译的GitHub创建一个 README.md 文件?例如,假设我有三个文件: repo / 1.md repo / 2.md 回购/ 3.md 。我想按照这个顺序合并文件来创建 repo / README.md

SO问题提供了一些帮助,但已经超过2年了,我在想(希望)现在可能会有新的想法。一个答案建议使用Pandoc将 .md 文件编译为输出到 html

  pandoc * .md> markdown_book.html 

我试着用我的档案。我的 .md 文件格式如下:

 #Page 1 
测试

一旦进入 repo / ,我跑了:

  pandoc * .md> README.html 

其中创建了:

 < h1 id =page-1>第1页< / h1> 
< p> testing#Page 2 testing#Page 3 testing< / p>

这看起来不正确,但是我继续运行以下操作以返回 .md file:

  pandoc -o README.md README.html 

其中:

  Page 1 
======

testing \#Page 2测试

我预计:

 #Page 1 
测试

#Page 2
测试

#Page 3
测试

结束语:


  1. Pandoc是工作的最佳工具,还是有一种更简单的方法来将 .md 文件组合在一起? 标记应用的语法包括外部文件 << [path / file] ,但我认为没有选项可将编译的文档导出为 .md

  2. 如果不是,那么用Pandoc做这件事的正确方法是什么?我想结合减价文件,而不必先转到另一种格式。

  3. >

    Pandoc 1.11.1适用于Ubuntu,直接从Markdown转到Markdown,但它将标题转换为下划线标题:

      pandoc -o README.md 1.md 2.md 3.md 

    确保您的文件在每个源文件中都包含最后的换行符;省略这是我能够重现错误的唯一方法。


    Is there a way to create a README.md file for GitHub that compiles from other .md files? For instance, let's say I have three files: repo/1.md, repo/2.md, and repo/3.md. I want to combine the files in this order to create repo/README.md.

    This SO question gives some help, but it's more than 2 years old and I'm thinking (hoping) there might be new ideas out there now. One answer suggests using Pandoc to compile .md files into outputting to html:

    pandoc *.md > markdown_book.html
    

    I tried this with my files. My .md files take the form:

    # Page 1
    testing
    

    Once in repo/, I ran:

    pandoc *.md > README.html
    

    which created:

    <h1 id="page-1">Page 1</h1>
    <p>testing # Page 2 testing # Page 3 testing</p>
    

    This is not looking right, but I went ahead and ran the following to get back to a .md file:

    pandoc -o README.md README.html
    

    which produced:

    Page 1
    ======
    
    testing \# Page 2 testing \# Page 3 testing
    

    I expected:

    # Page 1
    testing
    
    # Page 2 
    testing
    
    # Page 3
    testing
    

    So to wrap up:

    1. Is Pandoc the best tool for the job, or is there an easier approach to combining .md files together? The Marked app has syntax for including external files, <<[path/file], but I don't think there is an option to "export" the compiled document to .md.

    2. If not, what is the right way to do this with Pandoc? I'd like to combine markdown files without having to go to another format first.

    解决方案

    Pandoc 1.11.1 works for me on Ubuntu, going straight from Markdown to Markdown, although it converts # headings into underlined headings:

    pandoc -o README.md 1.md 2.md 3.md
    

    Make sure your files include a final newline in each of your source files; omitting this is the only way that I was able to reproduce your error.

    这篇关于有没有办法为其他`.md`文件编译的GitHub创建一个`README.md`文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆