Add build rule for creating markdown documents from LaTeX
This commit is contained in:
24
wscript
24
wscript
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
# Created On: Tue 28 Aug 2012 11:44:05 CEST
|
# 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
|
# MAKEFILE for compiling LaTeX Files
|
||||||
|
|
||||||
VERSION='1.1.0'
|
VERSION='1.1.0'
|
||||||
@@ -13,7 +13,7 @@ chapterpath='./chapters'
|
|||||||
|
|
||||||
# query the options that are possible outputs
|
# query the options that are possible outputs
|
||||||
def options(ctx):
|
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('--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('--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')
|
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.find_program('handlatex',var='TEX')
|
||||||
ctx.env.TEXINPUT = ctx.path.abspath() + '//'
|
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
|
# define a structure to assign the functions to the parameters
|
||||||
conf_output = {'pdflatex' : conf_tex,
|
conf_output = {'pdflatex' : conf_tex,
|
||||||
'latex' : conf_tex,
|
'latex' : conf_tex,
|
||||||
'htlatex' : conf_htlatex,
|
'htlatex' : conf_htlatex,
|
||||||
'odt' : conf_odt,
|
'odt' : conf_odt,
|
||||||
'epub' : conf_epub,
|
'epub' : conf_epub,
|
||||||
'handlatex' : conf_handlatex
|
'handlatex' : conf_handlatex,
|
||||||
|
'markdown' : conf_markdown
|
||||||
}
|
}
|
||||||
|
|
||||||
# set the selected mode
|
# set the selected mode
|
||||||
@@ -159,6 +163,15 @@ def build(ctx):
|
|||||||
fileName, fileExt = os.path.splitext(f)
|
fileName, fileExt = os.path.splitext(f)
|
||||||
ctx.install_files('${PREFIX}',fileName + outExt)
|
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
|
# define a structure to assign the functions to the parameters
|
||||||
build_output = {'pdflatex' : build_tex,
|
build_output = {'pdflatex' : build_tex,
|
||||||
@@ -166,7 +179,8 @@ def build(ctx):
|
|||||||
'htlatex' : build_htlatex,
|
'htlatex' : build_htlatex,
|
||||||
'odt' : build_odt,
|
'odt' : build_odt,
|
||||||
'epub' : build_epub,
|
'epub' : build_epub,
|
||||||
'handlatex' : build_handlatex
|
'handlatex' : build_handlatex,
|
||||||
|
'markdown' : build_markdown
|
||||||
}
|
}
|
||||||
|
|
||||||
# call the configured build method
|
# call the configured build method
|
||||||
|
|||||||
Reference in New Issue
Block a user