Add autofill keyword in texnote
This commit is contained in:
parent
8524b9d5b8
commit
6b738a3f6c
@ -1,3 +1,5 @@
|
||||
from .latex_tools import format_for_latex
|
||||
|
||||
AUTOFILL_TPL = '\\autofill{FIELD}{INFO}'
|
||||
|
||||
|
||||
@ -9,12 +11,13 @@ def autofill(text, paper):
|
||||
for field, info in get_autofill_info(paper):
|
||||
text = replace_pattern(text,
|
||||
get_autofill_pattern(field),
|
||||
info)
|
||||
format_for_latex(info))
|
||||
return text
|
||||
|
||||
|
||||
def get_autofill_info(paper):
|
||||
fields = paper.bibentry.fields
|
||||
|
||||
tags = paper.tags
|
||||
info = []
|
||||
if 'year' in fields:
|
||||
info.append(('YEAR', fields['year']))
|
||||
@ -23,12 +26,13 @@ def get_autofill_info(paper):
|
||||
if 'abstract' in fields:
|
||||
info.append(('ABSTRACT', fields['abstract']))
|
||||
info.append(('AUTHOR', get_author_as_str(paper)))
|
||||
info.append(('TAG', ', '.join(tags)))
|
||||
return info
|
||||
|
||||
|
||||
def find_first_level_delimiter(text, opening='{', closing='}'):
|
||||
if opening in text:
|
||||
match = text.split(opening,1)[1]
|
||||
match = text.split(opening, 1)[1]
|
||||
cnt = 1
|
||||
for index in xrange(len(match)):
|
||||
if match[index] in (opening + closing):
|
||||
|
@ -15,6 +15,7 @@
|
||||
\small{\textsc{\autofill{AUTHOR}{Author(s) not found}}} \\ [0.2cm]
|
||||
\normalsize{\textsc{\autofill{YEAR}{Year not found}}} \\ [1cm]
|
||||
\end{center}
|
||||
\textbf{Keywords:} \autofill{TAG}{Tags not found}
|
||||
\begin{abstract}
|
||||
\autofill{ABSTRACT}{Abstract not found}
|
||||
\end{abstract}
|
||||
|
@ -1,12 +1,18 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from .autofill_tools import replace_pattern
|
||||
|
||||
DO_NOT_MODIFY_PATTERN = '%DO_NOT_MODIFY{INFO}'
|
||||
HEADER_PATTERN = '%HEADER{INFO}'
|
||||
|
||||
|
||||
def format_for_latex(text):
|
||||
text = text.replace('_', '\_')
|
||||
return text
|
||||
|
||||
from .autofill_tools import replace_pattern
|
||||
|
||||
|
||||
def extract_note(text):
|
||||
text = replace_pattern(text, DO_NOT_MODIFY_PATTERN, 'INFO')
|
||||
text = text.replace(DO_NOT_MODIFY_PATTERN, '')
|
||||
@ -35,14 +41,14 @@ def full_compile(full_path_to_file, verbose=False):
|
||||
|
||||
|
||||
def run_command(command, full_path_to_file, stdout=None, nb_time=1):
|
||||
origWD = os.getcwd() # remember our original working directory
|
||||
origWD = os.getcwd() # remember our original working directory
|
||||
folder, filename = os.path.split(full_path_to_file)
|
||||
os.chdir(folder)
|
||||
for _ in xrange(nb_time):
|
||||
cmd = command.split()
|
||||
cmd.append(filename)
|
||||
subprocess.call(cmd, stdout=stdout)
|
||||
os.chdir(origWD) # get back to our original working directory
|
||||
os.chdir(origWD) # get back to our original working directory
|
||||
|
||||
|
||||
def run_pdflatex(full_path_to_file, stdout=None, nb_time=1):
|
||||
@ -52,5 +58,6 @@ def run_pdflatex(full_path_to_file, stdout=None, nb_time=1):
|
||||
def run_bibtex(full_path_to_file, stdout=None, nb_time=1):
|
||||
run_command('bibtex', full_path_to_file, stdout, nb_time)
|
||||
|
||||
|
||||
def run_makeglossaries(full_path_to_file, stdout=None, nb_time=1):
|
||||
run_command('makeglossaries', full_path_to_file, stdout, nb_time)
|
||||
|
Loading…
x
Reference in New Issue
Block a user