yamldown


Nameyamldown JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://github.com/dougli1sqrd/yamldown
SummaryPython library for loading and dumping "yamldown" (markdown with embedded yaml) files.
upload_time2019-03-25 16:46:27
maintainer
docs_urlNone
authoredouglass
requires_python
license
keywords yaml markdown
VCS
bugtrack_url
requirements mypy nose2 pyyaml
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Yamldown

This library allows users to load and read "YAMLdown" files. That is,
Markdown (primarily for github) with YAML embedded inside. Github markdown
already renders YAML style text in markdown as a table. This library parses
a yamldown file into its respective YAML and markdown.

## Installation

`pip install yamldown`

For local installation and development, you can run the make file:

    sauron@orthanc:[~]$ cd yamldown
    sauron@orthanc:[yamldown]$ make

This will create a virtual environemnt `env`, install everything in
`requirements.txt` and in `setup.py`, run tests, and run mypy, python 3's type
checker. Be sure to activate the virtual environment when local developing:

    source env/bin/activate

or

    . env/bin/activate

To undo your activated virtual environment, just run the command `deactivate`

## Usage

Importing the yamldown module will let you `load` and `dump` yamldown files.
`load` receives a file-like object (backed by text in yamldown format) and
returns a tuple, first a dictionary with the containing YAML, and second a
string with the contents of the Markdown. In this way the yaml can be utilized.

Example:

    $ python3
    >>> import io
    >>> import yamldown
    >>> s = """
    ...---
    ... things:
    ...   - hello
    ...   - world
    ... foo: bar
    ... ---
    ... This is some markdown text"""
    >>> f = io.StringIO(s)
    >>> yml, md = yamldown.load(f)
    >>> print(yml)
    {'things': ['hello', 'world'], 'foo': 'bar'}
    >>>print(md)
    This is some markdown text

To write out a yamldown file, `dump` takes a dictionary with your yaml data
and a string of markdown and outputs a string. The order in which the yaml
appears in the document can be specified with the `yamlfirst` option: `True`
for if the yaml should appear first (like in the above example) and `False` to
appear last.

Example:

    $ python3
    >>> import yamldown
    >>> yml = {'things': ['hello', 'world'], 'foo': 'bar'}
    >>> md = "This is some markdown text"
    >>> print(yamldown.dump(yml, md))
    ---
    foo: bar
    things:
    - hello
    - world

    ---
    This is some markdown text



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dougli1sqrd/yamldown",
    "name": "yamldown",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "yaml,markdown",
    "author": "edouglass",
    "author_email": "edouglass@lbl.gov",
    "download_url": "https://files.pythonhosted.org/packages/ed/cb/b64a53c4ca6bd0e0aba74523b434213a5c6a3f583631dc4a97abfe7cc7a1/yamldown-0.1.8.tar.gz",
    "platform": "",
    "description": "# Yamldown\n\nThis library allows users to load and read \"YAMLdown\" files. That is,\nMarkdown (primarily for github) with YAML embedded inside. Github markdown\nalready renders YAML style text in markdown as a table. This library parses\na yamldown file into its respective YAML and markdown.\n\n## Installation\n\n`pip install yamldown`\n\nFor local installation and development, you can run the make file:\n\n    sauron@orthanc:[~]$ cd yamldown\n    sauron@orthanc:[yamldown]$ make\n\nThis will create a virtual environemnt `env`, install everything in\n`requirements.txt` and in `setup.py`, run tests, and run mypy, python 3's type\nchecker. Be sure to activate the virtual environment when local developing:\n\n    source env/bin/activate\n\nor\n\n    . env/bin/activate\n\nTo undo your activated virtual environment, just run the command `deactivate`\n\n## Usage\n\nImporting the yamldown module will let you `load` and `dump` yamldown files.\n`load` receives a file-like object (backed by text in yamldown format) and\nreturns a tuple, first a dictionary with the containing YAML, and second a\nstring with the contents of the Markdown. In this way the yaml can be utilized.\n\nExample:\n\n    $ python3\n    >>> import io\n    >>> import yamldown\n    >>> s = \"\"\"\n    ...---\n    ... things:\n    ...   - hello\n    ...   - world\n    ... foo: bar\n    ... ---\n    ... This is some markdown text\"\"\"\n    >>> f = io.StringIO(s)\n    >>> yml, md = yamldown.load(f)\n    >>> print(yml)\n    {'things': ['hello', 'world'], 'foo': 'bar'}\n    >>>print(md)\n    This is some markdown text\n\nTo write out a yamldown file, `dump` takes a dictionary with your yaml data\nand a string of markdown and outputs a string. The order in which the yaml\nappears in the document can be specified with the `yamlfirst` option: `True`\nfor if the yaml should appear first (like in the above example) and `False` to\nappear last.\n\nExample:\n\n    $ python3\n    >>> import yamldown\n    >>> yml = {'things': ['hello', 'world'], 'foo': 'bar'}\n    >>> md = \"This is some markdown text\"\n    >>> print(yamldown.dump(yml, md))\n    ---\n    foo: bar\n    things:\n    - hello\n    - world\n\n    ---\n    This is some markdown text\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python library for loading and dumping \"yamldown\" (markdown with embedded yaml) files.",
    "version": "0.1.8",
    "split_keywords": [
        "yaml",
        "markdown"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "51c4e95392609f1edab9caf7badf8eed",
                "sha256": "6e9723d479739efa9423834fad005b31220b097ad42606dd0c8159e10677f27a"
            },
            "downloads": -1,
            "filename": "yamldown-0.1.8-py3.7.egg",
            "has_sig": false,
            "md5_digest": "51c4e95392609f1edab9caf7badf8eed",
            "packagetype": "bdist_egg",
            "python_version": "3.7",
            "requires_python": null,
            "size": 3053,
            "upload_time": "2019-03-25T16:46:26",
            "upload_time_iso_8601": "2019-03-25T16:46:26.615247Z",
            "url": "https://files.pythonhosted.org/packages/07/45/78cc7385153a9332d88b76a8cd7a72143974dce66acb2ef9957c0149155d/yamldown-0.1.8-py3.7.egg",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "db0f9fc6a788876dfc8288d9ba8334ef",
                "sha256": "936ad7bdbde725d0bd3adb77236aae4eb75388619f31232595f7dd45f7006598"
            },
            "downloads": -1,
            "filename": "yamldown-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db0f9fc6a788876dfc8288d9ba8334ef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4097,
            "upload_time": "2019-03-25T16:46:25",
            "upload_time_iso_8601": "2019-03-25T16:46:25.223861Z",
            "url": "https://files.pythonhosted.org/packages/5a/40/b8aa35f5ef831a1d47668cc63c6a29611b5b91a9076fddb3fa5368582a67/yamldown-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "bc60c60166ff21b130e4a2b5cc55dfe3",
                "sha256": "ec1056e5ec3c47a7c14f69d343b73256ad12751361f1a833805a8ee722cf883c"
            },
            "downloads": -1,
            "filename": "yamldown-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "bc60c60166ff21b130e4a2b5cc55dfe3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3432,
            "upload_time": "2019-03-25T16:46:27",
            "upload_time_iso_8601": "2019-03-25T16:46:27.510032Z",
            "url": "https://files.pythonhosted.org/packages/ed/cb/b64a53c4ca6bd0e0aba74523b434213a5c6a3f583631dc4a97abfe7cc7a1/yamldown-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-03-25 16:46:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dougli1sqrd",
    "github_project": "yamldown",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "mypy",
            "specs": []
        },
        {
            "name": "nose2",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": []
        }
    ],
    "lcname": "yamldown"
}
        
Elapsed time: 0.02330s