From bd9e09cf58c36be835cdf7db87024acdf5de1600 Mon Sep 17 00:00:00 2001 From: Tue Herlau <tuhe@dtu.dk> Date: Sun, 5 Sep 2021 00:00:34 +0200 Subject: [PATCH] Citation script fix after port from coursebox --- README.md | 6 +----- example/output/citations.py | 6 +----- .../__pycache__/fix_cite.cpython-38.pyc | Bin 2467 -> 2455 bytes src/snipper/fix_cite.py | 6 +++--- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e8e0a45..1a34eea 100644 --- a/README.md +++ b/README.md @@ -134,14 +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 """ -{{copyright}} 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 a081fab..b652b65 100644 --- a/example/output/citations.py +++ b/example/output/citations.py @@ -1,12 +1,8 @@ """ -{{copyright}} 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 25fca9463f8b858cdaef0c4b55b0579b45ebbe74..cad506a5c9c777bdec18848256196d71ff5e9d4d 100644 GIT binary patch delta 219 zcmZ21JYASKl$V!_fq{V`@r`lf{EfVqSsA@1KV&_|$T@ihn{lX94buYl5;h3AkTHcv zoM9nTEprNQ3SSFD4T}pyGh;1F4O0q34Rb4#Btr_nI715K0)`rvg^c11HB2?kDGVTS zafVu^8m0vt3mJkLGzBJ`uzR~EGlFb|VkQO#237_JhF}H;hGGc@28MKo8irVbTE-NH z8pZ_-3mL>2CNdSW1T$zdRxv3kXfobnEiNg_ESP+nJ(Q7WvJ%H*7B%J~o5`G<$&5CW Hb2-fblCCfL delta 231 zcmbO(yjYkwl$V!_fq{X+?ul{Y+Ks%ISsDE%KV&_|$UAujn{lLD4buYl5;h3AkTHcv zoM9nTEprNA3V#bj4T}pyGh;1F4O0q34Rb4#BtwdTI715K0)`rvg^VDUI71Cn4RZ<u zNKTxgmZ^qm0mnjyU<OUW$p-A+K2^Nc)yeq<l|`B986~x~$&4U}Krs^o0|N^K14A$a z14FS00|P@kLk&YLPc35#Lk*)i!$hV+mS6@=#wsQSg(6M{28PK8*h86kxh9KoJZ8~i RF0!8dmm`_cdU7JC834$&Gm`)S diff --git a/src/snipper/fix_cite.py b/src/snipper/fix_cite.py index 9c6aadc..561b5f1 100644 --- a/src/snipper/fix_cite.py +++ b/src/snipper/fix_cite.py @@ -61,13 +61,13 @@ def fix_bibtex(lines, bibtex): s = s[:i] + rtxt + s[j+1:] i = i + len(rtxt) - cpr = "{{copyright}}" + cpr = "" if not s.startswith(COMMENT): s = f"{COMMENT}\n{cpr}\n{COMMENT}\n" + s if len(all_refs) > 0: i = s.find(COMMENT, s.find(COMMENT)+1) - all_refs = [" " + r for r in all_refs] - s = s[:i] + "\nReferences:\n" + "\n".join(all_refs) + "\n" + s[i:] + all_refs = [" " + r.strip() for r in all_refs] + s = s[:i] + "References:\n" + "\n".join(all_refs) + s[i:] # s = s.replace(cpr, info['code_copyright']) return s.splitlines() \ No newline at end of file -- GitLab