File size: 1,376 Bytes
b87d7ee
ec6cde5
b87d7ee
 
d0922dd
b87d7ee
 
 
 
 
 
 
 
 
 
 
 
 
c3271ea
 
 
 
d0922dd
b87d7ee
 
 
 
 
 
 
 
 
 
 
 
1daaaff
 
 
d0922dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1daaaff
d0922dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import yaml
from pathlib import Path

data_file = "papers.yml"
papers_header = Path("stylesheets") / "papers_header.txt"
output_file = "papers.md"

# Load YAML file:
with open(data_file, "r") as stream:
    papers = yaml.load(stream, Loader=yaml.SafeLoader)["papers"]

# Load header:
with open(papers_header, "r") as stream:
    header = stream.read()

with open(output_file, "w") as f:
    f.write(header)

    # First, we sort the papers by date.
    # This is in the format of "2022-03-15"
    papers = sorted(papers, key=lambda paper: paper["date"], reverse=True)

    snippets = []
    for paper in papers:
        title = paper["title"]
        authors = (
            ", ".join(paper["authors"]).replace("(", "<sup>").replace(")", "</sup>")
        )
        affiliations = ", ".join(
            f"<sup>{num}</sup>{affil}" for num, affil in paper["affiliations"].items()
        )
        link = paper["link"]
        abstract = paper["abstract"]
        image_file = paper["image"]

        # Begin:
        paper_snippet = f"""

<figure markdown>
![](images/{image_file}){{ width="500"}}
<figcaption>
<!-- Large font: -->
<h2>
<a href="{link}">{title}</a>
</h2>
</figcaption>
</figure>

<center>
{authors}
    
<small>{affiliations}</small>
</center>

**Abstract:** {abstract}\n\n
"""
        snippets.append(paper_snippet)

    f.write("\n\n---\n\n".join(snippets))