Skip to content

Commit

Permalink
Merge branch 'master' into toml-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed May 28, 2017
2 parents 2948013 + 18a4c67 commit 99be63c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------


* Support for YAML and TOML metadata (Issue #2801)

New in v7.8.6
Expand Down
2 changes: 1 addition & 1 deletion docs/manual.txt
Expand Up @@ -302,7 +302,7 @@ YAML metadata should be wrapped by a "---" separator and in that case, the usual
date: 2012-09-15 19:52:05 UTC
---

TOML metadata should be wrapped by a "---" separator and in that case, the usual TOML syntax is used:
TOML metadata should be wrapped by a "+++" separator and in that case, the usual TOML syntax is used:

.. code:: yaml

Expand Down
4 changes: 3 additions & 1 deletion nikola/utils.py
Expand Up @@ -2050,8 +2050,10 @@ def load_data(path):
"""Given path to a file, load data from it."""
ext = os.path.splitext(path)[-1]
loader = None
function = 'load'
if ext in {'.yml', '.yaml'}:
loader = yaml
function = 'safe_load'
if yaml is None:
req_missing(['yaml'], 'use YAML data files')
return {}
Expand All @@ -2065,7 +2067,7 @@ def load_data(path):
if loader is None:
return
with io.open(path, 'r', encoding='utf8') as inf:
return loader.load(inf)
return getattr(loader, function)(inf)


# see http://stackoverflow.com/a/2087433
Expand Down

0 comments on commit 99be63c

Please sign in to comment.