降价并包含多个文件 [英] Markdown and including multiple files

查看:84
本文介绍了降价并包含多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何markdown分支可以让您引用其他文件(例如包含文件)?具体来说,我想创建一个单独的markdown文件,该文件包含我经常调用但并不总是调用的链接(称为B.md),然后在我正在编写的md文件中通过引用链接(A.md)时,像这样从其他文件(B.md)而不是从当前文件(A.md)的末尾拉出链接.

Is there any markdown fork that allows you to reference other files, something like an includes file? Specifically, I want to create a separate markdown file with links that I call often but not always (call this B.md), then when I link by reference in the md file I'm writing (A.md), I'd like it to pull the link from the other file (B.md) rather than from the end of the current file (A.md).

推荐答案

简短的回答是否".长答案是肯定的. :-)

The short answer is no. The long answer is yes. :-)

Markdown旨在允许人们编写简单易读的文本,这些文本可以轻松转换为简单的HTML标记.它实际上并没有进行文档布局.例如,没有真正的方法可以将图像左右对齐.关于您的问题,没有markdown命令可以在任何版本的markdown中包含从一个文件到另一个文件的单个链接(据我所知).

Markdown was designed to allow people to write simple, readable text that could be easily converted to a simple HTML markup. It doesn't really do document layout. For example, there's no real way to align an image to the right or left. As to your question, there's no markdown command to include a single link from one file to another in any version of markdown (so far as I know).

最接近此功能的是 Pandoc . Pandoc允许您在转换过程中合并文件,从而可以轻松地将多个文件呈现为单个输出.例如,如果您正在创建一本书,那么您可能会有类似的章节:

The closest you could come to this functionality is Pandoc. Pandoc allows you to merge files as a part of the transformation, which allows you to easily render multiple files into a single output. For example, if you were creating a book, then you could have chapters like this:

01_preface.md
02_introduction.md
03_why_markdown_is_useful.md
04_limitations_of_markdown.md
05_conclusions.md

您可以通过在同一目录中执行以下命令来合并它们:

You can merge them by doing executing this command within the same directory:

pandoc *.md > markdown_book.html

由于pandoc会在翻译之前合并所有文件,因此您可以将链接包含在最后一个文件中,如下所示:

Since pandoc will merge all the files prior to doing the translation, you can include your links in the last file like this:

01_preface.md
02_introduction.md
03_why_markdown_is_useful.md
04_limitations_of_markdown.md
05_conclusions.md
06_links.md

所以您的01_preface.md的一部分可能看起来像这样:

So part of your 01_preface.md could look like this:

I always wanted to write a book with [markdown][mkdnlink].

02_introduction.md的一部分可能看起来像这样:

And part of your 02_introduction.md could look like this:

Let's start digging into [the best text-based syntax][mkdnlink] available.

只要您的最后一个文件包含以下行:

As long as your last file includes the line:

[mkdnlink]: http://daringfireball.net/projects/markdown

...之前使用的同一命令将执行合并和转换,同时始终包含该链接.只需确保在该文件的开头保留一两行空白即可. pandoc文档说,它在以这种方式合并的文件之间添加了空白行,但这并没有没有空白行对我不起作用.

...the same command used before will perform the merge and conversion while including that link throughout. Just make sure you leave a blank line or two at the beginning of that file. The pandoc documentation says that it adds a blank line between files that are merged this way, but this didn't work for me without the blank line.

这篇关于降价并包含多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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