def str_representer(dumper, data):
    """Use literal block scalar style for multiline strings.

    This function should be used as the `representer` argument of
    the yaml.add_representer() function before dumping the YAML.

    """
    if len(data.splitlines()) > 1:
        return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|'
            )
    return dumper.represent_scalar('tag:yaml.org,2002:str', data)
