Closed cdlscpmv closed 10 years ago
Since MMD is a command-line utility, you can do whatever you like to the input before passing it in. You can prepend/append anything via cat/echo or your own scripts. You can keep all of the metadata in a separate file and prepend it at runtime. The possibilities are limitless.
And the best part is you don't have to wait for me to do anything!
Thanks, man! I don't know why I didn't figure it out by myself.
Additionally you can already use the transclusion feature to populate your metadata (even nested). You have to be a bit careful with linebreaks and empty lines in the transcluded files but it works.
That can be tricky -- if you enter metadata in a file, it will not be included when transcluding. The reason for this is that normally when transcluding a file, you don't want the metadata.
You can include plain text that would be transcluded into the metadata as a variable. For example, I use a single file for a document version number for the MMD User's guide, and this is transcluded into the metadata in all the individiual files so that I don't have to repeat myself.
The User's Guide source is a great place to see examples of the tricks I use for MMD.
Yes, I forgot to mention that it can be tricky, sorry. @cdlscpmv, one way to achieve metada transclusion is in the following example:
The document:
prepend: {{meta.prepend.transclude}}
meta1: data1
meta2: data2
meta3: data3
append: {{meta.append.transclude}}
Content
Content...
The content of meta.prepend.transclude:
meta-prepend1: prepend1
meta-prepend2: prepend2
The content of meta.append.transclude:
meta-append1: append1
meta-append2: append2
The result:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="prepend" content=""/>
<meta name="meta-prepend1" content="prepend1"/>
<meta name="meta-prepend2" content="prepend2"/>
<meta name="meta1" content="data1"/>
<meta name="meta2" content="data2"/>
<meta name="meta3" content="data3"/>
<meta name="append" content=""/>
<meta name="meta-append1" content="append1"/>
<meta name="meta-append2" content="append2"/>
</head>
<body>
<p>Content
Content…</p>
</body>
</html>
Please note the empty line at the beginning of both meta.prepend.transclude
and meta.append.transclude
.
Thank you, guys, for advices! File transclusion is a good idea but it is not really what I wanted. I wanted to separate unnecessary metadata information from source text file.
I don't need all the details about how a file wiil be converted into another format inside of my markdown file. Having author, title, date is enough in case of writing an article.
So I came up with a somewhat ugly method of achieving this by using a temporary file and a combination of echo's. Here is a sample script.
Nice job!
Hi!
Thanks for multimarkdown! I enjoy using it, but there is an issue, which I would like to be resolved.
Would it be possilbe to implement two command line options like "--prepend-metadata" and "--append-metadata" which would accept an argumens of the form "key:value"?
This would allow to prepend/append some metadata to the existing metadata in the document, without modifying content of the document.
For example, when converting to LaTeX, it's often required to incude "latex input" multiple times. This clutters the appearance of the source markdown file.
I think many people can make use of this feature, since it would make converting more convenient and source file cleaner.