From 288c5aeba001bc605d20c573c37d1fb9384262e8 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Mon, 3 Jun 2019 10:36:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20PDF,=20=D0=B5?= =?UTF-8?q?=D1=81=D0=BB=D0=B8=20=D0=B8=D1=81=D1=82=D0=BE=D1=87=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=20=D0=BD=D0=B5=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D1=91=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asciidoctor.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/asciidoctor.py b/asciidoctor.py index 5d3df32..1539206 100644 --- a/asciidoctor.py +++ b/asciidoctor.py @@ -17,6 +17,7 @@ from pelican.readers import BaseReader from pelican.generators import Generator from pelican import signals import os +import os.path import re import subprocess import sys @@ -139,12 +140,13 @@ class AsciiDoctorPdfGenerator(Generator): filename = "{id_file}.pdf".format(id_file=content.slug) filepath = os.path.join(output_dir, filename) - check_call([cmd] + self.settings.get('ASCIIDOCTOR_EXTRA_OPTIONS', []) + - ['--require', 'asciidoctor-pdf', '--backend', 'pdf'] + - ['--doctype=article'] + - ['--out-file', filepath, content.source_path]) - - logger.info("[ok] writing {filepath}".format(filepath=filepath)) + if ((not os.path.isfile(filepath)) or + (os.path.getmtime(filepath) < os.path.getmtime(content.source_path))): + check_call([cmd] + self.settings.get('ASCIIDOCTOR_EXTRA_OPTIONS', []) + + ['--require', 'asciidoctor-pdf', '--backend', 'pdf'] + + ['--doctype=article'] + + ['--out-file', filepath, content.source_path]) + logger.info("[ok] writing {filepath}".format(filepath=filepath)) def generate_output(self, writer=None): """Generate files for each articles and pages.