-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool taking bibtex file and giving output md rf #401
Conversation
scripts/bib2md.py
Outdated
def main(): | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument('-f', '--file', type=str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be an argument, not an option. If no argument is provided, the script should throw an error and terminate.
scripts/bib2md.py
Outdated
try: | ||
authors = entry['author'].split(' and ') | ||
if len(authors) > 1: | ||
authors[-1] = 'and ' + authors[-1] | ||
|
||
authors_formatted = ', '.join([a.replace('\n', ' ').strip() for a in authors]) | ||
title = entry['title'] | ||
year = int(entry['year']) | ||
venue = entry.get('journal') or entry.get('booktitle') or entry.get('archivePrefix') | ||
|
||
if not venue: | ||
id_unprocessed = "[" + entry.key + " - " + entry.entry_type + "]" | ||
unprocessed_entries.append(id_unprocessed) | ||
continue | ||
|
||
formatted_entries.append((year, f"{authors_formatted}. {title}. {venue.value}. ({year}).")) | ||
|
||
except KeyError as e: | ||
print(f"One or more necessary fields {str(e)} not present in this BibTeX entry.") | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this loop body should be a separate function that takes a single entry as input and returns a string as output.
scripts/bib2md.py
Outdated
parser.add_argument('-ord', '--order', type=str, | ||
choices=['asc', 'desc'], | ||
help='here we set a sort order. We have the choice between "asc" and "desc"', | ||
required=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be required; if not provided, the order should be newest first
scripts/bib2md.py
Outdated
apa_citations = format_simple(bibtex_str, args.order) | ||
for citation in apa_citations: | ||
print() | ||
print(citation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not call this 'apa_citations', these might be formatted differently than APA
output md rf = output markdown reference
output md rf = output markdown reference