Fix Unicode encoding failure in directory export when creating filenames from journal titles with certain characters (#1090)

Fix Unicode encoding failure in directory export when creating filenames from journal titles with certain characters
This commit is contained in:
Micah Jerome Ellison 2020-11-21 15:41:08 -08:00 committed by GitHub
parent 046ebc7514
commit b511461cfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View file

@ -536,3 +536,21 @@ Feature: Custom formats
[2013-06-10 15:40] Life is good.
But I'm better.
"""
Scenario Outline: Exporting entries with Cyrillic characters to directory should not fail
Given we use the config "<config>.yaml"
And we use the password "test" if prompted
And we create a cache directory
When we run "jrnl 2020-11-21: Первая"
When we run "jrnl --format md --file {cache_dir} -on 2020-11-21"
Then the cache should contain the files
"""
2020-11-21_первая.md
"""
Examples: configs
| config |
| basic_onefile |
| basic_encrypted |
| basic_folder |
| basic_dayone |

View file

@ -37,8 +37,8 @@ class TextExporter:
@classmethod
def make_filename(cls, entry):
return entry.date.strftime(
"%Y-%m-%d_{}.{}".format(cls._slugify(str(entry.title)), cls.extension)
return entry.date.strftime("%Y-%m-%d") + "_{}.{}".format(
cls._slugify(str(entry.title)), cls.extension
)
@classmethod