Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ docs/_build/

# PyBuilder
target/

# Ignore vim swap files
*.swp
10 changes: 8 additions & 2 deletions local_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

\begin{{document}}

{authorcontent}

{titlecontent}

{sectioninputs}
Expand Down Expand Up @@ -168,6 +170,10 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname,
titlestr = f.read()
titlecontent.append(r'\title{' + titlestr + '}')

authorcontent = ""
with open(os.path.join(localdir, 'authors.tex')) as f:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this: why are you opening the file? It should be sufficient just to do the get_input_string line below, as then LaTeX will drop the content in there instead of you needing to access the file.

So perhaps instead you want this to be if os.path.exists(os.path.join(localdir, 'authors.tex')):? Then if the files is present it will be used, but otherwise just the empty string from above will get in?

authorcontent = r'\author{' + get_input_string('authors', get_in_path(localdir, builddir, pathtype)) + '}'

sectioninputs = []
with open(os.path.join(localdir, 'layout.md')) as f:
for l in f:
Expand All @@ -177,8 +183,8 @@ def build_authorea_latex(localdir, builddir, latex_exec, bibtex_exec, outname,
elif ls in ('posttitle.tex', 'title.tex', 'preamble.tex', 'header.tex'):
pass # skip any that have been processed above
elif ls in ('abstract.tex'):
# add abstract to title content
titlecontent.append(r'\begin{abstract}' + get_input_string('abstract', get_in_path(localdir, builddir, pathtype)) + '\end{abstract}')
# add abstract to section input
sectioninputs.append(get_input_string('abstract', get_in_path(localdir, builddir, pathtype)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need to be more careful with this. In at least some situations, authorea articles are not expected to have \begin{abstract} \end{abstract} sections. So maybe the thing to do is to just read the abstract file into a string, and then look through in for the presence of r'\begin{abstract}' and r'\end{abstract}'. If they are present, add it the way you're doing here, but if not, add in the section headers. I think that will address both use cases.

elif ls.endswith('.html') or ls.endswith('.htm'):
pass # html files aren't latex-able
elif ls.startswith('figures'):
Expand Down