From 09517bca2df51f00abdb214893fb38d3088246a5 Mon Sep 17 00:00:00 2001 From: Tue Herlau <tuhe@dtu.dk> Date: Sun, 5 Sep 2021 00:01:35 +0200 Subject: [PATCH] Citation script fix after port from coursebox --- README.md | 4 ++-- example/output/citations.py | 4 ++-- .../__pycache__/fix_cite.cpython-38.pyc | Bin 2455 -> 2453 bytes src/snipper/fix_cite.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1a34eea..4541d88 100644 --- a/README.md +++ b/README.md @@ -134,10 +134,10 @@ Next, we load the python file containing the reference code and fix all referenc The middle command is a convenience feature: It allows us to specify a special citation command `\nref{..}` which always compiles to `\cite[\ref{...}]{herlau}`. This is useful if e.g. `herlau` is the bibtex key for your lecture notes. The result is as follows: ```python """ - References: [Ber07] Dimitri P. Bertsekas. Dynamic Programming and Optimal Control, Vol. II. Athena Scientific, 3rd edition, 2007. ISBN 1886529302. - [Her21] Tue Herlau. Sequential decision making. (See 02465_Notes.pdf), 2021.""" + [Her21] Tue Herlau. Sequential decision making. (See 02465_Notes.pdf), 2021. +""" def myfun(): #!s """ To solve this exercise, look at eq. (1) in Section 1. diff --git a/example/output/citations.py b/example/output/citations.py index b652b65..7904c3f 100644 --- a/example/output/citations.py +++ b/example/output/citations.py @@ -1,8 +1,8 @@ """ - References: [Ber07] Dimitri P. Bertsekas. Dynamic Programming and Optimal Control, Vol. II. Athena Scientific, 3rd edition, 2007. ISBN 1886529302. - [Her21] Tue Herlau. Sequential decision making. (See 02465_Notes.pdf), 2021.""" + [Her21] Tue Herlau. Sequential decision making. (See 02465_Notes.pdf), 2021. +""" def myfun(): #!s """ To solve this exercise, look at eq. (1) in Section 1. diff --git a/src/snipper/__pycache__/fix_cite.cpython-38.pyc b/src/snipper/__pycache__/fix_cite.cpython-38.pyc index cad506a5c9c777bdec18848256196d71ff5e9d4d..f4f2a6a15da1ceb5b8ad897d8a875183ee0e919c 100644 GIT binary patch delta 89 zcmbO(JXM%Cl$V!_fq{Wx^Bd#Dxf^*evod;2e#m-B`AG@eY=#s@2sxLfhDn^EmZ^lL qhNYP?g(;h50%MWG<U4FOj47K%+3zrNiZJpqiZSvrYEAydF&6-N{TPS< delta 93 zcmbO#JYASKl$V!_fq{V`@r`lf{EfVqSsA@1KV-e6`Kp9%HbV+y4G)Nfu;;SXFo`qN sGL^8@urxEKFlDn$U@UT)e2vX!vl#nLMouY4K1MM{K1Q|4KRD(B0L_sZWdHyG diff --git a/src/snipper/fix_cite.py b/src/snipper/fix_cite.py index 561b5f1..475e44d 100644 --- a/src/snipper/fix_cite.py +++ b/src/snipper/fix_cite.py @@ -63,11 +63,11 @@ def fix_bibtex(lines, bibtex): cpr = "" if not s.startswith(COMMENT): - s = f"{COMMENT}\n{cpr}\n{COMMENT}\n" + s + s = f"{COMMENT}\n{COMMENT}\n" + s if len(all_refs) > 0: i = s.find(COMMENT, s.find(COMMENT)+1) all_refs = [" " + r.strip() for r in all_refs] - s = s[:i] + "References:\n" + "\n".join(all_refs) + s[i:] + s = s[:i] + "References:\n" + "\n".join(all_refs) +"\n"+ s[i:] # s = s.replace(cpr, info['code_copyright']) return s.splitlines() \ No newline at end of file -- GitLab