Add autofill keyword in texnote

main
jgrizou 12 years ago
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,6 +26,7 @@ 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

@ -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, '')
@ -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…
Cancel
Save