## tikz

Renders Tikz code to PDF.

### Aliases for this filter

• tikz

### Converts from file formats:

• .tex
• .txt

### To file formats:

• .pdf

### Available settings:

SettingDescriptionDefault
add-new-filesBoolean or list of extensions/patterns to match.False
added-in-versionDexy version when this filter was first available.
argsArguments to be passed to the executable.
check-return-codeWhether to look for nonzero return code.True
clargsArguments to be passed to the executable (same as 'args').
command-stringThe full command string.%(prog)s -interaction=nonstopmode -halt-on-error %(args)s %(script_file)s
data-typeAlias of custom data class to use to store filter output.generic
envDictionary of key-value pairs to be added to environment for runs.{}
examplesTemplates which should be used as examples for this filter.[]
exclude-new-files-from-dirList of directories to skip when adding new files.[]
executableThe executable to be runpdflatex
extFile extension to output.None
extension-mapDictionary mapping input extensions to default output extensions.None
helpHelpstring for plugin.Renders Tikz code to PDF.
initial-timeout10
input-extensionsList of extensions which this filter can accept as input.['.tex', '.txt']
keep-originalsWhether, if additional-doc-filters are specified, the original unmodified docs should also be added.False
make-dummy-outputWhether to make a dummy output file when one is not generated and add-new-files is True.False
mkdirA directory which should be created in working dir.None
mkdirsA list of directories which should be created in working dir.[]
nodocWhether filter should be excluded from documentation.False
outputWhether to output results of this filter by default by reporters such as 'output' or 'website'.True
output-extensionsList of extensions which this filter can produce as output.['.pdf']
override-workspace-exclude-filtersIf True, document will be populated to other workspaces ignoring workspace-exclude-filters.False
path-extensionsstrings to extend path with[]
preserve-prior-data-classWhether output data class should be set to match the input data class.False
record-varsWhether to add code that will automatically record values of variables.False
require-outputShould dexy raise an exception if no output is produced by this filter?True
run-bibtexShould we run bibtex if a .bib file is an input?True
scriptargsArguments to be passed to the executable.
tagsTags which describe the filter.[]
timeout10
times-to-run-latexHow many times to run latex? (Latex is run one additional time if bibtex runs.)2
use-wdWhether to use a custom working directory when running filter.True
variablesA dictionary of variable names and values to make available to this filter.{}
varsA dictionary of variable names and values to make available to this filter.{}
version-commandCommand to call to return version of installed software.None
windows-version-commandCommand to call on windows to return version of installed software.None
workspace-exclude-filtersFilters whose output should be excluded from workspace.['pyg']
workspace-includesIf set to a list of filenames or extensions, only these will be populated to working dir.None
write-stderr-to-stdoutShould stderr be piped to stdout?True
##### Filter Source Code
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 class TikzPdfFilter(LatexFilter): """ Renders Tikz code to PDF. """ aliases = ['tikz'] def process(self): latex_filename = self.output_data.basename().replace(self.ext, ".tex") # TODO allow setting tikz libraries per-document, or just include all of them? # TODO how to create a page size that just includes the content latex_header = r"""\documentclass[tikz]{standalone} \usetikzlibrary{shapes.multipart} \begin{document} """ latex_footer = "\n\end{document}" self.populate_workspace() wd = self.parent_work_dir() work_path = os.path.join(wd, latex_filename) self.log_debug("writing latex header + tikz content to %s" % work_path) with codecs.open(work_path, "w", encoding="utf-8") as f: f.write(latex_header) f.write(str(self.input_data)) f.write(latex_footer) latex_command = "%s -interaction=batchmode %s" % (self.setting('executable'), latex_filename) def run_cmd(command): self.log_debug("about to run %s in %s" % (command, os.path.abspath(wd))) proc = subprocess.Popen(command, shell=True, cwd=wd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=self.setup_env()) stdout, stderr = proc.communicate() if proc.returncode > 2: # Set at 2 for now as this is highest I've hit, better to detect whether PDF has been generated? raise dexy.exceptions.UserFeedback("latex error, look for information in %s" % latex_filename.replace(".tex", ".log")) elif proc.returncode > 0: self.log_warn("""A non-critical latex error has occurred running %s, status code returned was %s, look for information in %s""" % ( self.key, proc.returncode, latex_filename.replace(".tex", ".log"))) run_cmd(latex_command) self.copy_canonical_file()