diff --git a/.gitignore b/.gitignore index ba74660..e819891 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,11 @@ docs/_build/ # PyBuilder target/ + +.tags +README.rst +**/Build/ +**/title.tex +Session.vim +.tags +**/*.zip diff --git a/LICENSE b/LICENSE index 8f71f43..3d482df 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,7 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ +Copyright 2019 Mark Juers - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..9561fb1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include README.rst diff --git a/README.md b/README.md index 1a83535..dee57c5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # authorea-scripts Scripts for working with Authorea articles. + +Installation: pip install authorea-scripts + +Usage of build-authorea-latex: `$build-authorea-latex [options] ` + +Help: `$build-authorea-latex --help` + +You must install latexml.sty from +https://github.com/brucemiller/LaTeXML/blob/master/lib/LaTeXML/texmf/latexml.sty +Just put is in ~/Library/texmf/tex/latex/latexml/ on Mac, or +~/texmf/tex/latex/latexml/ on Linux (I don't know about Windows, unfortunately). diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..4f2ea3a --- /dev/null +++ b/README.rst @@ -0,0 +1,14 @@ +authorea-scripts +================ + +Scripts for working with Authorea articles. + +Installation: pip install authorea-scripts + +Usage of build-authorea-latex: build-authorea-latex [options] + +You must install latexml.sty from +https://github.com/brucemiller/LaTeXML/blob/master/lib/LaTeXML/texmf/latexml.sty +Just put is in ~/Library/texmf/tex/latex/latexml/ on Mac, or +~/texmf/tex/latex/latexml/ on Linux (I don’t know about Windows, +unfortunately). diff --git a/authorea_scripts/__init__.py b/authorea_scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/local_build.py b/authorea_scripts/local_build.py similarity index 59% rename from local_build.py rename to authorea_scripts/local_build.py index bc14db3..82f9433 100755 --- a/local_build.py +++ b/authorea_scripts/local_build.py @@ -20,26 +20,80 @@ the correct place in the ``layout.md`` file. A file named 'latexfigopts.json' can specify a dictionary for additional figure options (see the `FIGURE_DEFAULTS` below for what options that can be replaced). + If pdf or eps figures exist alongside referenced raster image files, they will + be favored over the raster format. """ import os import sys +import shutil import subprocess +from pypandoc import convert_file #lots of dobule-{}'s are here because we use it as a formatting template below MAIN_TEMPLATE = r""" +% Options for packages loaded elsewhere +\PassOptionsToPackage{{unicode}}{{hyperref}} +\PassOptionsToPackage{{hyphens}}{{url}} + {preamblein} +\usepackage{{graphicx}} +\usepackage{{natbib}} +\usepackage{{latexml}} +\usepackage{{setspace}} +\usepackage{{hyperref}} +\usepackage[english]{{babel}} + +% From pandoc +\usepackage{{lmodern}} +\usepackage{{amssymb,amsmath}} +\usepackage{{ifxetex,ifluatex}} +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \usepackage[T1]{{fontenc}} + \usepackage[utf8]{{inputenc}} + \usepackage{{textcomp}} % provide euro and other symbols +\else % if luatex or xetex + \usepackage{{unicode-math}} + \defaultfontfeatures{{Scale=MatchLowercase}} + \defaultfontfeatures[\rmfamily]{{Ligatures=TeX,Scale=1}} +\fi +% Use upquote if available, for straight quotes in verbatim environments +\IfFileExists{{upquote.sty}}{{\usepackage{{upquote}}}}{{}} +\IfFileExists{{microtype.sty}}{{% use microtype if available + \usepackage[]{{microtype}} + \UseMicrotypeSet[protrusion]{{basicmath}} % disable protrusion for tt fonts +}}{{}} +{parskip} +\usepackage{{xcolor}} +\IfFileExists{{xurl.sty}}{{\usepackage{{xurl}}}}{{}} % add URL line breaks if available +\IfFileExists{{bookmark.sty}}{{\usepackage{{bookmark}}}}{{\usepackage{{hyperref}}}} +\hypersetup{{ + hidelinks, + pdfcreator={{LaTeX via pandoc}}}} +\urlstyle{{same}} % disable monospaced font for URLs +\setlength{{\emergencystretch}}{{3em}} % prevent overfull lines +\providecommand{{\tightlist}}{{% + \setlength{{\itemsep}}{{0pt}}\setlength{{\parskip}}{{0pt}}}} +\setcounter{{secnumdepth}}{{-\maxdimen}} % remove section numbering + +\date{{}} + +\let\cite\{citecommand} + {headerin} +{titlecontent} + \begin{{document}} -{titlecontent} +{spacing} {sectioninputs} +\bibliographystyle{{{bibstyle}}} \bibliography{{{bibloc}}}{{}} \end{{document}} @@ -54,7 +108,7 @@ \end{} """.replace('{', '{{').replace('}', '}}').replace('<', '{').replace('>', '}') -FIGURE_DEFAULTS = {'placement': '', 'width': '1\columnwidth', 'figure_env': 'figure'} +FIGURE_DEFAULTS = {'placement': '', 'width': '1\columnwidth', 'figure_env': 'figure', 'caption': ''} def get_input_string(filename, localdir, quotepath=True, flatten=False): @@ -72,31 +126,51 @@ def get_input_string(filename, localdir, quotepath=True, flatten=False): quote_chr = '"' else: quote_chr = '' - return r'\input{' + quote_chr + os.path.join(localdir, filename) + quote_chr + '}' + return r'\input{' + os.path.join(localdir, filename) + '}' -def get_figure_string(filename, localdir, inputdir, flatten=False): +def get_figure_string(filename, localdir, inputdir, flatten=False, copyto=False): import json - figdir, figfn = os.path.split(filename) - - figfnbase = os.path.splitext(figfn)[0] - figfn = os.path.join(inputdir, figdir, figfn) - pdffn = os.path.join(localdir, figdir, figfnbase + '.pdf') - epsfn = os.path.join(localdir, figdir, figfnbase + '.eps') - - if not os.path.exists(pdffn): - pdffn = None - if not os.path.exists(epsfn): - epsfn = None - - if pdffn or epsfn: - figfn = os.path.join(inputdir, figdir, figfnbase) - + figdir, figname = os.path.split(filename) + + fignamebase = os.path.splitext(figname)[0] + figfn = os.path.join(inputdir, filename) + pngfn = os.path.join(localdir, figdir, fignamebase, fignamebase + '.png') + pdffn = os.path.join(localdir, figdir, fignamebase, fignamebase + '.pdf') + epsfn = os.path.join(localdir, figdir, fignamebase, fignamebase + '.eps') + + if copyto: + figpath = os.path.join(localdir, filename) + if os.path.exists(pdffn): + figpath = pdffn + figfn = fignamebase + elif os.path.exists(epsfn): + figpath = epsfn + figfn = fignamebase + elif os.path.exists(pngfn): + figpath = pngfn + figfn = fignamebase + elif os.path.exists(figpath): + figfn = figname + else: + raise IOError('Could not find figure file {}'.format(figpath)) + shutil.copy(figpath, os.path.join(copyto, os.path.split(figpath)[1])) + else: + if ( os.path.exists(pdffn) + or os.path.exists(epsfn) + or os.path.exists(pngfn) + ): + figfn = os.path.join(inputdir, figdir, fignamebase, fignamebase) if os.path.exists(os.path.join(localdir, figdir, 'caption.tex')): capinput = get_input_string('caption', os.path.join(inputdir, figdir), False, flatten=flatten) caption = r'\caption{ \protect' + capinput.strip() + '}' + elif os.path.exists(os.path.join(localdir, figdir, 'caption.html')): + caption = convert_file( + os.path.join(localdir, figdir, 'caption.html'), + 'latex', format='html+tex_math_dollars', filters=['stripreftags'] + ) else: caption = '' @@ -113,6 +187,7 @@ def get_figure_string(filename, localdir, inputdir, flatten=False): figopts[k] = v if len(optsjson) != 0: raise ValueError('Entries in "{0}" that were not understood: {1}'.format(optsfn, optsjson)) + figopts['caption'] = caption figopts.update(locals()) return FIGURE_TEMPLATE.format(**figopts) @@ -145,7 +220,34 @@ def get_in_path(localdir, builddir, pathtype=None): def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, usetitle, dobibtex, npostbibcalls, openwith, titleinput, - dobuild, pathtype, flatten): + dobuild, pathtype, flatten, copy_figs, bibstyle, + citecommand, spacing, noparskip): + + if noparskip: + parskip = '' + else: + parskip = r''' + \makeatletter + \@ifundefined{KOMAClassName}{% if non-KOMA class + \IfFileExists{parskip.sty}{% + \usepackage{parskip} + }{% else + \setlength{\parindent}{0pt} + \setlength{\parskip}{6pt plus 2pt minus 1pt}} + }{% if KOMA class + \KOMAoptions{parskip=half}} + \makeatother + ''' + + if spacing == 'single': + spacing = '' + elif spacing == 'half': + spacing = r'\onehalfspacing' + elif spacing == 'double': + spacing = r'\doublespacing' + else: + raise ValueError('spacing must be "single, half, or double"') + if not os.path.exists(builddir): os.mkdir(builddir) @@ -157,7 +259,7 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, if os.path.exists(os.path.join(localdir, 'preamble.tex')): preamblein = get_input_string('preamble', get_in_path(localdir, builddir, pathtype), flatten=flatten) else: - preamblein = '' + preamblein = r'\documentclass[12pt]{article}' if os.path.exists(os.path.join(localdir, 'header.tex')): headerin = get_input_string('header', get_in_path(localdir, builddir, pathtype), flatten=flatten) else: @@ -166,18 +268,25 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, if not headerin and not preamblein: print("Neither preable nor header found! Proceeding, but that's rather weird") - bibloc = os.path.join(get_in_path(localdir, builddir, pathtype), 'bibliography', 'biblio') + + if copy_figs: + bibloc_abs = os.path.join(get_in_path(localdir, builddir, 'abs'), 'bibliography', 'biblio') + '.bib' + shutil.copy(bibloc_abs, os.path.join(builddir, os.path.split(bibloc_abs)[1])) + bibloc = 'biblio' + else: + bibloc = os.path.join(get_in_path(localdir, builddir, pathtype), 'bibliography', 'biblio') + '.bib' titlecontent = [] + sectioninputs = [] if usetitle: if titleinput: titlestr = get_input_string('title', get_in_path(localdir, builddir, pathtype), flatten=flatten) else: with open(os.path.join(get_in_path(localdir, builddir, 'abs'), 'title.tex')) as f: titlestr = f.read() - titlecontent.append(r'\title{' + titlestr + '}') + titlecontent.append(r'\title{' + titlestr.strip('\n') + '}') + sectioninputs.append('\maketitle\n') - sectioninputs = [] with open(os.path.join(localdir, 'layout.md')) as f: for l in f: ls = l.strip() @@ -185,14 +294,27 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, pass elif ls in ('posttitle.tex', 'title.tex', 'preamble.tex', 'header.tex'): pass # skip any that have been processed above - elif ls in ('abstract.tex'): + elif ls in ('abstract.html'): # add abstract to title content - titlein = get_input_string('abstract', get_in_path(localdir, builddir, pathtype), flatten=flatten) - titlecontent.append(r'\begin{abstract}' + titlein + '\end{abstract}') + html_to_tex = convert_file( + os.path.join(localdir, ls), + 'latex', format='html+tex_math_dollars', filters=['stripreftags']) + sectioninputs.append(r'\begin{abstract}' + '\n' + html_to_tex + r'\end{abstract}') elif ls.endswith('.html') or ls.endswith('.htm'): - pass # html files aren't latex-able + html_to_tex = convert_file( + os.path.join(localdir, ls), + 'latex', format='html+tex_math_dollars', filters=['stripreftags']) + sectioninputs.append(html_to_tex) + elif ls.endswith('.md'): + md_to_tex = convert_file( + os.path.join(localdir, ls), + 'latex', format='markdown+tex_math_dollars') + sectioninputs.append(md_to_tex) elif ls.startswith('figures'): - sectioninputs.append(get_figure_string(ls, localdir, get_in_path(localdir, builddir, pathtype), flatten=flatten)) + ls = ls + ls.lstrip('figures') + inpath = get_in_path(localdir, builddir, pathtype) + sectioninputs.append(get_figure_string(ls, localdir, inpath, flatten=flatten, + copyto=builddir if copy_figs else False)) else: sectioninputs.append(get_input_string(ls, get_in_path(localdir, builddir, pathtype), flatten=flatten)) sectioninputs = '\n'.join(sectioninputs) @@ -217,25 +339,25 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, if dobuild: #now actually run latex/bibtex - args = [latex_exec, outname + '.tex'] + buildargs = [latex_exec, outname + '.tex'] print('\n\RUNNING THIS COMMAND: "{0}"\n'.format(' '.join([latex_exec, outname + '.tex']))) - subprocess.check_call(args, cwd=builddir) + subprocess.check_call(buildargs, cwd=builddir) if dobibtex: - args = [bibtex_exec, outname] + buildargs = [bibtex_exec, outname] print('\n\RUNNING THIS COMMAND: "{0}"\n'.format(' '.join([latex_exec, outname + '.tex']))) - subprocess.check_call(args, cwd=builddir) + subprocess.check_call(buildargs, cwd=builddir) for _ in range(npostbibcalls): - args = [latex_exec, outname + '.tex'] + buildargs = [latex_exec, outname + '.tex'] print('\n\RUNNING THIS COMMAND: "{0}"\n'.format(' '.join([latex_exec, outname + '.tex']))) - subprocess.check_call(args, cwd=builddir) + subprocess.check_call(buildargs, cwd=builddir) #launch the result if necessary resultfn = outtexpath[:-4] + ('.pdf' if 'pdf' in latex_exec else '.dvi') if openwith: - args = openwith.split(' ') - args.append(resultfn) - print('\nLaunching as:' + str(args), '\n') - subprocess.check_call(args) + buildargs = openwith.split(' ') + buildargs.append(resultfn) + print('\nLaunching as:' + str(buildargs), '\n') + subprocess.check_call(buildargs) else: msg = '\nBuild completed. You can see the result in "{0}": "{1}"' print(msg.format(builddir, resultfn), '\n') @@ -244,7 +366,7 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, print(msg.format(os.path.join(builddir, outname))) -if __name__ == '__main__': +def main(): import argparse parser = argparse.ArgumentParser(description='Local builder for authorea papers.') @@ -286,12 +408,30 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, 'the .tex file absolute. Default is to do this if ' 'localdir and buildir are different.') parser.add_argument('--flatten', '-t', action='store_true', - help='Directly inputs the content from the files instead of .') + help=r'Directly includes the content from tex files ' + r'instead of using \input.') + parser.add_argument('--copy-figs', '-c', action='store_true', + help='Copy figures and any bib files into the build ' + 'directory and set includes to point to those copies.') + parser.add_argument('--bibstyle', nargs='?', default='apa', + help='The bibliography style to use') + parser.add_argument('--citecommand', nargs='?', default='citep', + help='The primary natbib citation command to use.' + ' Omit leading backslash.') + parser.add_argument('--spacing', nargs='?', default='half', + help='Spacing to use for the document. "single", "half", or "double"' + ' "half" is one and one-half') + parser.add_argument('--noparskip', action='store_true', + help='Suppresses loading parskip class for normal' + ' indentation rules.') args = parser.parse_args() pathtype = None + convert_file(os.path.join(args.localdir, 'title.html'), + 'latex', format='html+tex_math_dollars', outputfile=os.path.join(args.localdir, 'title.tex')) + if args.flatten and (args.rellinks or args.abslinks): print('You cannot use both "--flatten" and either "--relative-links" ' 'or "--absolute-links".') @@ -310,4 +450,10 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname, build_authorea_latex(args.localdir, args.build_dir, args.latex, args.bibtex, args.filename, args.usetitle, args.usebibtex, args.n_runs_after_bibtex, args.open_with, - args.titleinput, args.dobuild, pathtype, args.flatten) + args.titleinput, args.dobuild, pathtype, args.flatten, + args.copy_figs, args.bibstyle, args.citecommand, + args.spacing, args.noparskip) + + +if __name__ == "__main__": + main() diff --git a/authorea_scripts/stripreftags.py b/authorea_scripts/stripreftags.py new file mode 100755 index 0000000..ee0836d --- /dev/null +++ b/authorea_scripts/stripreftags.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +""" +Pandoc filter to strip tags from references and citations and write plain +text. +""" +import re +import panflute as pf + + +def multireplace(string, replacements): + """ + Given a string and a replacement map, it returns the replaced string. + :param str string: string to execute replacements on + :param dict replacements: replacement dictionary {value to find: value to replace} + :rtype: str + """ + # Place longer ones first to keep shorter substrings from matching where the longer ones should take place + # For instance given the replacements {'ab': 'AB', 'abc': 'ABC'} against the string 'hey abc', it should produce + # 'hey ABC' and not 'hey ABc' + substrs = sorted(replacements, key=len, reverse=True) + + # Create a big OR regex that matches any of the substrings to replace + regexp = re.compile('|'.join(map(re.escape, substrs))) + + # For each match, look up the new string in the replacements + return regexp.sub(lambda match: replacements[match.group(0)], string) + + +def striptags(elem, doc, replacements): + try: + if elem.format == 'html': + return[] + except AttributeError: + pass + + +def destring(elem, doc, replacements): + if isinstance(elem, pf.Str): + return pf.RawInline(multireplace(elem.text, replacements), + format='latex') + else: + return elem + + +def labels(elem, doc, replacements): + if ( isinstance(elem, pf.Header) + or isinstance(elem, pf.Div)): + try: + if 'label' in elem.attributes: + elem.identifier = label = elem.attributes['label'] + mytext = (r'\caption{\hypertarget{' + + label + + r'}{\label{' + + label + + r'}}') + first_child = elem.content[0] + first_child.content.insert(0, pf.RawInline(mytext, format='latex')) + first_child.content.append(pf.RawInline(r'}', format='latex')) + return (elem if isinstance(elem, pf.Header) + else pf.Div(first_child)) + except AttributeError: + pass + # Extra section headers with not content can cause an IndexError. + except IndexError: + pass + except KeyError: + pass + + +def main(doc=None): + replacements = {'\\\\(cite[tp]?|ref)\{(.*)\}': r'\\\1{\2}', + '$': r'\$'} + return pf.run_filters((labels, striptags, destring), + doc=doc, replacements=replacements) + + +if __name__ == '__main__': + main() diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..e70b9dd --- /dev/null +++ b/changelog.md @@ -0,0 +1,23 @@ +# Changelog + +## 0.0.2 + +- Fixed an error that caused inline math to be typset without space before. +- Fixed compilation errors with multiple section headings. + +## 0.0.3 + +- Added argument to control spacing. +- Added ability to not use parskip class for standard indentation rules. + +## 0.0.5 + +- Fixed custom citation command. + +## 0.0.6 + +- Added markdown support. + +## 0.0.7 + +- Fixed handling of captions. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..498ba48 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +setuptools==39.0.1 +panflute==1.11.2 +pypandoc==1.4 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e472ef7 --- /dev/null +++ b/setup.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from setuptools import setup, find_packages + +import pypandoc + +pypandoc.convert_file('README.md', 'rst', outputfile='README.rst') +setup( + name='authorea-scripts', + version='0.0.7', + py_modules=['build-authorea'], + description='Tools for working locally with Authorea projects', + url='https://github.com/mpjuers/authorea-scripts', + author='Mark Juers', + author_email='mpjuers@indiana.edu', + license='MIT', + packages=find_packages(), + include_package_data=True, + install_requires=[ + 'pypandoc', + 'panflute' + ], + entry_points=''' + [console_scripts] + build-authorea-latex=authorea_scripts.local_build:main + stripreftags=authorea_scripts.stripreftags:main + ''', + zip_safe=False, + classifiers=[ + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + ] + ) diff --git a/test/TestDocument/abstract.html b/test/TestDocument/abstract.html new file mode 100644 index 0000000..3d3cc02 --- /dev/null +++ b/test/TestDocument/abstract.html @@ -0,0 +1 @@ +
An abstract.
\ No newline at end of file diff --git a/test/TestDocument/bibliography/.placeholder.md b/test/TestDocument/bibliography/.placeholder.md new file mode 100644 index 0000000..70235eb --- /dev/null +++ b/test/TestDocument/bibliography/.placeholder.md @@ -0,0 +1 @@ +this is a placeholder for the directory diff --git a/test/TestDocument/bibliography/biblio.bib b/test/TestDocument/bibliography/biblio.bib new file mode 100644 index 0000000..216d4e0 --- /dev/null +++ b/test/TestDocument/bibliography/biblio.bib @@ -0,0 +1,12 @@ +@article{ebert_epidemiology_2013, + title = {{The epidemiology and evolution of symbionts with mixed-mode transmission}}, + volume = {44}, + abstract = {Vertical and horizontal transmission are terms that describe the transfer of symbionts from parents to offspring and among unrelated hosts, respectively. Many symbionts, including parasites, pathogens, mutualists, and microbiota, use a combination of both strategies, known as mixed-mode transmission (MMT). Here I review what is known about the evolution, ecology, and epidemiology of symbionts with MMT and compare MMT with our expectations for single-mode strategies. Symbionts with MMT are common and, in comparison with single-mode symbionts, show many surprising features. MMT combines the best of two worlds with regard to the ecological conditions required for persistence and plays a role in the evolution of virulence and genome architecture. Even rare transmission by the minority type of these two transmission modes can make a big difference for the system. This review explores the conceptual issues surrounding the dynamics of mixed-mode symbionts by reviewing literature from the entire range of host and symbiont taxa.}, + number = {1}, + journal = {Annual Review of Ecology, Evolution, and Systematics}, + doi = {10.1146/annurev-ecolsys-032513-100555}, + author = {Ebert, Dieter}, + year = {2013}, + pages = {623-643}, + file = {/Users/mpjuers/Zotero/Zotero/storage/6WQ93GVG/Ebert - 2013 - The Epidemiology and Evolution of Symbionts with M.pdf;/Users/mpjuers/Zotero/Zotero/storage/IQSHCBR4/es44_ebert_supmat.pdf}, +} diff --git a/test/TestDocument/bibliography/converted_to_latex.bib b/test/TestDocument/bibliography/converted_to_latex.bib new file mode 100644 index 0000000..216d4e0 --- /dev/null +++ b/test/TestDocument/bibliography/converted_to_latex.bib @@ -0,0 +1,12 @@ +@article{ebert_epidemiology_2013, + title = {{The epidemiology and evolution of symbionts with mixed-mode transmission}}, + volume = {44}, + abstract = {Vertical and horizontal transmission are terms that describe the transfer of symbionts from parents to offspring and among unrelated hosts, respectively. Many symbionts, including parasites, pathogens, mutualists, and microbiota, use a combination of both strategies, known as mixed-mode transmission (MMT). Here I review what is known about the evolution, ecology, and epidemiology of symbionts with MMT and compare MMT with our expectations for single-mode strategies. Symbionts with MMT are common and, in comparison with single-mode symbionts, show many surprising features. MMT combines the best of two worlds with regard to the ecological conditions required for persistence and plays a role in the evolution of virulence and genome architecture. Even rare transmission by the minority type of these two transmission modes can make a big difference for the system. This review explores the conceptual issues surrounding the dynamics of mixed-mode symbionts by reviewing literature from the entire range of host and symbiont taxa.}, + number = {1}, + journal = {Annual Review of Ecology, Evolution, and Systematics}, + doi = {10.1146/annurev-ecolsys-032513-100555}, + author = {Ebert, Dieter}, + year = {2013}, + pages = {623-643}, + file = {/Users/mpjuers/Zotero/Zotero/storage/6WQ93GVG/Ebert - 2013 - The Epidemiology and Evolution of Symbionts with M.pdf;/Users/mpjuers/Zotero/Zotero/storage/IQSHCBR4/es44_ebert_supmat.pdf}, +} diff --git a/test/TestDocument/bo8cpuni4jo.md b/test/TestDocument/bo8cpuni4jo.md new file mode 100644 index 0000000..61dbcc3 --- /dev/null +++ b/test/TestDocument/bo8cpuni4jo.md @@ -0,0 +1,2 @@ +# Some markdown +Once, there was a cuttlefish, who we'll call *Sepia apama*. Now, some math: $a + b = c$. \ No newline at end of file diff --git a/test/TestDocument/figures/scatterplot/caption.html b/test/TestDocument/figures/scatterplot/caption.html new file mode 100644 index 0000000..e45c309 --- /dev/null +++ b/test/TestDocument/figures/scatterplot/caption.html @@ -0,0 +1 @@ +
A scatterplot by By DanielPenfield - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=9402369.
\ No newline at end of file diff --git a/test/TestDocument/figures/scatterplot/config.yml b/test/TestDocument/figures/scatterplot/config.yml new file mode 100644 index 0000000..91e2580 --- /dev/null +++ b/test/TestDocument/figures/scatterplot/config.yml @@ -0,0 +1,20 @@ +--- +version: 2 +multicolumn: false +web-width: 500px +align: center +float: h! +grid: + rows: 1 + columns: 1 + grid_elements: + - path: figures/scatterplot/scatterplot.png + type: static + from: + - 1 + - 1 + to: + - 1 + - 1 + url: "/users/263225/articles/372534/master/file/figures/scatterplot/scatterplot.png" + folder_url: "/users/263225/articles/372534/master/folder/figures/scatterplot" diff --git a/test/TestDocument/figures/scatterplot/scatterplot.png b/test/TestDocument/figures/scatterplot/scatterplot.png new file mode 100644 index 0000000..651731b Binary files /dev/null and b/test/TestDocument/figures/scatterplot/scatterplot.png differ diff --git a/test/TestDocument/figures/scatterplot/scatterplot_original.png b/test/TestDocument/figures/scatterplot/scatterplot_original.png new file mode 100644 index 0000000..48e04d3 Binary files /dev/null and b/test/TestDocument/figures/scatterplot/scatterplot_original.png differ diff --git a/test/TestDocument/full_article.tex b/test/TestDocument/full_article.tex new file mode 100644 index 0000000..a53851c --- /dev/null +++ b/test/TestDocument/full_article.tex @@ -0,0 +1,189 @@ +\documentclass[10pt]{article} + +\usepackage{fullpage} +\usepackage{setspace} +\usepackage{parskip} +\usepackage{titlesec} +\usepackage{placeins} +\usepackage{xcolor} +\usepackage{lineno} + + + + + +\PassOptionsToPackage{hyphens}{url} +\usepackage[colorlinks = true, + linkcolor = blue, + urlcolor = blue, + citecolor = blue, + anchorcolor = blue]{hyperref} +\usepackage{etoolbox} +\makeatletter +\patchcmd\@combinedblfloats{\box\@outputbox}{\unvbox\@outputbox}{}{% + \errmessage{\noexpand\@combinedblfloats could not be patched}% +}% +\makeatother + + +\usepackage{natbib} + + + + +\renewenvironment{abstract} + {{\bfseries\noindent{\abstractname}\par\nobreak}\footnotesize} + {\bigskip} + +\renewenvironment{quote} + {\begin{tabular}{|p{13cm}}} + {\end{tabular}} + +\titlespacing{\section}{0pt}{*3}{*1} +\titlespacing{\subsection}{0pt}{*2}{*0.5} +\titlespacing{\subsubsection}{0pt}{*1.5}{0pt} + + +\usepackage{authblk} + + +\usepackage{graphicx} +\usepackage[space]{grffile} +\usepackage{latexsym} +\usepackage{textcomp} +\usepackage{longtable} +\usepackage{tabulary} +\usepackage{booktabs,array,multirow} +\usepackage{amsfonts,amsmath,amssymb} +\providecommand\citet{\cite} +\providecommand\citep{\cite} +\providecommand\citealt{\cite} +% You can conditionalize code for latexml or normal latex using this. +\newif\iflatexml\latexmlfalse +\providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}% + +\AtBeginDocument{\DeclareGraphicsExtensions{.pdf,.PDF,.eps,.EPS,.png,.PNG,.tif,.TIF,.jpg,.JPG,.jpeg,.JPEG}} + +\usepackage[utf8]{inputenc} +\usepackage[english]{babel} + + + + + + +% Edit this header.tex file to include frontmatter definitions and global macros + +% Add here any LaTeX packages you would like to load in all document blocks +% \usepackage{xspace} +\usepackage{authblk} + +\author[1]{Mark Juers} +\affil[1]{Indiana University} +% Add here any LaTeX macros you would like to load in all document blocks +% \def\example{This is an example macro.} +\setcounter{secnumdepth}{2} + + +% ----- + +\iflatexml +% Add here any LaTeXML-specific commands + +% ----- + +\else +% Add here any export style-specific LaTeX commands. These will only be loaded upon document export. +% \paperfield{Subject domain of my document} +% \keywords{keyword1, keyword2} +% \corraddress{Author One PhD, Department, Institution, City, State or Province, Postal Code, Country} +% \fundinginfo{Funder One, Funder One Department, Grant/Award Number: 123456.} +\fi + + +\begin{document} + +\title{Test document} + + + +\author[1]{Mark Juers}% +\affil[1]{Affiliation not available}% + + +\vspace{-1em} + + + + \date{\today} + + +\begingroup +\let\center\flushleft +\let\endcenter\endflushleft +\maketitle +\endgroup + + + + + +\selectlanguage{english} +\begin{abstract} +An abstract.% +\end{abstract}% + + + + +\section*{A heading} + +{\label{850151}} + +\subsection*{Another heading} + +{\label{367935}} + +\hyperref[csl:1]{(Ebert, 2013)} + +\hyperref[csl:1]{(Ebert, 2013)} + +\hyperref[csl:1]{(Ebert, 2013)} + +Figure {\ref{286335}} + +Eq~{\ref{eq:eq1}} + +An inline equation:~\(\int_0^xf\left(t\right)\mathrm{d}t\). And a display equation. + +\begin{equation} +\label{eq:eq1} +\int_0^x f(t) \mathrm{d}t +\end{equation} + +Some troublesome dollar signs: \$100, \$200, \$300 + +Section~{\ref{850151}} + +\section*{Some markdown}\label{some-markdown} + +Once, there was a cuttlefish, who we'll call \emph{Sepia apama}. Now, +some math: \(a + b = c\).\selectlanguage{english} +\begin{figure}[h!] +\begin{center} +\includegraphics[width=0.70\columnwidth]{figures/scatterplot/scatterplot} +\caption{{A scatterplot by By DanielPenfield - Own work, CC BY-SA 3.0, +\url{https://commons.wikimedia.org/w/index.php?curid=9402369}. +{\label{286335}}% +}} +\end{center} +\end{figure} + +\selectlanguage{english} +\FloatBarrier +\section*{References}\sloppy +\phantomsection +\label{csl:1}Ebert, D. (2013). {The epidemiology and evolution of symbionts with mixed-mode transmission}. \textit{Annual Review of Ecology, Evolution, and Systematics}, \textit{44}(1), 623–643. \url{https://doi.org/10.1146/annurev-ecolsys-032513-100555} + +\end{document} + diff --git a/test/TestDocument/header.tex b/test/TestDocument/header.tex new file mode 100644 index 0000000..d2bbfe5 --- /dev/null +++ b/test/TestDocument/header.tex @@ -0,0 +1,27 @@ +% Edit this header.tex file to include frontmatter definitions and global macros + +% Add here any LaTeX packages you would like to load in all document blocks +% \usepackage{xspace} +\usepackage{authblk} + +\author[1]{Mark Juers} +\affil[1]{Indiana University} +% Add here any LaTeX macros you would like to load in all document blocks +% \def\example{This is an example macro.} +\setcounter{secnumdepth}{2} + + +% ----- + +\iflatexml +% Add here any LaTeXML-specific commands + +% ----- + +\else +% Add here any export style-specific LaTeX commands. These will only be loaded upon document export. +% \paperfield{Subject domain of my document} +% \keywords{keyword1, keyword2} +% \corraddress{Author One PhD, Department, Institution, City, State or Province, Postal Code, Country} +% \fundinginfo{Funder One, Funder One Department, Grant/Award Number: 123456.} +\fi diff --git a/test/TestDocument/layout.md b/test/TestDocument/layout.md new file mode 100644 index 0000000..d4f5844 --- /dev/null +++ b/test/TestDocument/layout.md @@ -0,0 +1,7 @@ +abstract.html +untitled.html +li1fpi8krbo.html +rtdm09a2c6g.tex +nat261l8ito.html +bo8cpuni4jo.md +figures/scatterplot \ No newline at end of file diff --git a/test/TestDocument/li1fpi8krbo.html b/test/TestDocument/li1fpi8krbo.html new file mode 100644 index 0000000..ad0251e --- /dev/null +++ b/test/TestDocument/li1fpi8krbo.html @@ -0,0 +1 @@ +
An inline equation: \(\int_0^xf\left(t\right)\mathrm{d}t\). And a display equation.
\ No newline at end of file diff --git a/test/TestDocument/nat261l8ito.html b/test/TestDocument/nat261l8ito.html new file mode 100644 index 0000000..1727c09 --- /dev/null +++ b/test/TestDocument/nat261l8ito.html @@ -0,0 +1 @@ +
Some troublesome dollar signs: $100, $200, $300
Section \ref{850151}
\ No newline at end of file diff --git a/test/TestDocument/rtdm09a2c6g.tex b/test/TestDocument/rtdm09a2c6g.tex new file mode 100644 index 0000000..328b7ce --- /dev/null +++ b/test/TestDocument/rtdm09a2c6g.tex @@ -0,0 +1,4 @@ +\begin{equation} +\label{eq:eq1} +\int_0^x f(t) \mathrm{d}t +\end{equation} \ No newline at end of file diff --git a/test/TestDocument/title.html b/test/TestDocument/title.html new file mode 100644 index 0000000..0309800 --- /dev/null +++ b/test/TestDocument/title.html @@ -0,0 +1 @@ +
Test document
\ No newline at end of file diff --git a/test/TestDocument/title.tex b/test/TestDocument/title.tex new file mode 100644 index 0000000..f15f917 --- /dev/null +++ b/test/TestDocument/title.tex @@ -0,0 +1 @@ +Test document diff --git a/test/TestDocument/untitled.html b/test/TestDocument/untitled.html new file mode 100644 index 0000000..5f8be20 --- /dev/null +++ b/test/TestDocument/untitled.html @@ -0,0 +1 @@ +

A heading

Another heading

\cite{ebert_epidemiology_2013}
\citet{ebert_epidemiology_2013}
\citep[see][]{ebert_epidemiology_2013}
Figure \ref{286335}
Eq \ref{eq:eq1}
\ No newline at end of file diff --git a/test/TestDocumentCustomHeader/Test document.zip b/test/TestDocumentCustomHeader/Test document.zip new file mode 100644 index 0000000..056ad6b Binary files /dev/null and b/test/TestDocumentCustomHeader/Test document.zip differ diff --git a/test/TestDocumentCustomHeader/bibliography/.placeholder.md b/test/TestDocumentCustomHeader/bibliography/.placeholder.md new file mode 100644 index 0000000..70235eb --- /dev/null +++ b/test/TestDocumentCustomHeader/bibliography/.placeholder.md @@ -0,0 +1 @@ +this is a placeholder for the directory diff --git a/test/TestDocumentCustomHeader/bibliography/biblio.bib b/test/TestDocumentCustomHeader/bibliography/biblio.bib new file mode 100644 index 0000000..216d4e0 --- /dev/null +++ b/test/TestDocumentCustomHeader/bibliography/biblio.bib @@ -0,0 +1,12 @@ +@article{ebert_epidemiology_2013, + title = {{The epidemiology and evolution of symbionts with mixed-mode transmission}}, + volume = {44}, + abstract = {Vertical and horizontal transmission are terms that describe the transfer of symbionts from parents to offspring and among unrelated hosts, respectively. Many symbionts, including parasites, pathogens, mutualists, and microbiota, use a combination of both strategies, known as mixed-mode transmission (MMT). Here I review what is known about the evolution, ecology, and epidemiology of symbionts with MMT and compare MMT with our expectations for single-mode strategies. Symbionts with MMT are common and, in comparison with single-mode symbionts, show many surprising features. MMT combines the best of two worlds with regard to the ecological conditions required for persistence and plays a role in the evolution of virulence and genome architecture. Even rare transmission by the minority type of these two transmission modes can make a big difference for the system. This review explores the conceptual issues surrounding the dynamics of mixed-mode symbionts by reviewing literature from the entire range of host and symbiont taxa.}, + number = {1}, + journal = {Annual Review of Ecology, Evolution, and Systematics}, + doi = {10.1146/annurev-ecolsys-032513-100555}, + author = {Ebert, Dieter}, + year = {2013}, + pages = {623-643}, + file = {/Users/mpjuers/Zotero/Zotero/storage/6WQ93GVG/Ebert - 2013 - The Epidemiology and Evolution of Symbionts with M.pdf;/Users/mpjuers/Zotero/Zotero/storage/IQSHCBR4/es44_ebert_supmat.pdf}, +} diff --git a/test/TestDocumentCustomHeader/bibliography/converted_to_latex.bib b/test/TestDocumentCustomHeader/bibliography/converted_to_latex.bib new file mode 100644 index 0000000..216d4e0 --- /dev/null +++ b/test/TestDocumentCustomHeader/bibliography/converted_to_latex.bib @@ -0,0 +1,12 @@ +@article{ebert_epidemiology_2013, + title = {{The epidemiology and evolution of symbionts with mixed-mode transmission}}, + volume = {44}, + abstract = {Vertical and horizontal transmission are terms that describe the transfer of symbionts from parents to offspring and among unrelated hosts, respectively. Many symbionts, including parasites, pathogens, mutualists, and microbiota, use a combination of both strategies, known as mixed-mode transmission (MMT). Here I review what is known about the evolution, ecology, and epidemiology of symbionts with MMT and compare MMT with our expectations for single-mode strategies. Symbionts with MMT are common and, in comparison with single-mode symbionts, show many surprising features. MMT combines the best of two worlds with regard to the ecological conditions required for persistence and plays a role in the evolution of virulence and genome architecture. Even rare transmission by the minority type of these two transmission modes can make a big difference for the system. This review explores the conceptual issues surrounding the dynamics of mixed-mode symbionts by reviewing literature from the entire range of host and symbiont taxa.}, + number = {1}, + journal = {Annual Review of Ecology, Evolution, and Systematics}, + doi = {10.1146/annurev-ecolsys-032513-100555}, + author = {Ebert, Dieter}, + year = {2013}, + pages = {623-643}, + file = {/Users/mpjuers/Zotero/Zotero/storage/6WQ93GVG/Ebert - 2013 - The Epidemiology and Evolution of Symbionts with M.pdf;/Users/mpjuers/Zotero/Zotero/storage/IQSHCBR4/es44_ebert_supmat.pdf}, +} diff --git a/test/TestDocumentCustomHeader/figures/scatterplot/caption.html b/test/TestDocumentCustomHeader/figures/scatterplot/caption.html new file mode 100644 index 0000000..e45c309 --- /dev/null +++ b/test/TestDocumentCustomHeader/figures/scatterplot/caption.html @@ -0,0 +1 @@ +
A scatterplot by By DanielPenfield - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=9402369.
\ No newline at end of file diff --git a/test/TestDocumentCustomHeader/figures/scatterplot/config.yml b/test/TestDocumentCustomHeader/figures/scatterplot/config.yml new file mode 100644 index 0000000..91e2580 --- /dev/null +++ b/test/TestDocumentCustomHeader/figures/scatterplot/config.yml @@ -0,0 +1,20 @@ +--- +version: 2 +multicolumn: false +web-width: 500px +align: center +float: h! +grid: + rows: 1 + columns: 1 + grid_elements: + - path: figures/scatterplot/scatterplot.png + type: static + from: + - 1 + - 1 + to: + - 1 + - 1 + url: "/users/263225/articles/372534/master/file/figures/scatterplot/scatterplot.png" + folder_url: "/users/263225/articles/372534/master/folder/figures/scatterplot" diff --git a/test/TestDocumentCustomHeader/figures/scatterplot/scatterplot.png b/test/TestDocumentCustomHeader/figures/scatterplot/scatterplot.png new file mode 100644 index 0000000..651731b Binary files /dev/null and b/test/TestDocumentCustomHeader/figures/scatterplot/scatterplot.png differ diff --git a/test/TestDocumentCustomHeader/figures/scatterplot/scatterplot_original.png b/test/TestDocumentCustomHeader/figures/scatterplot/scatterplot_original.png new file mode 100644 index 0000000..48e04d3 Binary files /dev/null and b/test/TestDocumentCustomHeader/figures/scatterplot/scatterplot_original.png differ diff --git a/test/TestDocumentCustomHeader/full_article.tex b/test/TestDocumentCustomHeader/full_article.tex new file mode 100644 index 0000000..c8dcb8d --- /dev/null +++ b/test/TestDocumentCustomHeader/full_article.tex @@ -0,0 +1,176 @@ +\documentclass[10pt]{article} + +\usepackage{fullpage} +\usepackage{setspace} +\usepackage{parskip} +\usepackage{titlesec} +\usepackage{xcolor} +\usepackage{lineno} + + + + + +\PassOptionsToPackage{hyphens}{url} +\usepackage[colorlinks = true, + linkcolor = blue, + urlcolor = blue, + citecolor = blue, + anchorcolor = blue]{hyperref} +\usepackage{etoolbox} +\makeatletter +\patchcmd\@combinedblfloats{\box\@outputbox}{\unvbox\@outputbox}{}{% + \errmessage{\noexpand\@combinedblfloats could not be patched}% +}% +\makeatother + + +\usepackage{natbib} + + + + +\renewenvironment{abstract} + {{\bfseries\noindent{\abstractname}\par\nobreak}\footnotesize} + {\bigskip} + +\renewenvironment{quote} + {\begin{tabular}{|p{13cm}}} + {\end{tabular}} + +\titlespacing{\section}{0pt}{*3}{*1} +\titlespacing{\subsection}{0pt}{*2}{*0.5} +\titlespacing{\subsubsection}{0pt}{*1.5}{0pt} + + +\usepackage{authblk} + + +\usepackage{graphicx} +\usepackage[space]{grffile} +\usepackage{latexsym} +\usepackage{textcomp} +\usepackage{longtable} +\usepackage{tabulary} +\usepackage{booktabs,array,multirow} +\usepackage{amsfonts,amsmath,amssymb} +\providecommand\citet{\cite} +\providecommand\citep{\cite} +\providecommand\citealt{\cite} +% You can conditionalize code for latexml or normal latex using this. +\newif\iflatexml\latexmlfalse +\providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}% + +\AtBeginDocument{\DeclareGraphicsExtensions{.pdf,.PDF,.eps,.EPS,.png,.PNG,.tif,.TIF,.jpg,.JPG,.jpeg,.JPEG}} + +\usepackage[utf8]{inputenc} +\usepackage[english]{babel} + + + + + + +% Edit this header.tex file to include frontmatter definitions and global macros + +% Add here any LaTeX packages you would like to load in all document blocks +% \usepackage{xspace} +\usepackage{authblk} + +\author[1]{Mark Juers} +\affil[1]{Indiana University} +% Add here any LaTeX macros you would like to load in all document blocks +% \def\example{This is an example macro.} + + +% ----- + +\iflatexml +% Add here any LaTeXML-specific commands + +% ----- + +\else +% Add here any export style-specific LaTeX commands. These will only be loaded upon document export. +% \paperfield{Subject domain of my document} +% \keywords{keyword1, keyword2} +% \corraddress{Author One PhD, Department, Institution, City, State or Province, Postal Code, Country} +% \fundinginfo{Funder One, Funder One Department, Grant/Award Number: 123456.} +\fi + + +\begin{document} + +\title{Test document} + + + +\author[1]{Mark Juers}% +\affil[1]{Affiliation not available}% + + +\vspace{-1em} + + + + \date{\today} + + +\begingroup +\let\center\flushleft +\let\endcenter\endflushleft +\maketitle +\endgroup + + + + + + + + + +\section*{A heading} + +{\label{850151}} + +\subsection*{Another heading} + +{\label{367935}} + +\hyperref[csl:1]{(Ebert, 2013)} + +\hyperref[csl:1]{(Ebert, 2013)} + +\hyperref[csl:1]{(Ebert, 2013)} + +Figure {\ref{286335}} + +Eq~{\ref{eq:eq1}} + +An inline equation:~\(\int_0^xf\left(t\right)\mathrm{d}t\). And a display equation. + +\begin{equation} +\label{eq:eq1} +\int_0^x f(t) \mathrm{d}t +\end{equation} + +Some troublesome dollar signs: \$100, \$200, \$300\selectlanguage{english} +\begin{figure}[h!] +\begin{center} +\includegraphics[width=0.70\columnwidth]{figures/scatterplot/scatterplot} +\caption{{A scatterplot by By DanielPenfield - Own work, CC BY-SA 3.0, +\url{https://commons.wikimedia.org/w/index.php?curid=9402369}. +{\label{286335}}% +}} +\end{center} +\end{figure} + +\selectlanguage{english} +\clearpage +\section*{References}\sloppy +\phantomsection +\label{csl:1}Ebert, D. (2013). {The epidemiology and evolution of symbionts with mixed-mode transmission}. \textit{Annual Review of Ecology, Evolution, and Systematics}, \textit{44}(1), 623–643. \url{https://doi.org/10.1146/annurev-ecolsys-032513-100555} + +\end{document} + diff --git a/test/TestDocumentCustomHeader/header.tex b/test/TestDocumentCustomHeader/header.tex new file mode 100644 index 0000000..a98e475 --- /dev/null +++ b/test/TestDocumentCustomHeader/header.tex @@ -0,0 +1,26 @@ +% Edit this header.tex file to include frontmatter definitions and global macros + +% Add here any LaTeX packages you would like to load in all document blocks +% \usepackage{xspace} +\usepackage{authblk} + +\author[1]{Mark Juers} +\affil[1]{Indiana University} +% Add here any LaTeX macros you would like to load in all document blocks +% \def\example{This is an example macro.} + + +% ----- + +\iflatexml +% Add here any LaTeXML-specific commands + +% ----- + +\else +% Add here any export style-specific LaTeX commands. These will only be loaded upon document export. +% \paperfield{Subject domain of my document} +% \keywords{keyword1, keyword2} +% \corraddress{Author One PhD, Department, Institution, City, State or Province, Postal Code, Country} +% \fundinginfo{Funder One, Funder One Department, Grant/Award Number: 123456.} +\fi diff --git a/test/TestDocumentCustomHeader/layout.md b/test/TestDocumentCustomHeader/layout.md new file mode 100644 index 0000000..d441ae2 --- /dev/null +++ b/test/TestDocumentCustomHeader/layout.md @@ -0,0 +1,5 @@ +untitled.html +li1fpi8krbo.html +rtdm09a2c6g.tex +nat261l8ito.html +figures/scatterplot \ No newline at end of file diff --git a/test/TestDocumentCustomHeader/li1fpi8krbo.html b/test/TestDocumentCustomHeader/li1fpi8krbo.html new file mode 100644 index 0000000..ad0251e --- /dev/null +++ b/test/TestDocumentCustomHeader/li1fpi8krbo.html @@ -0,0 +1 @@ +
An inline equation: \(\int_0^xf\left(t\right)\mathrm{d}t\). And a display equation.
\ No newline at end of file diff --git a/test/TestDocumentCustomHeader/nat261l8ito.html b/test/TestDocumentCustomHeader/nat261l8ito.html new file mode 100644 index 0000000..61fe1f8 --- /dev/null +++ b/test/TestDocumentCustomHeader/nat261l8ito.html @@ -0,0 +1 @@ +
Some troublesome dollar signs: $100, $200, $300
\ No newline at end of file diff --git a/test/TestDocumentCustomHeader/preamble.tex b/test/TestDocumentCustomHeader/preamble.tex new file mode 100644 index 0000000..f204761 --- /dev/null +++ b/test/TestDocumentCustomHeader/preamble.tex @@ -0,0 +1 @@ +\documentclass[10pt]{article} diff --git a/test/TestDocumentCustomHeader/rtdm09a2c6g.tex b/test/TestDocumentCustomHeader/rtdm09a2c6g.tex new file mode 100644 index 0000000..328b7ce --- /dev/null +++ b/test/TestDocumentCustomHeader/rtdm09a2c6g.tex @@ -0,0 +1,4 @@ +\begin{equation} +\label{eq:eq1} +\int_0^x f(t) \mathrm{d}t +\end{equation} \ No newline at end of file diff --git a/test/TestDocumentCustomHeader/title.html b/test/TestDocumentCustomHeader/title.html new file mode 100644 index 0000000..0309800 --- /dev/null +++ b/test/TestDocumentCustomHeader/title.html @@ -0,0 +1 @@ +
Test document
\ No newline at end of file diff --git a/test/TestDocumentCustomHeader/untitled.html b/test/TestDocumentCustomHeader/untitled.html new file mode 100644 index 0000000..5f8be20 --- /dev/null +++ b/test/TestDocumentCustomHeader/untitled.html @@ -0,0 +1 @@ +

A heading

Another heading

\cite{ebert_epidemiology_2013}
\citet{ebert_epidemiology_2013}
\citep[see][]{ebert_epidemiology_2013}
Figure \ref{286335}
Eq \ref{eq:eq1}
\ No newline at end of file