From 91d2e940b0ff32cd2dbda7a3c0e2c67c403cb9a8 Mon Sep 17 00:00:00 2001 From: TiynGER Date: Tue, 20 Oct 2020 23:40:52 +0200 Subject: [PATCH] Docker: use utf-8 encoding for working docker-image --- README.md | 3 ++- src/content.py | 8 ++++---- src/search.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ae5e7fa..d02b705 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ I however just want to put my markdown files in a directory and get a working wi - [ ] Option to get plain text file - [ ] Optimize CSS for code - [x] Start page + - [ ] Overview of pages and namespaces - [x] Search page - [x] Full-text search - [x] Show first few lines of each match (preview) @@ -27,7 +28,7 @@ I however just want to put my markdown files in a directory and get a working wi - [x] CSS dark-theme - [x] CSS light-theme - [x] Config file -- [ ] Docker installation +- [x] Docker installation - [ ] Enable variables/environment variables - [ ] Logo diff --git a/src/content.py b/src/content.py index 859af97..5fbd163 100644 --- a/src/content.py +++ b/src/content.py @@ -17,8 +17,8 @@ def gen_stand_string(path_ex): filename = os.path.join(ENTRY_DIR, path_ex) result = '' if path.exists(filename): - title = open(filename).readline().rstrip('\n') - text = open(filename).readlines()[1:] + title = open(filename,encoding='utf-8').readline().rstrip('\n') + text = open(filename,encoding='utf-8').readlines()[1:] filename_no_end = filename.split('.', 1)[0] result += '

' + title + '

\n' if filename.endswith('.md'): @@ -35,7 +35,7 @@ def gen_md_content(path_ex, depth): for i in range(depth): header += '#' header += ' ' - markdown_lines = open(path_ex, 'r').readlines()[1:] + markdown_lines = open(path_ex, 'r',encoding='utf-8').readlines()[1:] markdown_text = '' for line in markdown_lines: markdown_text += line.replace('# ', header) @@ -61,7 +61,7 @@ def gen_query_res_string(query_str): def create_preview(path): - file = open(path, 'r') + file = open(path, 'r',encoding='utf-8') first_lines = file.readlines() preview = '' preview_length = 3 diff --git a/src/search.py b/src/search.py index d67c7c5..56ab814 100644 --- a/src/search.py +++ b/src/search.py @@ -28,7 +28,7 @@ def createSearchableData(root): for r, d, f in os.walk(root): for file in f: path = os.path.join(r, file) - fp = open(path) + fp = open(path,encoding='utf-8') title = fp.readline() text = title + fp.read() writer.add_document(title=title, path=path, content=text)