~sirodoht/mataroa

61d451403db16790947b49d5788299583e44d14e — Theodore Keloglou 6 months ago 15d234c
fix hugo and zola double quote escape
2 files changed, 11 insertions(+), 2 deletions(-)

M main/util.py
M main/views_export.py
M main/util.py => main/util.py +5 -0
@@ 204,3 204,8 @@ def generate_markdown_export(user_id):
            )

    return (export_name, zip_outfile)


def escape_quotes(input_string):
    output_string = input_string.replace('"', '\\"')
    return output_string

M main/views_export.py => main/views_export.py +6 -2
@@ 97,7 97,9 @@ def export_zola(request):
        for p in posts:
            pub_date = p.published_at or p.created_at.date()
            title = p.slug + ".md"
            body = prepend_zola_frontmatter(p.body, p.title, pub_date)
            body = prepend_zola_frontmatter(
                p.body, util.escape_quotes(p.title), pub_date
            )
            export_posts.append((title, io.BytesIO(body.encode())))

        # create zip archive in memory


@@ 155,7 157,9 @@ def export_hugo(request):
        for p in posts:
            title = p.slug + ".md"
            pub_date = p.published_at or p.created_at.date()
            body = prepend_hugo_frontmatter(p.body, p.title, pub_date)
            body = prepend_hugo_frontmatter(
                p.body, util.escape_quotes(p.title), pub_date
            )
            export_posts.append((title, io.BytesIO(body.encode())))

        # create zip archive in memory