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}'
|
AUTOFILL_TPL = '\\autofill{FIELD}{INFO}'
|
||||||
|
|
||||||
|
|
||||||
@ -9,12 +11,13 @@ def autofill(text, paper):
|
|||||||
for field, info in get_autofill_info(paper):
|
for field, info in get_autofill_info(paper):
|
||||||
text = replace_pattern(text,
|
text = replace_pattern(text,
|
||||||
get_autofill_pattern(field),
|
get_autofill_pattern(field),
|
||||||
info)
|
format_for_latex(info))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def get_autofill_info(paper):
|
def get_autofill_info(paper):
|
||||||
fields = paper.bibentry.fields
|
fields = paper.bibentry.fields
|
||||||
|
tags = paper.tags
|
||||||
info = []
|
info = []
|
||||||
if 'year' in fields:
|
if 'year' in fields:
|
||||||
info.append(('YEAR', fields['year']))
|
info.append(('YEAR', fields['year']))
|
||||||
@ -23,12 +26,13 @@ def get_autofill_info(paper):
|
|||||||
if 'abstract' in fields:
|
if 'abstract' in fields:
|
||||||
info.append(('ABSTRACT', fields['abstract']))
|
info.append(('ABSTRACT', fields['abstract']))
|
||||||
info.append(('AUTHOR', get_author_as_str(paper)))
|
info.append(('AUTHOR', get_author_as_str(paper)))
|
||||||
|
info.append(('TAG', ', '.join(tags)))
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
def find_first_level_delimiter(text, opening='{', closing='}'):
|
def find_first_level_delimiter(text, opening='{', closing='}'):
|
||||||
if opening in text:
|
if opening in text:
|
||||||
match = text.split(opening,1)[1]
|
match = text.split(opening, 1)[1]
|
||||||
cnt = 1
|
cnt = 1
|
||||||
for index in xrange(len(match)):
|
for index in xrange(len(match)):
|
||||||
if match[index] in (opening + closing):
|
if match[index] in (opening + closing):
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
\small{\textsc{\autofill{AUTHOR}{Author(s) not found}}} \\ [0.2cm]
|
\small{\textsc{\autofill{AUTHOR}{Author(s) not found}}} \\ [0.2cm]
|
||||||
\normalsize{\textsc{\autofill{YEAR}{Year not found}}} \\ [1cm]
|
\normalsize{\textsc{\autofill{YEAR}{Year not found}}} \\ [1cm]
|
||||||
\end{center}
|
\end{center}
|
||||||
|
\textbf{Keywords:} \autofill{TAG}{Tags not found}
|
||||||
\begin{abstract}
|
\begin{abstract}
|
||||||
\autofill{ABSTRACT}{Abstract not found}
|
\autofill{ABSTRACT}{Abstract not found}
|
||||||
\end{abstract}
|
\end{abstract}
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .autofill_tools import replace_pattern
|
|
||||||
|
|
||||||
DO_NOT_MODIFY_PATTERN = '%DO_NOT_MODIFY{INFO}'
|
DO_NOT_MODIFY_PATTERN = '%DO_NOT_MODIFY{INFO}'
|
||||||
HEADER_PATTERN = '%HEADER{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):
|
def extract_note(text):
|
||||||
text = replace_pattern(text, DO_NOT_MODIFY_PATTERN, 'INFO')
|
text = replace_pattern(text, DO_NOT_MODIFY_PATTERN, 'INFO')
|
||||||
text = text.replace(DO_NOT_MODIFY_PATTERN, '')
|
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):
|
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)
|
folder, filename = os.path.split(full_path_to_file)
|
||||||
os.chdir(folder)
|
os.chdir(folder)
|
||||||
for _ in xrange(nb_time):
|
for _ in xrange(nb_time):
|
||||||
cmd = command.split()
|
cmd = command.split()
|
||||||
cmd.append(filename)
|
cmd.append(filename)
|
||||||
subprocess.call(cmd, stdout=stdout)
|
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):
|
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):
|
def run_bibtex(full_path_to_file, stdout=None, nb_time=1):
|
||||||
run_command('bibtex', full_path_to_file, stdout, nb_time)
|
run_command('bibtex', full_path_to_file, stdout, nb_time)
|
||||||
|
|
||||||
|
|
||||||
def run_makeglossaries(full_path_to_file, stdout=None, nb_time=1):
|
def run_makeglossaries(full_path_to_file, stdout=None, nb_time=1):
|
||||||
run_command('makeglossaries', full_path_to_file, stdout, nb_time)
|
run_command('makeglossaries', full_path_to_file, stdout, nb_time)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user