Skip to content

Commit 4ca7321

Browse files
authored
Merge pull request #10763 from quarto-dev/cc0-licence
2 parents cf0b7d0 + 0b198f9 commit 4ca7321

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

news/changelog-1.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ All changes included in 1.6:
1515
## `html` Format
1616

1717
- Fix `kbd` element styling on dark themes.
18+
- ([#10761](https://github.com/quarto-dev/quarto-cli/issues/10761)): Add support for `licence: CC0` to automatically link to Creative Commons licence [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/).
1819

1920
## `revealjs` Format
2021

src/format/html/format-html-appendix.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const kAppendixCreativeCommonsLic = [
4646
"CC BY-NC-ND",
4747
];
4848

49+
const kAppendixCCZero = "CC0";
50+
4951
const kStylePlain = "plain";
5052
const kStyleDefault = "default";
5153

@@ -455,9 +457,13 @@ function creativeCommonsLicense(
455457
| "CC BY-NC-SA",
456458
version: version || "4.0",
457459
};
458-
} else {
459-
return undefined;
460460
}
461+
} else if (license === kAppendixCCZero) {
462+
// special case for this creative commons license
463+
return {
464+
base: kAppendixCCZero,
465+
version: "1.0",
466+
};
461467
} else {
462468
return undefined;
463469
}
@@ -467,6 +473,14 @@ function creativeCommonsLicense(
467473
}
468474

469475
function creativeCommonsUrl(license: string, lang?: string, version?: string) {
476+
// Special case for CC0 as different URL
477+
if (license === kAppendixCCZero) {
478+
return {
479+
url: `https://creativecommons.org/publicdomain/zero/${version}/`,
480+
text: `CC0 ${version}`,
481+
inlineLink: true,
482+
};
483+
}
470484
const licenseType = license.substring(3);
471485
if (lang && lang !== "en") {
472486
return {

tests/docs/appendix/license.qmd

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
format:
3+
html+zero:
4+
license: "CC0"
5+
html+cc:
6+
license: "CC BY"
7+
html+text:
8+
license: "This work is dedicated to the Public Domain"
9+
html+custom:
10+
license:
11+
text: >
12+
Permission is granted to copy, distribute and/or
13+
modify this document under the terms of the GNU Free
14+
Documentation License, Version 1.3 or any later version
15+
published by the Free Software Foundation; with no
16+
Invariant Sections, no Front-Cover Texts, and no
17+
Back-Cover Texts. A copy of the license is included in
18+
the section entitled "GNU Free Documentation License
19+
type: open-access
20+
url: https://www.gnu.org/licenses/fdl-1.3-standalone.html
21+
_quarto:
22+
tests:
23+
html+zero:
24+
ensureHtmlElements:
25+
- ['a[rel="license"][href="https://creativecommons.org/publicdomain/zero/1.0/"]']
26+
- []
27+
ensureFileRegexMatches:
28+
- ['CC0 1.0']
29+
- []
30+
html+cc:
31+
ensureHtmlElements:
32+
- ['a[rel="license"][href="https://creativecommons.org/licenses/by/4.0/"]']
33+
- []
34+
ensureFileRegexMatches:
35+
- ['CC BY 4.0']
36+
- []
37+
html+text:
38+
ensureHtmlElements:
39+
- ['h2 + div.quarto-appendix-contents']
40+
- []
41+
ensureFileRegexMatches:
42+
- ['This work is dedicated to the Public Domain']
43+
- []
44+
html+custom:
45+
ensureHtmlElements:
46+
- ['a[rel="license"][href="https://www.gnu.org/licenses/fdl-1.3-standalone.html"]']
47+
- []
48+
ensureFileRegexMatches:
49+
- ['GNU Free Documentation License']
50+
- []
51+
---
52+
53+
54+
## Title
55+
56+
This doc will have an appendix part with a licence as a link to the right creative common url

0 commit comments

Comments
 (0)