|
9 | 9 | const edits = (p.editors || '').replace('&', 'AND'); |
10 | 10 | const pages = (p.start_page || '') + (p.end_page ? '--' + p.end_page : ''); |
11 | 11 | const auths = p.authors.map((a) => `${a.last_name}, ${a.first_name}`).join(' AND '); |
12 | | - const type = v.venueType == 'journal' ? 'article' |
13 | | - : v.venueType == 'book' ? 'incollection' |
14 | | - : 'inproceedings'; |
| 12 | + const type = |
| 13 | + v.venueType == 'journal' |
| 14 | + ? 'article' |
| 15 | + : v.venueType == 'book' |
| 16 | + ? 'incollection' |
| 17 | + : 'inproceedings'; |
15 | 18 |
|
16 | 19 | const fields = [ |
17 | 20 | attr('title', escape(p.title)), |
|
28 | 31 | attr('doi', p.doi) |
29 | 32 | ]; |
30 | 33 |
|
31 | | - const id = `${p.year}-${p.web_name}`; |
| 34 | + const id = `${p.year}-${p.web_name}`; |
32 | 35 | return `@${type}{${id},\n${fields.filter((x) => x).join(',\n')}\n}`; |
33 | 36 | } |
34 | 37 |
|
35 | 38 | function attr(name: string, value?: string | number | null) { |
36 | | - return value ? ` ${name} = {${value}}` : ''; |
37 | | - } |
| 39 | + return value ? ` ${name} = {${value}}` : ''; |
| 40 | + } |
38 | 41 |
|
39 | 42 | function escape(str: string = '') { |
40 | 43 | return str |
41 | | - .replace('&', '\\&') |
42 | | - .replace('%', '\\%') |
43 | | - .replace(/\u00E9/, "\\'{e}") |
44 | | - .replace(/\u00C7/, '\\c{C}') |
45 | | - .replace(/\u011F/, '\\u{g}'); |
| 44 | + .replace('&', '\\&') |
| 45 | + .replace('%', '\\%') |
| 46 | + .replace(/\u00E9/, "\\'{e}") |
| 47 | + .replace(/\u00C7/, '\\c{C}') |
| 48 | + .replace(/\u011F/, '\\u{g}'); |
46 | 49 | } |
47 | 50 |
|
48 | | - const bibtex = formatBibtex(paper, venue); |
| 51 | + const bibtex = formatBibtex(paper, venue); |
49 | 52 |
|
50 | | - async function copyBibtex() { |
51 | | - await navigator.clipboard.writeText(bibtex); |
52 | | - alert('Copied BibTeX citation data to clipboard.'); |
53 | | - } |
| 53 | + async function copyBibtex() { |
| 54 | + await navigator.clipboard.writeText(bibtex); |
| 55 | + alert('Copied BibTeX citation data to clipboard.'); |
| 56 | + } |
54 | 57 | </script> |
55 | 58 |
|
56 | 59 | <div class="group relative bg-slate-100 p-2"> |
57 | | - <button |
| 60 | + <button |
58 | 61 | class="absolute top-0.5 right-0.5 p-1 rounded-md text-gray-400 hover:text-gray-600 active:bg-slate-600 active:text-white" |
59 | 62 | title="Copy BibTeX citation" |
60 | 63 | on:click={copyBibtex} |
61 | 64 | > |
62 | | - <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><path d="M2 6C2 5.44772 2.44772 5 3 5H10C10.5523 5 11 5.44772 11 6V13C11 13.5523 10.5523 14 10 14H3C2.44772 14 2 13.5523 2 13V6Z M4 2.00004L12 2.00001C13.1046 2 14 2.89544 14 4.00001V12"></path></svg> |
| 65 | + <svg |
| 66 | + width="16" |
| 67 | + height="16" |
| 68 | + viewBox="0 0 16 16" |
| 69 | + fill="none" |
| 70 | + stroke="currentColor" |
| 71 | + stroke-width="2" |
| 72 | + ><path |
| 73 | + d="M2 6C2 5.44772 2.44772 5 3 5H10C10.5523 5 11 5.44772 11 6V13C11 13.5523 10.5523 14 10 14H3C2.44772 14 2 13.5523 2 13V6Z M4 2.00004L12 2.00001C13.1046 2 14 2.89544 14 4.00001V12" |
| 74 | + ></path></svg |
| 75 | + > |
63 | 76 | </button> |
64 | | - <pre class="font-mono text-xs whitespace-pre-wrap">{bibtex}</pre> |
| 77 | + <pre class="font-mono text-xs whitespace-pre-wrap">{bibtex}</pre> |
65 | 78 | </div> |
0 commit comments