diff -urN v4/ezhtml.py v5/ezhtml.py --- v4/ezhtml.py 2018-09-17 23:46:44.000000000 +0900 +++ v5/ezhtml.py 2018-09-18 00:31:27.000000000 +0900 @@ -130,6 +130,18 @@ o = o[0] return o +def yaml_dump(o): + def represent_str(dumper, instance): + tag = 'tag:yaml.org,2002:str' + style = '|' if '\n' in instance else None + return dumper.represent_scalar( tag, instance, style=style ) + + for typ in [ str ] + ( [ unicode ] if six.PY2 else [] ): + yaml.add_representer(typ, represent_str) + + u8 = yaml.dump( o, default_flow_style=False, allow_unicode=True, encoding='utf-8' ) + return nkf.dec(u8) + if __name__ == "__main__": b = nkf.get_stdin() opt = nkf.guess(b) @@ -139,7 +151,7 @@ if html: o = html_load(s) - s = yaml.dump( o, default_flow_style=False ) + s = yaml_dump(o) else: o = yaml.load(s) s = html_dump(o) + '\n'