mirror of
https://gitlab.com/openlp/documentation.git
synced 2024-12-22 12:32:48 +00:00
Most of the preprocessor is working.
This commit is contained in:
parent
c57884d674
commit
7a1e3946d5
@ -153,6 +153,8 @@ doctest:
|
|||||||
"results in $(BUILDDIR)/doctest/output.txt."
|
"results in $(BUILDDIR)/doctest/output.txt."
|
||||||
|
|
||||||
pdf:
|
pdf:
|
||||||
|
TEMP_DIR=`python pdf_optimise.py`
|
||||||
$(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) build/pdf
|
$(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) build/pdf
|
||||||
|
python pdf_optimise.py restore $(TEMP_DIR)
|
||||||
@echo
|
@echo
|
||||||
@echo "Build finished. The PDF files are in build/pdf."
|
@echo "Build finished. The PDF files are in build/pdf."
|
||||||
|
@ -5,11 +5,11 @@ from tempfile import mkdtemp
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
IMAGE_WIDTH = re.compile(r'^ :width: ([\d]+)px', re.UNICODE)
|
IMAGE_WIDTH = re.compile(r':width: ([\d]+)px', re.UNICODE)
|
||||||
|
|
||||||
def copy_files(source_dir, temp_dir):
|
def copy_files(source_dir, temp_dir):
|
||||||
for root, dirs, files in os.walk(source_dir):
|
for root, dirs, files in os.walk(source_dir):
|
||||||
curr_dir = root[len(source_dir):]
|
curr_dir = root[len(source_dir) + 1:]
|
||||||
full_dir = os.path.join(temp_dir, curr_dir)
|
full_dir = os.path.join(temp_dir, curr_dir)
|
||||||
for name in files:
|
for name in files:
|
||||||
if name.endswith(u'.rst'):
|
if name.endswith(u'.rst'):
|
||||||
@ -31,7 +31,9 @@ def adjust_image(match):
|
|||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
def process_images(filename):
|
def process_images(filename):
|
||||||
contents = open(filename, 'rb').read()
|
fd = open(filename, 'rb')
|
||||||
|
contents = fd.read()
|
||||||
|
fd.close()
|
||||||
contents = IMAGE_WIDTH.sub(adjust_image, contents)
|
contents = IMAGE_WIDTH.sub(adjust_image, contents)
|
||||||
fd = open(filename, 'wb')
|
fd = open(filename, 'wb')
|
||||||
fd.write(contents)
|
fd.write(contents)
|
||||||
@ -46,10 +48,8 @@ def process_files(base_dir):
|
|||||||
def main():
|
def main():
|
||||||
here = os.path.abspath(os.path.split(__file__)[0])
|
here = os.path.abspath(os.path.split(__file__)[0])
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == 'restore':
|
if len(sys.argv) > 1 and sys.argv[1] == 'restore':
|
||||||
print 'Restoring...',
|
|
||||||
temp_dir = os.path.abspath(sys.argv[2])
|
temp_dir = os.path.abspath(sys.argv[2])
|
||||||
restore_files(temp_dir, here)
|
restore_files(temp_dir, here)
|
||||||
print 'done.'
|
|
||||||
else:
|
else:
|
||||||
temp_dir = mkdtemp()
|
temp_dir = mkdtemp()
|
||||||
print temp_dir
|
print temp_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user