Add build rule for creating markdown documents from LaTeX

This commit is contained in:
2021-11-13 18:16:22 +01:00
parent 2466bf498b
commit 51616a6794

24
wscript
View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8
# Created On: Tue 28 Aug 2012 11:44:05 CEST
# Last Modified: Sun 08 Apr 2018 10:46:32 pm CEST
# Last Modified: Sat 13 Nov 2021 06:11:56 PM CET CEST
# MAKEFILE for compiling LaTeX Files
VERSION='1.1.0'
@@ -13,7 +13,7 @@ chapterpath='./chapters'
# query the options that are possible outputs
def options(ctx):
ctx.add_option('--form',action='store',default='pdflatex',help='Specify the output format. Allowed values are: pdflatex, latex, htlatex, odt, epub, handlatex')
ctx.add_option('--form',action='store',default='pdflatex',help='Specify the output format. Allowed values are: pdflatex, latex, htlatex, odt, epub, handlatex, markdown')
ctx.add_option('--cover',action='store',default='images/cover.png',help='Specify an image as cover for ePubs.\nOnly works with --form=epub')
ctx.add_option('--infile',action='store',help='Specify the tex file to use as input file.\nIf not given, all files in the top level directory will be compiled.')
ctx.add_option('--css',action='store',default='css/epub.css',help='Specifiy a style sheet to design an ebook')
@@ -50,14 +50,18 @@ def configure(ctx):
ctx.find_program('handlatex',var='TEX')
ctx.env.TEXINPUT = ctx.path.abspath() + '//'
def conf_markdown(ctx):
ctx.find_program('pandoc',var='MARKDOWN')
ctx.env.TEXINPUT = ctx.path.abspath() + '//'
# define a structure to assign the functions to the parameters
conf_output = {'pdflatex' : conf_tex,
'latex' : conf_tex,
'htlatex' : conf_htlatex,
'odt' : conf_odt,
'epub' : conf_epub,
'handlatex' : conf_handlatex
'handlatex' : conf_handlatex,
'markdown' : conf_markdown
}
# set the selected mode
@@ -158,6 +162,15 @@ def build(ctx):
if ctx.cmd == 'install':
fileName, fileExt = os.path.splitext(f)
ctx.install_files('${PREFIX}',fileName + outExt)
def build_markdown(ctx):
import os
for f in ctx.env.SOURCEFILES:
fileName, fileExt = os.path.splitext(f)
ctx(rule='TEXINPUTS=${TEXINPUT}: ${MARKDOWN} -t markdown ${SRC} -o ${TGT} > /dev/null', source=f,
target=fileName + '.md')
if ctx.cmd == 'install':
ctx.install_files('${PREFIX}',fileName + outExt)
# define a structure to assign the functions to the parameters
@@ -166,7 +179,8 @@ def build(ctx):
'htlatex' : build_htlatex,
'odt' : build_odt,
'epub' : build_epub,
'handlatex' : build_handlatex
'handlatex' : build_handlatex,
'markdown' : build_markdown
}
# call the configured build method