Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Added ability to refernce metadata fields from within the markdown file. #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ Metadata can also be provided on the command-line with the `-d|--define` option.

restdown --define mediaroot=/ index.restdown

## Using Metadata Fields

You can also access the values of the metadata fields you set in your markdown as follows:

---
author: John Doe
created: 3rd September 2013
---

The author of this document is #{author}. It was created on #{created}.



# JSON API Summary

Expand Down
3 changes: 3 additions & 0 deletions bin/restdown
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def restdown(metadata, markdown, brand_dir=None, doc_dir=None):
@returns {str, dict} The HTML document (full page) and a dict giving
data about the API: version, endpoints.
"""
for key in metadata:
markdown = re.sub(r"#{" + key + "}", metadata.get(key), markdown)

doc_markdown_opts = copy.deepcopy(markdown_opts)
for extra in metadata.get("markdown2extras", []):
doc_markdown_opts["extras"][extra] = True
Expand Down