@cell_magic
@magic_arguments.magic_arguments()
@magic_arguments.argument('var_name', default=None, nargs='?', help='Name of local variable to set to parsed value')
@magic_arguments.argument('-l', '--loader', default='yaml.SafeLoader', help='Dotted-notation class to use for loading')
def yaml(self, line, cell):
    line = line.strip()
    args = magic_arguments.parse_argstring(self.yaml, line)
    display(Javascript('\n            require(\n                [\n                    "notebook/js/codecell",\n                    "codemirror/mode/yaml/yaml"\n                ],\n                function(cc){\n                    cc.CodeCell.options_default.highlight_modes.magic_yaml = {\n                        reg: ["^%%yaml"]\n                    }\n                }\n            );\n            '))
    loader = get_ipython().user_global_ns.get(args.loader, None)
    if (loader is None):
        loader = import_item(args.loader)
    try:
        val = yaml.load(cell, Loader=loader)
    except yaml.YAMLError as err:
        print(err)
        return
    if (args.var_name is not None):
        get_ipython().user_ns[args.var_name] = val
    else:
        return val
@cell_magic
@magic_arguments.magic_arguments()
@magic_arguments.argument('var_name', default=None, nargs='?', help='Name of local variable to set to parsed value')
@magic_arguments.argument('-l', '--loader', default='yaml.SafeLoader', help='Dotted-notation class to use for loading')
def yaml(self, line, cell):
    line = line.strip()
    args = magic_arguments.parse_argstring(self.yaml, line)
    display(Javascript('\n            require(\n                [\n                    "notebook/js/codecell",\n                    "codemirror/mode/yaml/yaml"\n                ],\n                function(cc){\n                    cc.CodeCell.options_default.highlight_modes.magic_yaml = {\n                        reg: ["^%%yaml"]\n                    }\n                }\n            );\n            '))
    loader = get_ipython().user_global_ns.get(args.loader, None)
    if (loader is None):
        loader = import_item(args.loader)
    try:
        val = yaml.load(cell, Loader=loader)
    except yaml.YAMLError as err:
        print(err)
        return
    if (args.var_name is not None):
        get_ipython().user_ns[args.var_name] = val
    else:
        return val