您可以将文本文件中的信息导入/引用到Markdown文件中吗? [英] Can you import/reference info from text files into a Markdown file?

查看:303
本文介绍了您可以将文本文件中的信息导入/引用到Markdown文件中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到一个示例,但是可以通过引用将文本导入Markdown文件吗?例如,说我有我的README.md. Markdown是否可以像图像参考一样从somefile.txt导入自述文件?

I haven't been able to find an example for this, but is it possible to import text by reference into a Markdown file? For example, say I have my README.md. Can Markdown import from somefile.txt into the README, like with image references?

推荐答案

简单的答案:不,Markdown不支持.

Easy answer: No, Markdown does not support this.

稍微复杂一点的答案:如果您不介意手动串联文件或编写简单的构建脚本,则可以轻松地对其进行伪造.考虑下面的简单示例:

Slightly more complicated answer: If you don't mind manually concatenating files or writing a simple build script, you can easily fake it. Consider the following simple example:

  • parts/是用于存放部分文件的目录.
    • 01-introduction.md包含您的Markdown简介,标题等.
    • 02-somefile.txt包含要在01-introduction.md之后立即包含的信息.
    • 03-conclusion.md包含您的Markdown结论,结尾,版权信息以及您可能想要的其他任何内容.
    • parts/ is a directory to hold your partial files.
      • 01-introduction.md contains your Markdown introduction, header, etc.
      • 02-somefile.txt contains the information that you want to include immediately after 01-introduction.md.
      • 03-conclusion.md contains your Markdown conclusion, outro, copyright information, and whatever else you may want.

      现在,您可以将这些文件串联到Markdown主文件中.如果您使用的是Unixy系统,则cat parts/* > final.md之类的东西将起作用.在Windows上,我相信等效为type parts\* > final.md.

      Now you can concatenate these files into your main Markdown file. If you're on a Unixy system, something like cat parts/* > final.md will work. On Windows, I believe the equivalent would be type parts\* > final.md.

      如果您计划定期更新内容,则编写名为build.shbuild.bat的shell脚本将使此过程的痛苦减轻.

      Writing a shell script called build.sh or build.bat will make this process less painful if you plan on updating your content regularly.

      请注意,您可能需要玩 Pandoc ,而不是简单地串联文件,多个输入文件并输出Markdown(以及其他几种格式).如果您的目标格式不是Markdown,而是HTML,PDF或其他内容,这将特别有趣.

      Note that, instead of simply concatenating your files, you may want to play with Pandoc, which can take multiple input files and output Markdown (and several other formats). This will be particularly interesting if your target format isn't actually Markdown, but rather HTML, PDF, or something else.

      这篇关于您可以将文本文件中的信息导入/引用到Markdown文件中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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