commonmeta-ruby 3.7.1 → 3.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish.yml +23 -0
  3. data/Gemfile.lock +26 -26
  4. data/bin/commonmeta +1 -1
  5. data/docs/.gitignore +1 -0
  6. data/docs/_publish.yml +4 -0
  7. data/docs/_quarto.yml +46 -0
  8. data/docs/_site/favicon.ico +0 -0
  9. data/docs/_site/images/icon.png +0 -0
  10. data/docs/_site/index.html +947 -0
  11. data/docs/_site/readers/bibtex_reader.html +802 -0
  12. data/docs/_site/search.json +74 -0
  13. data/docs/_site/site_libs/bootstrap/bootstrap-dark.min.css +9 -0
  14. data/docs/_site/site_libs/bootstrap/bootstrap-icons.css +2078 -0
  15. data/docs/_site/site_libs/bootstrap/bootstrap-icons.woff +0 -0
  16. data/docs/_site/site_libs/bootstrap/bootstrap.min.css +9 -0
  17. data/docs/_site/site_libs/bootstrap/bootstrap.min.js +7 -0
  18. data/docs/_site/site_libs/clipboard/clipboard.min.js +7 -0
  19. data/docs/_site/site_libs/quarto-html/anchor.min.js +9 -0
  20. data/docs/_site/site_libs/quarto-html/popper.min.js +6 -0
  21. data/docs/_site/site_libs/quarto-html/quarto-syntax-highlighting-dark.css +179 -0
  22. data/docs/_site/site_libs/quarto-html/quarto-syntax-highlighting.css +179 -0
  23. data/docs/_site/site_libs/quarto-html/quarto.js +889 -0
  24. data/docs/_site/site_libs/quarto-html/tippy.css +1 -0
  25. data/docs/_site/site_libs/quarto-html/tippy.umd.min.js +2 -0
  26. data/docs/_site/site_libs/quarto-nav/headroom.min.js +7 -0
  27. data/docs/_site/site_libs/quarto-nav/quarto-nav.js +288 -0
  28. data/docs/_site/site_libs/quarto-search/autocomplete.umd.js +3 -0
  29. data/docs/_site/site_libs/quarto-search/fuse.min.js +9 -0
  30. data/docs/_site/site_libs/quarto-search/quarto-search.js +1241 -0
  31. data/docs/_site/utils/doi_utils.html +787 -0
  32. data/docs/_site/writers/bibtex_writer.html +803 -0
  33. data/docs/favicon.ico +0 -0
  34. data/docs/images/icon.png +0 -0
  35. data/docs/index.qmd +83 -0
  36. data/docs/readers/bibtex_reader.ipynb +37 -0
  37. data/docs/theme.scss +7 -0
  38. data/docs/utils/doi_utils.ipynb +28 -0
  39. data/docs/writers/bibtex_writer.ipynb +39 -0
  40. data/lib/commonmeta/cli.rb +8 -8
  41. data/lib/commonmeta/readers/json_feed_reader.rb +6 -6
  42. data/lib/commonmeta/utils.rb +2 -2
  43. data/lib/commonmeta/version.rb +1 -1
  44. data/spec/cli_spec.rb +5 -5
  45. data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/json_feed_blog_slug.yml +71 -0
  46. data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/json_feed_updated.yml +186 -0
  47. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/updated_posts.yml +186 -0
  48. data/spec/readers/json_feed_reader_spec.rb +5 -5
  49. metadata +42 -5
  50. data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/json_feed_not_indexed.yml +0 -37
  51. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/not_indexed_posts.yml +0 -37
@@ -0,0 +1,803 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
3
+
4
+ <meta charset="utf-8">
5
+ <meta name="generator" content="quarto-1.4.504">
6
+
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
8
+
9
+ <meta name="description" content="This notebook shows how to generate BibTex metadata from a scholarly resource in commonmeta format generated by commonmeta-ruby.">
10
+
11
+ <title>commonmeta-ruby - BibTex Writer</title>
12
+ <style>
13
+ code{white-space: pre-wrap;}
14
+ span.smallcaps{font-variant: small-caps;}
15
+ div.columns{display: flex; gap: min(4vw, 1.5em);}
16
+ div.column{flex: auto; overflow-x: auto;}
17
+ div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
18
+ ul.task-list{list-style: none;}
19
+ ul.task-list li input[type="checkbox"] {
20
+ width: 0.8em;
21
+ margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
22
+ vertical-align: middle;
23
+ }
24
+ </style>
25
+
26
+
27
+ <script src="../site_libs/quarto-nav/quarto-nav.js"></script>
28
+ <script src="../site_libs/quarto-nav/headroom.min.js"></script>
29
+ <script src="../site_libs/clipboard/clipboard.min.js"></script>
30
+ <script src="../site_libs/quarto-search/autocomplete.umd.js"></script>
31
+ <script src="../site_libs/quarto-search/fuse.min.js"></script>
32
+ <script src="../site_libs/quarto-search/quarto-search.js"></script>
33
+ <meta name="quarto:offset" content="../">
34
+ <link href="../favicon.ico" rel="icon">
35
+ <script src="../site_libs/quarto-html/quarto.js"></script>
36
+ <script src="../site_libs/quarto-html/popper.min.js"></script>
37
+ <script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
38
+ <script src="../site_libs/quarto-html/anchor.min.js"></script>
39
+ <link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">
40
+ <link href="../site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-text-highlighting-styles">
41
+ <link href="../site_libs/quarto-html/quarto-syntax-highlighting-dark.css" rel="prefetch" class="quarto-color-scheme quarto-color-alternate" id="quarto-text-highlighting-styles">
42
+ <script src="../site_libs/bootstrap/bootstrap.min.js"></script>
43
+ <link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
44
+ <link href="../site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-bootstrap" data-mode="light">
45
+ <link href="../site_libs/bootstrap/bootstrap-dark.min.css" rel="prefetch" class="quarto-color-scheme quarto-color-alternate" id="quarto-bootstrap" data-mode="dark">
46
+ <script id="quarto-search-options" type="application/json">{
47
+ "location": "navbar",
48
+ "copy-button": false,
49
+ "collapse-after": 3,
50
+ "panel-placement": "end",
51
+ "type": "overlay",
52
+ "limit": 50,
53
+ "keyboard-shortcut": [
54
+ "f",
55
+ "/",
56
+ "s"
57
+ ],
58
+ "show-item-context": false,
59
+ "language": {
60
+ "search-no-results-text": "No results",
61
+ "search-matching-documents-text": "matching documents",
62
+ "search-copy-link-title": "Copy link to search",
63
+ "search-hide-matches-text": "Hide additional matches",
64
+ "search-more-match-text": "more match in this document",
65
+ "search-more-matches-text": "more matches in this document",
66
+ "search-clear-button-title": "Clear",
67
+ "search-detached-cancel-button-title": "Cancel",
68
+ "search-submit-button-title": "Submit",
69
+ "search-label": "Search"
70
+ }
71
+ }</script>
72
+
73
+
74
+ </head>
75
+
76
+ <body class="nav-sidebar floating nav-fixed">
77
+
78
+ <div id="quarto-search-results"></div>
79
+ <header id="quarto-header" class="headroom fixed-top">
80
+ <nav class="navbar navbar-expand-lg " data-bs-theme="dark">
81
+ <div class="navbar-container container-fluid">
82
+ <div class="navbar-brand-container mx-auto">
83
+ <a href="../index.html" class="navbar-brand navbar-brand-logo">
84
+ <img src="../images/icon.png" alt="commonmeta-py" class="navbar-logo">
85
+ </a>
86
+ <a class="navbar-brand" href="../index.html">
87
+ <span class="navbar-title">commonmeta-ruby</span>
88
+ </a>
89
+ </div>
90
+ <div id="quarto-search" class="" title="Search"></div>
91
+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
92
+ <span class="navbar-toggler-icon"></span>
93
+ </button>
94
+ <div class="collapse navbar-collapse" id="navbarCollapse">
95
+ <ul class="navbar-nav navbar-nav-scroll ms-auto">
96
+ <li class="nav-item compact">
97
+ <a class="nav-link" href="https://github.com/front-matter/commonmeta-ruby"> <i class="bi bi-github" role="img">
98
+ </i>
99
+ <span class="menu-text"></span></a>
100
+ </li>
101
+ </ul>
102
+ </div> <!-- /navcollapse -->
103
+ <div class="quarto-navbar-tools">
104
+ <a href="" class="quarto-color-scheme-toggle quarto-navigation-tool px-1" onclick="window.quartoToggleColorScheme(); return false;" title="Toggle dark mode"><i class="bi"></i></a>
105
+ </div>
106
+ </div> <!-- /container-fluid -->
107
+ </nav>
108
+ <nav class="quarto-secondary-nav">
109
+ <div class="container-fluid d-flex">
110
+ <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
111
+ <i class="bi bi-layout-text-sidebar-reverse"></i>
112
+ </button>
113
+ <a class="flex-grow-1 no-decor" role="button" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
114
+ <h1 class="quarto-secondary-nav-title">BibTex Writer</h1>
115
+ </a>
116
+ </div>
117
+ </nav>
118
+ </header>
119
+ <!-- content -->
120
+ <div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
121
+ <!-- sidebar -->
122
+ <nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
123
+ <div class="sidebar-menu-container">
124
+ <ul class="list-unstyled mt-1">
125
+ <li class="sidebar-item">
126
+ <div class="sidebar-item-container">
127
+ <a href="../index.html" class="sidebar-item-text sidebar-link">
128
+ <span class="menu-text">Guide</span></a>
129
+ </div>
130
+ </li>
131
+ <li class="sidebar-item sidebar-item-section">
132
+ <div class="sidebar-item-container">
133
+ <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true">
134
+ <span class="menu-text">Readers</span></a>
135
+ <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" aria-expanded="true" aria-label="Toggle section">
136
+ <i class="bi bi-chevron-right ms-2"></i>
137
+ </a>
138
+ </div>
139
+ <ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show">
140
+ <li class="sidebar-item">
141
+ <div class="sidebar-item-container">
142
+ <a href="../readers/bibtex_reader.html" class="sidebar-item-text sidebar-link">
143
+ <span class="menu-text">BibTex Reader</span></a>
144
+ </div>
145
+ </li>
146
+ </ul>
147
+ </li>
148
+ <li class="sidebar-item sidebar-item-section">
149
+ <div class="sidebar-item-container">
150
+ <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true">
151
+ <span class="menu-text">Writers</span></a>
152
+ <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" aria-expanded="true" aria-label="Toggle section">
153
+ <i class="bi bi-chevron-right ms-2"></i>
154
+ </a>
155
+ </div>
156
+ <ul id="quarto-sidebar-section-2" class="collapse list-unstyled sidebar-section depth1 show">
157
+ <li class="sidebar-item">
158
+ <div class="sidebar-item-container">
159
+ <a href="../writers/bibtex_writer.html" class="sidebar-item-text sidebar-link active">
160
+ <span class="menu-text">BibTex Writer</span></a>
161
+ </div>
162
+ </li>
163
+ </ul>
164
+ </li>
165
+ <li class="sidebar-item sidebar-item-section">
166
+ <div class="sidebar-item-container">
167
+ <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="true">
168
+ <span class="menu-text">Utils</span></a>
169
+ <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" aria-expanded="true" aria-label="Toggle section">
170
+ <i class="bi bi-chevron-right ms-2"></i>
171
+ </a>
172
+ </div>
173
+ <ul id="quarto-sidebar-section-3" class="collapse list-unstyled sidebar-section depth1 show">
174
+ <li class="sidebar-item">
175
+ <div class="sidebar-item-container">
176
+ <a href="../utils/doi_utils.html" class="sidebar-item-text sidebar-link">
177
+ <span class="menu-text">doi_utils</span></a>
178
+ </div>
179
+ </li>
180
+ </ul>
181
+ </li>
182
+ </ul>
183
+ </div>
184
+ </nav>
185
+ <div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
186
+ <!-- margin-sidebar -->
187
+ <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
188
+ <nav id="TOC" role="doc-toc" class="toc-active">
189
+ <h2 id="toc-title">On this page</h2>
190
+
191
+ <ul>
192
+ <li><a href="#fetch-the-metadata" id="toc-fetch-the-metadata" class="nav-link active" data-scroll-target="#fetch-the-metadata">Fetch the metadata</a></li>
193
+ </ul>
194
+ </nav>
195
+ </div>
196
+ <!-- main -->
197
+ <main class="content" id="quarto-document-content">
198
+
199
+ <header id="title-block-header" class="quarto-title-block default">
200
+ <div class="quarto-title">
201
+ <h1 class="title d-none d-lg-block">BibTex Writer</h1>
202
+ </div>
203
+
204
+ <div>
205
+ <div class="description">
206
+ <p>This notebook shows how to generate BibTex metadata from a scholarly resource in commonmeta format generated by commonmeta-ruby.</p>
207
+ </div>
208
+ </div>
209
+
210
+
211
+ <div class="quarto-title-meta">
212
+
213
+
214
+
215
+
216
+ </div>
217
+
218
+
219
+
220
+ </header>
221
+
222
+
223
+ <section id="fetch-the-metadata" class="level2">
224
+ <h2 class="anchored" data-anchor-id="fetch-the-metadata">Fetch the metadata</h2>
225
+ <p>As with all commonmeta-ruby notebooks, we start by fetching metadata, in this example a journal article via its Crossref DOI, and then convert it to the commonmeta format.</p>
226
+
227
+
228
+ </section>
229
+
230
+ </main> <!-- /main -->
231
+ <script id="quarto-html-after-body" type="application/javascript">
232
+ window.document.addEventListener("DOMContentLoaded", function (event) {
233
+ const toggleBodyColorMode = (bsSheetEl) => {
234
+ const mode = bsSheetEl.getAttribute("data-mode");
235
+ const bodyEl = window.document.querySelector("body");
236
+ if (mode === "dark") {
237
+ bodyEl.classList.add("quarto-dark");
238
+ bodyEl.classList.remove("quarto-light");
239
+ } else {
240
+ bodyEl.classList.add("quarto-light");
241
+ bodyEl.classList.remove("quarto-dark");
242
+ }
243
+ }
244
+ const toggleBodyColorPrimary = () => {
245
+ const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
246
+ if (bsSheetEl) {
247
+ toggleBodyColorMode(bsSheetEl);
248
+ }
249
+ }
250
+ toggleBodyColorPrimary();
251
+ const disableStylesheet = (stylesheets) => {
252
+ for (let i=0; i < stylesheets.length; i++) {
253
+ const stylesheet = stylesheets[i];
254
+ stylesheet.rel = 'prefetch';
255
+ }
256
+ }
257
+ const enableStylesheet = (stylesheets) => {
258
+ for (let i=0; i < stylesheets.length; i++) {
259
+ const stylesheet = stylesheets[i];
260
+ stylesheet.rel = 'stylesheet';
261
+ }
262
+ }
263
+ const manageTransitions = (selector, allowTransitions) => {
264
+ const els = window.document.querySelectorAll(selector);
265
+ for (let i=0; i < els.length; i++) {
266
+ const el = els[i];
267
+ if (allowTransitions) {
268
+ el.classList.remove('notransition');
269
+ } else {
270
+ el.classList.add('notransition');
271
+ }
272
+ }
273
+ }
274
+ const toggleGiscusIfUsed = (isAlternate, darkModeDefault) => {
275
+ const baseTheme = document.querySelector('#giscus-base-theme')?.value ?? 'light';
276
+ const alternateTheme = document.querySelector('#giscus-alt-theme')?.value ?? 'dark';
277
+ let newTheme = '';
278
+ if(darkModeDefault) {
279
+ newTheme = isAlternate ? baseTheme : alternateTheme;
280
+ } else {
281
+ newTheme = isAlternate ? alternateTheme : baseTheme;
282
+ }
283
+ const changeGiscusTheme = () => {
284
+ // From: https://github.com/giscus/giscus/issues/336
285
+ const sendMessage = (message) => {
286
+ const iframe = document.querySelector('iframe.giscus-frame');
287
+ if (!iframe) return;
288
+ iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app');
289
+ }
290
+ sendMessage({
291
+ setConfig: {
292
+ theme: newTheme
293
+ }
294
+ });
295
+ }
296
+ const isGiscussLoaded = window.document.querySelector('iframe.giscus-frame') !== null;
297
+ if (isGiscussLoaded) {
298
+ changeGiscusTheme();
299
+ }
300
+ }
301
+ const toggleColorMode = (alternate) => {
302
+ // Switch the stylesheets
303
+ const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate');
304
+ manageTransitions('#quarto-margin-sidebar .nav-link', false);
305
+ if (alternate) {
306
+ enableStylesheet(alternateStylesheets);
307
+ for (const sheetNode of alternateStylesheets) {
308
+ if (sheetNode.id === "quarto-bootstrap") {
309
+ toggleBodyColorMode(sheetNode);
310
+ }
311
+ }
312
+ } else {
313
+ disableStylesheet(alternateStylesheets);
314
+ toggleBodyColorPrimary();
315
+ }
316
+ manageTransitions('#quarto-margin-sidebar .nav-link', true);
317
+ // Switch the toggles
318
+ const toggles = window.document.querySelectorAll('.quarto-color-scheme-toggle');
319
+ for (let i=0; i < toggles.length; i++) {
320
+ const toggle = toggles[i];
321
+ if (toggle) {
322
+ if (alternate) {
323
+ toggle.classList.add("alternate");
324
+ } else {
325
+ toggle.classList.remove("alternate");
326
+ }
327
+ }
328
+ }
329
+ // Hack to workaround the fact that safari doesn't
330
+ // properly recolor the scrollbar when toggling (#1455)
331
+ if (navigator.userAgent.indexOf('Safari') > 0 && navigator.userAgent.indexOf('Chrome') == -1) {
332
+ manageTransitions("body", false);
333
+ window.scrollTo(0, 1);
334
+ setTimeout(() => {
335
+ window.scrollTo(0, 0);
336
+ manageTransitions("body", true);
337
+ }, 40);
338
+ }
339
+ }
340
+ const isFileUrl = () => {
341
+ return window.location.protocol === 'file:';
342
+ }
343
+ const hasAlternateSentinel = () => {
344
+ let styleSentinel = getColorSchemeSentinel();
345
+ if (styleSentinel !== null) {
346
+ return styleSentinel === "alternate";
347
+ } else {
348
+ return false;
349
+ }
350
+ }
351
+ const setStyleSentinel = (alternate) => {
352
+ const value = alternate ? "alternate" : "default";
353
+ if (!isFileUrl()) {
354
+ window.localStorage.setItem("quarto-color-scheme", value);
355
+ } else {
356
+ localAlternateSentinel = value;
357
+ }
358
+ }
359
+ const getColorSchemeSentinel = () => {
360
+ if (!isFileUrl()) {
361
+ const storageValue = window.localStorage.getItem("quarto-color-scheme");
362
+ return storageValue != null ? storageValue : localAlternateSentinel;
363
+ } else {
364
+ return localAlternateSentinel;
365
+ }
366
+ }
367
+ const darkModeDefault = false;
368
+ let localAlternateSentinel = darkModeDefault ? 'alternate' : 'default';
369
+ // Dark / light mode switch
370
+ window.quartoToggleColorScheme = () => {
371
+ // Read the current dark / light value
372
+ let toAlternate = !hasAlternateSentinel();
373
+ toggleColorMode(toAlternate);
374
+ setStyleSentinel(toAlternate);
375
+ toggleGiscusIfUsed(toAlternate, darkModeDefault);
376
+ };
377
+ // Ensure there is a toggle, if there isn't float one in the top right
378
+ if (window.document.querySelector('.quarto-color-scheme-toggle') === null) {
379
+ const a = window.document.createElement('a');
380
+ a.classList.add('top-right');
381
+ a.classList.add('quarto-color-scheme-toggle');
382
+ a.href = "";
383
+ a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; };
384
+ const i = window.document.createElement("i");
385
+ i.classList.add('bi');
386
+ a.appendChild(i);
387
+ window.document.body.appendChild(a);
388
+ }
389
+ // Switch to dark mode if need be
390
+ if (hasAlternateSentinel()) {
391
+ toggleColorMode(true);
392
+ } else {
393
+ toggleColorMode(false);
394
+ }
395
+ const icon = "";
396
+ const anchorJS = new window.AnchorJS();
397
+ anchorJS.options = {
398
+ placement: 'right',
399
+ icon: icon
400
+ };
401
+ anchorJS.add('.anchored');
402
+ const isCodeAnnotation = (el) => {
403
+ for (const clz of el.classList) {
404
+ if (clz.startsWith('code-annotation-')) {
405
+ return true;
406
+ }
407
+ }
408
+ return false;
409
+ }
410
+ const clipboard = new window.ClipboardJS('.code-copy-button', {
411
+ text: function(trigger) {
412
+ const codeEl = trigger.previousElementSibling.cloneNode(true);
413
+ for (const childEl of codeEl.children) {
414
+ if (isCodeAnnotation(childEl)) {
415
+ childEl.remove();
416
+ }
417
+ }
418
+ return codeEl.innerText;
419
+ }
420
+ });
421
+ clipboard.on('success', function(e) {
422
+ // button target
423
+ const button = e.trigger;
424
+ // don't keep focus
425
+ button.blur();
426
+ // flash "checked"
427
+ button.classList.add('code-copy-button-checked');
428
+ var currentTitle = button.getAttribute("title");
429
+ button.setAttribute("title", "Copied!");
430
+ let tooltip;
431
+ if (window.bootstrap) {
432
+ button.setAttribute("data-bs-toggle", "tooltip");
433
+ button.setAttribute("data-bs-placement", "left");
434
+ button.setAttribute("data-bs-title", "Copied!");
435
+ tooltip = new bootstrap.Tooltip(button,
436
+ { trigger: "manual",
437
+ customClass: "code-copy-button-tooltip",
438
+ offset: [0, -8]});
439
+ tooltip.show();
440
+ }
441
+ setTimeout(function() {
442
+ if (tooltip) {
443
+ tooltip.hide();
444
+ button.removeAttribute("data-bs-title");
445
+ button.removeAttribute("data-bs-toggle");
446
+ button.removeAttribute("data-bs-placement");
447
+ }
448
+ button.setAttribute("title", currentTitle);
449
+ button.classList.remove('code-copy-button-checked');
450
+ }, 1000);
451
+ // clear code selection
452
+ e.clearSelection();
453
+ });
454
+ function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
455
+ const config = {
456
+ allowHTML: true,
457
+ maxWidth: 500,
458
+ delay: 100,
459
+ arrow: false,
460
+ appendTo: function(el) {
461
+ return el.parentElement;
462
+ },
463
+ interactive: true,
464
+ interactiveBorder: 10,
465
+ theme: 'quarto',
466
+ placement: 'bottom-start',
467
+ };
468
+ if (contentFn) {
469
+ config.content = contentFn;
470
+ }
471
+ if (onTriggerFn) {
472
+ config.onTrigger = onTriggerFn;
473
+ }
474
+ if (onUntriggerFn) {
475
+ config.onUntrigger = onUntriggerFn;
476
+ }
477
+ window.tippy(el, config);
478
+ }
479
+ const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
480
+ for (var i=0; i<noterefs.length; i++) {
481
+ const ref = noterefs[i];
482
+ tippyHover(ref, function() {
483
+ // use id or data attribute instead here
484
+ let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
485
+ try { href = new URL(href).hash; } catch {}
486
+ const id = href.replace(/^#\/?/, "");
487
+ const note = window.document.getElementById(id);
488
+ return note.innerHTML;
489
+ });
490
+ }
491
+ const xrefs = window.document.querySelectorAll('a.quarto-xref');
492
+ const processXRef = (id, note) => {
493
+ // Strip column container classes
494
+ const stripColumnClz = (el) => {
495
+ el.classList.remove("page-full", "page-columns");
496
+ if (el.children) {
497
+ for (const child of el.children) {
498
+ stripColumnClz(child);
499
+ }
500
+ }
501
+ }
502
+ stripColumnClz(note)
503
+ const typesetMath = (el) => {
504
+ if (window.MathJax) {
505
+ // MathJax Typeset
506
+ window.MathJax.typeset([el]);
507
+ } else if (window.katex) {
508
+ // KaTeX Render
509
+ var mathElements = el.getElementsByClassName("math");
510
+ var macros = [];
511
+ for (var i = 0; i < mathElements.length; i++) {
512
+ var texText = mathElements[i].firstChild;
513
+ if (mathElements[i].tagName == "SPAN") {
514
+ window.katex.render(texText.data, mathElements[i], {
515
+ displayMode: mathElements[i].classList.contains('display'),
516
+ throwOnError: false,
517
+ macros: macros,
518
+ fleqn: false
519
+ });
520
+ }
521
+ }
522
+ }
523
+ }
524
+ if (id === null || id.startsWith('sec-')) {
525
+ // Special case sections, only their first couple elements
526
+ const container = document.createElement("div");
527
+ if (note.children && note.children.length > 2) {
528
+ container.appendChild(note.children[0].cloneNode(true));
529
+ for (let i = 1; i < note.children.length; i++) {
530
+ const child = note.children[i];
531
+ if (child.tagName === "P" && child.innerText === "") {
532
+ continue;
533
+ } else {
534
+ container.appendChild(child.cloneNode(true));
535
+ break;
536
+ }
537
+ }
538
+ typesetMath(container);
539
+ return container.innerHTML
540
+ } else {
541
+ typesetMath(note);
542
+ return note.innerHTML;
543
+ }
544
+ } else {
545
+ // Remove any anchor links if they are present
546
+ const anchorLink = note.querySelector('a.anchorjs-link');
547
+ if (anchorLink) {
548
+ anchorLink.remove();
549
+ }
550
+ typesetMath(note);
551
+ return note.innerHTML;
552
+ }
553
+ }
554
+ for (var i=0; i<xrefs.length; i++) {
555
+ const xref = xrefs[i];
556
+ tippyHover(xref, undefined, function(instance) {
557
+ instance.disable();
558
+ let url = xref.getAttribute('href');
559
+ let hash = undefined;
560
+ if (url.startsWith('#')) {
561
+ hash = url;
562
+ } else {
563
+ try { hash = new URL(url).hash; } catch {}
564
+ }
565
+ if (hash) {
566
+ const id = hash.replace(/^#\/?/, "");
567
+ const note = window.document.getElementById(id);
568
+ if (note !== null) {
569
+ try {
570
+ const html = processXRef(id, note.cloneNode(true));
571
+ instance.setContent(html);
572
+ } finally {
573
+ instance.enable();
574
+ instance.show();
575
+ }
576
+ } else {
577
+ // See if we can fetch this
578
+ fetch(url.split('#')[0])
579
+ .then(res => res.text())
580
+ .then(html => {
581
+ const parser = new DOMParser();
582
+ const htmlDoc = parser.parseFromString(html, "text/html");
583
+ const note = htmlDoc.getElementById(id);
584
+ if (note !== null) {
585
+ const html = processXRef(id, note);
586
+ instance.setContent(html);
587
+ }
588
+ }).finally(() => {
589
+ instance.enable();
590
+ instance.show();
591
+ });
592
+ }
593
+ } else {
594
+ // See if we can fetch a full url (with no hash to target)
595
+ // This is a special case and we should probably do some content thinning / targeting
596
+ fetch(url)
597
+ .then(res => res.text())
598
+ .then(html => {
599
+ const parser = new DOMParser();
600
+ const htmlDoc = parser.parseFromString(html, "text/html");
601
+ const note = htmlDoc.querySelector('main.content');
602
+ if (note !== null) {
603
+ // This should only happen for chapter cross references
604
+ // (since there is no id in the URL)
605
+ // remove the first header
606
+ if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
607
+ note.children[0].remove();
608
+ }
609
+ const html = processXRef(null, note);
610
+ instance.setContent(html);
611
+ }
612
+ }).finally(() => {
613
+ instance.enable();
614
+ instance.show();
615
+ });
616
+ }
617
+ }, function(instance) {
618
+ });
619
+ }
620
+ let selectedAnnoteEl;
621
+ const selectorForAnnotation = ( cell, annotation) => {
622
+ let cellAttr = 'data-code-cell="' + cell + '"';
623
+ let lineAttr = 'data-code-annotation="' + annotation + '"';
624
+ const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
625
+ return selector;
626
+ }
627
+ const selectCodeLines = (annoteEl) => {
628
+ const doc = window.document;
629
+ const targetCell = annoteEl.getAttribute("data-target-cell");
630
+ const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
631
+ const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
632
+ const lines = annoteSpan.getAttribute("data-code-lines").split(",");
633
+ const lineIds = lines.map((line) => {
634
+ return targetCell + "-" + line;
635
+ })
636
+ let top = null;
637
+ let height = null;
638
+ let parent = null;
639
+ if (lineIds.length > 0) {
640
+ //compute the position of the single el (top and bottom and make a div)
641
+ const el = window.document.getElementById(lineIds[0]);
642
+ top = el.offsetTop;
643
+ height = el.offsetHeight;
644
+ parent = el.parentElement.parentElement;
645
+ if (lineIds.length > 1) {
646
+ const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
647
+ const bottom = lastEl.offsetTop + lastEl.offsetHeight;
648
+ height = bottom - top;
649
+ }
650
+ if (top !== null && height !== null && parent !== null) {
651
+ // cook up a div (if necessary) and position it
652
+ let div = window.document.getElementById("code-annotation-line-highlight");
653
+ if (div === null) {
654
+ div = window.document.createElement("div");
655
+ div.setAttribute("id", "code-annotation-line-highlight");
656
+ div.style.position = 'absolute';
657
+ parent.appendChild(div);
658
+ }
659
+ div.style.top = top - 2 + "px";
660
+ div.style.height = height + 4 + "px";
661
+ div.style.left = 0;
662
+ let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
663
+ if (gutterDiv === null) {
664
+ gutterDiv = window.document.createElement("div");
665
+ gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
666
+ gutterDiv.style.position = 'absolute';
667
+ const codeCell = window.document.getElementById(targetCell);
668
+ const gutter = codeCell.querySelector('.code-annotation-gutter');
669
+ gutter.appendChild(gutterDiv);
670
+ }
671
+ gutterDiv.style.top = top - 2 + "px";
672
+ gutterDiv.style.height = height + 4 + "px";
673
+ }
674
+ selectedAnnoteEl = annoteEl;
675
+ }
676
+ };
677
+ const unselectCodeLines = () => {
678
+ const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
679
+ elementsIds.forEach((elId) => {
680
+ const div = window.document.getElementById(elId);
681
+ if (div) {
682
+ div.remove();
683
+ }
684
+ });
685
+ selectedAnnoteEl = undefined;
686
+ };
687
+ // Handle positioning of the toggle
688
+ window.addEventListener(
689
+ "resize",
690
+ throttle(() => {
691
+ elRect = undefined;
692
+ if (selectedAnnoteEl) {
693
+ selectCodeLines(selectedAnnoteEl);
694
+ }
695
+ }, 10)
696
+ );
697
+ function throttle(fn, ms) {
698
+ let throttle = false;
699
+ let timer;
700
+ return (...args) => {
701
+ if(!throttle) { // first call gets through
702
+ fn.apply(this, args);
703
+ throttle = true;
704
+ } else { // all the others get throttled
705
+ if(timer) clearTimeout(timer); // cancel #2
706
+ timer = setTimeout(() => {
707
+ fn.apply(this, args);
708
+ timer = throttle = false;
709
+ }, ms);
710
+ }
711
+ };
712
+ }
713
+ // Attach click handler to the DT
714
+ const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
715
+ for (const annoteDlNode of annoteDls) {
716
+ annoteDlNode.addEventListener('click', (event) => {
717
+ const clickedEl = event.target;
718
+ if (clickedEl !== selectedAnnoteEl) {
719
+ unselectCodeLines();
720
+ const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
721
+ if (activeEl) {
722
+ activeEl.classList.remove('code-annotation-active');
723
+ }
724
+ selectCodeLines(clickedEl);
725
+ clickedEl.classList.add('code-annotation-active');
726
+ } else {
727
+ // Unselect the line
728
+ unselectCodeLines();
729
+ clickedEl.classList.remove('code-annotation-active');
730
+ }
731
+ });
732
+ }
733
+ const findCites = (el) => {
734
+ const parentEl = el.parentElement;
735
+ if (parentEl) {
736
+ const cites = parentEl.dataset.cites;
737
+ if (cites) {
738
+ return {
739
+ el,
740
+ cites: cites.split(' ')
741
+ };
742
+ } else {
743
+ return findCites(el.parentElement)
744
+ }
745
+ } else {
746
+ return undefined;
747
+ }
748
+ };
749
+ var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
750
+ for (var i=0; i<bibliorefs.length; i++) {
751
+ const ref = bibliorefs[i];
752
+ const citeInfo = findCites(ref);
753
+ if (citeInfo) {
754
+ tippyHover(citeInfo.el, function() {
755
+ var popup = window.document.createElement('div');
756
+ citeInfo.cites.forEach(function(cite) {
757
+ var citeDiv = window.document.createElement('div');
758
+ citeDiv.classList.add('hanging-indent');
759
+ citeDiv.classList.add('csl-entry');
760
+ var biblioDiv = window.document.getElementById('ref-' + cite);
761
+ if (biblioDiv) {
762
+ citeDiv.innerHTML = biblioDiv.innerHTML;
763
+ }
764
+ popup.appendChild(citeDiv);
765
+ });
766
+ return popup.innerHTML;
767
+ });
768
+ }
769
+ }
770
+ });
771
+ </script>
772
+ </div> <!-- /content -->
773
+ <footer class="footer">
774
+ <div class="nav-footer">
775
+ <div class="nav-footer-left">
776
+ <p>Copyright ©2023 Front Matter.</p>
777
+ </div>
778
+ <div class="nav-footer-center">
779
+ &nbsp;
780
+ </div>
781
+ <div class="nav-footer-right">
782
+ <ul class="footer-items list-unstyled">
783
+ <li class="nav-item compact">
784
+ <a class="nav-link" href="mailto:info@front-matter.io">
785
+ <i class="bi bi-envelope" role="img">
786
+ </i>
787
+ </a>
788
+ </li>
789
+ <li class="nav-item compact">
790
+ <a class="nav-link" href="https://rogue-scholar.social/@admin">
791
+ <i class="bi bi-mastodon" role="img">
792
+ </i>
793
+ </a>
794
+ </li>
795
+ </ul>
796
+ </div>
797
+ </div>
798
+ </footer>
799
+
800
+
801
+
802
+
803
+ </body></html>