How to get metadata (e.g. keyword) in output

Is there a way to get some of the metadata attached to each document (e.g. keyword) included in the compiled output (e.g. html, as class="…"; or in MMD)?

Thanks … Sophie

Not a bad idea for MMD, though that is a decision that should probably be left up to the user, as some might prefer labels -> class, or whatever. You can get meta-data out in all export types, but it will be included as part of the text, not as any form of styling or semantic inclusion. To do so, just check the appropriate boxes in the Document Elements section on the first page of the Compiler preferences.

The non-MMD HTML exporter simply converts the look of the document to XHTML + inline CSS. It isn’t very aware of things like header levels, classes, and so forth.

Does that mean there is a way to get it into MMD? Into MMD-XHTML? Any specific “do-this” much appreciated.

Thanks !
Sophie

All metadata is included in the MMD output. Simply view the XHTML source to see it.

Some metadata is used by default (e.g. Title, XHTML Header, CSS fields, etc). The rest is stored as meta. The most common metadata is also used when the XHTML files is converted to LaTeX as well.

You can create your own XSLT files to do whatever you like with any of the “default” or custom metadata fields that you like.

F-

I put a single keyword into a Scrivener document and compiled-draft.

I found the keyword in the XHTML, but it appeared as straight content “keyword22” below, with additional styling around it, not distinguishable as meta-data.

[code]

Section 2

Keywords
keyword22

[/code]

Is this intented? Why not make it more distinct from content, and why not retain some more semantic structure (specially if this XHTML is the starting point for further transforms) e.g.

<div Keywords="keyword22">
  <h2 id="s2">Section 2</h2>
</div>

New XSLT could probably do it, I am just interested in your thinking on the “baseline” XSLT/XHTML.

Thanks!

If this is the output you got, then you didn’t properly enter the metadata. Metadata will not appear before any tags.

Hmm, I’m not sure we are talking about the same “metadata”. I’m a bit new to scrivener, so I may not be using the right words. Here is what I did:

- start new project
- add a child text node "s1" to the initial default one (in the binder)
- add a grandchild text node "s2", so the binder looks like this:
    - A 
       - s1
           - s2   (with content: "Section 2")

Then I add a keyword “keyword2” to s2, and do a compile-draft. I consider “keyword2” to be metadata about s2.

So where should the “keyword2” appear in the XHTML?

Thanks — Sophie

If you want to include metadata in a MMD export, see:

http://fletcherpenney.net/multimarkdown/users_guide/multimarkdown_syntax_guide/#metadata

Metadata is per document, not per section, however. So you can only include metadata in MultiMarkdown Settings within Scrivener.

To my knowledge, Scrivener doesn’t have a concept of metadata itself, so can’t include that in it’s own export formats.

Ah, I think I understand the gap here. Thanks for the reply.

Scrivener very much understands meta-data (I searched in its help menu for “meta-data”) at all levels of the document. In Scrivener a “document” is any node that appears in the binder view, so it includes any section or sub-section. And you can attach many forms of meta-data to any level of “document” e.g. synopsis, label, status, keywords, notes, references, … This is one of Scriveners quite powerful features.

Why would MMD exclude meta-data on sub-parts of a “document”? This meta-data is defined clearly within scrivener and is an important part of scrivener capabilities, and could be embedded in many ways in the xhtml. e.g. a fairly general one could use a list of property-values distinguished as “metadata” and encoded in a xhtml definition-list.

<div class="scriv_subdocument"> 
  <!-- corresponds to a (sub)section, or a (sub)document in Scrivener -->
  <dl class="metadata">
     <dt>Title</dt>        <dd>Sub-Section A</dd>
     <dt>Keywords</dt>     <dd>K1</dd>
     <dt>Keywords</dt>     <dd>K2</dd>
     <dt>Status</dt>       <dd>Incomplete</dd>
  </dl>
  ... normal content goes here ...
</div>

A default .css could choose to not display the entire

. Different .css and XSLT could do quite different things with it, like embed keywords into “class=…” annotations.

I’m not sure how such meta-data would be embedded into markdown syntax itself, but perhaps something like the key: value convention at the top of a markdown document could be used elsewhere as well.

Thoughts?

But this metadata is distinct from the content of the document itself. In other words, there is no way (to my understanding) to flag a part of the body of the RTF document as “metadata”.

MMD is a completely separate program than Scrivener. It was designed independently (and I believe before Scrivener existed), and Keith and I collaborated to add the ability to export the text of a Scrivener document and process it with MMD. So it’s not “exclud[ing]” anything. There simply is no corollary in MMD for the built-in metadata that Scrivener uses. If you want to use a definition-list, then simply put your metadata in a MMD definition list, and modify your CSS to hide definition lists that immediately follow a header.

“True” MMD metadata is encoded at the top of the document (no leading whitespace), and once there is a whitespace only line, the metadata ends. This will not change in the foreseeable future. But there are other ways of indicating “metadata” within the confines of the current MMD syntax as mentioned above. As another example, I use special formatting to indicate the author of each poem in a poetry collection, and used a custom XSLT to extract that text and indicate in LaTeX that it represented the author.

I don’t see this happening in the official MMD release, but it’s open source and of course anyone is free to modify it. My sense, however, is that this would over complicate the syntax - the beauty of Markdown is it’s simplicity and “human-readability.” As the syntax for MMD gets more complicated, it strays further from that ideal. In most of the cases where users have requested new syntax, it seems to me that the same result can be achieved using the current syntax and custom XSLT to interpret that syntax in desired ways.

F-

Not sure why it needs to be part of the body of the RTF (but then I don’t know the mechanics of how it works). Scrivener as a tool makes it’s own meta-data very easy to manipulate (search, etc.). The importer/exporter converts #…# ↔ binder structure; it could do the same for MMD meta-data markup ↔ scrivener meta-data, if MMD could allow that meta-data markup at all levels without destroying its readability and simplicity.

##My Nth Header##
Metadata:  list of key: value pairs

My normal content here.

Thanks for explaining, I now understand better how these came to be and how they work together. I think this could improve the Scrivener-MMD combo.

Thanks - Sophie