Skip to content

Commit bef5bc9

Browse files
committed
chore(ci): upstream update
1 parent fb69d72 commit bef5bc9

File tree

4 files changed

+15
-40
lines changed

4 files changed

+15
-40
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="apple-mobile-web-app-capable" content="yes" />
6-
<meta name="generator" content="slidesdown 1.2.4" />
6+
<meta name="generator" content="slidesdown 1.2.5" />
77
<link href="https://slidesdown.github.io" rel="canonical" />
88
<meta content="Slidesdown" property="og:title" />
99
<meta content="Presentations at the speed of Markdown" name="description" />

learn.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ <h2>Get your first slideshow up and running in less than 5 minutes.</h2>
138138
</section>
139139
</main>
140140
</div>
141-
<!-- <script -->
142-
<!-- src="https://kit.fontawesome.com/fec85b2437.js" -->
143-
<!-- crossorigin="anonymous" -->
144-
<!-- ></script> -->
145141
<script src="/js/minimal-theme-switcher.js"></script>
146142
<!-- <script -->
147143
<!-- async -->

loader.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ <h1>Open your Slideshow</h1>
9999
</form>
100100
</main>
101101
</header>
102-
<!-- <s lript -->
103-
<!-- src="https://kit.fontawesome.com/fec85b2437.js" -->
104-
<!-- crossorigin="anonymous" -->
105-
<!-- ></script> -->
106102
<script src="/js/minimal-theme-switcher.js"></script>
107103
<!-- <script -->
108104
<!-- async -->

plugin/slidesdown.js

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import DOMPurify from "dompurify";
1616

1717
const DEFAULT_SLIDE_SEPARATOR = "\r?\n---\r?\n",
1818
DEFAULT_NOTES_SEPARATOR = "notes?:",
19-
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = "\\\.element\\\s*?(.+?)$",
20-
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = "\\\.slide:\\\s*?(\\\S.+?)$";
19+
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = "\\\s\\\.element:\\\s*(.+?)$",
20+
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = "\\\s\\\.slide:\\\s*(\\\S.+?)$";
2121

2222
const SCRIPT_END_PLACEHOLDER = "__SCRIPT_END__";
2323

@@ -63,7 +63,7 @@ const SANITIZE = (string) =>
6363
* http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
6464
*/
6565
function addAttributeInElement(node, elementTarget, separator) {
66-
const attrsInNode = new RegExp(separator, "mg");
66+
const attrsInNode = new RegExp(separator, "gm");
6767
const attrsRegex = new RegExp(
6868
// attributes are limited to prevent code injection
6969
"(?:^|\s)(?<attr>class|style|data-[a-z-]+)=(?:\"(?<dval>[^\"]+?)\"|'(?<sval>[^']+?)')",
@@ -72,10 +72,8 @@ function addAttributeInElement(node, elementTarget, separator) {
7272
let matches,
7373
matchesAttrs;
7474
if ((matches = attrsInNode.exec(node.nodeValue)) !== null) {
75-
const classes = matches[1];
76-
node.nodeValue = node.nodeValue.substring(0, matches.index) +
77-
node.nodeValue.substring(attrsInNode.lastIndex);
78-
while ((matchesAttrs = attrsRegex.exec(classes)) !== null) {
75+
const attrs = matches[1];
76+
while ((matchesAttrs = attrsRegex.exec(attrs)) !== null) {
7977
elementTarget.setAttribute(
8078
matchesAttrs.groups.attr,
8179
matchesAttrs.groups.dval || matchesAttrs.groups.sval || "",
@@ -87,8 +85,8 @@ function addAttributeInElement(node, elementTarget, separator) {
8785
}
8886

8987
/**
90-
* Add attributes to the parent element of a text node,
91-
* or the element of an attribute node.
88+
* Recursively add attributes to the parent element of a text node,
89+
* or the section element, depending on the selector.
9290
*/
9391
function addAttributes(
9492
section,
@@ -97,10 +95,11 @@ function addAttributes(
9795
separatorElementAttributes,
9896
separatorSectionAttributes,
9997
) {
100-
if (element?.childNodes && element.childNodes.length > 0) {
98+
if (element?.childNodes?.length) {
10199
let previousParentElement = element;
102100
for (let i = 0; i < element.childNodes.length; i++) {
103101
const childElement = element.childNodes[i];
102+
// if an element has multiple children, search for the one that can receive the attributes
104103
if (i > 0) {
105104
let j = i - 1;
106105
while (j >= 0) {
@@ -135,16 +134,14 @@ function addAttributes(
135134
}
136135
}
137136
if (element.nodeType == Node.COMMENT_NODE) {
138-
if (
137+
if (previousElement !== section) {
139138
addAttributeInElement(
140139
element,
141140
previousElement,
142141
separatorElementAttributes,
143-
) ===
144-
false
145-
) {
146-
addAttributeInElement(element, section, separatorSectionAttributes);
142+
);
147143
}
144+
addAttributeInElement(element, section, separatorSectionAttributes);
148145
}
149146
}
150147

@@ -300,13 +297,15 @@ export function convertMarkdownToSlides(startElement, marked) {
300297
const markdown = getMarkdownFromSlide(section);
301298
// convert markdown to HTML
302299
section.innerHTML = SANITIZE(await marked.parse(markdown));
300+
// set ID on section elements and remove it from headings so revealjs can navigate to the slides via URL fragments
303301
const firstChild = section.firstElementChild;
304302
if (firstChild && firstChild.id !== "") {
305303
section.id = firstChild.id;
306304
firstChild.removeAttribute("id");
307305
} else {
308306
section.id = `${sectionNumber}`;
309307
}
308+
// search for comment nodes and add the attributes to respective parent nodes
310309
addAttributes(
311310
section,
312311
section,
@@ -721,8 +720,6 @@ const Plugin = () => {
721720
"theme": "white",
722721
"highlight-theme": "monokai",
723722
"favicon": "/favicon.svg",
724-
"fontawesomePro": false,
725-
"fontawesomeFree": false,
726723
// changed revealjs defaults
727724
"hash": true,
728725
};
@@ -809,14 +806,6 @@ const Plugin = () => {
809806
"topic": addMeta("topic"),
810807
"url": (url) =>
811808
S.map((fn) => fn(url))([addMeta("url"), addMeta("og:url")]),
812-
"fontawesomePro": loadScript(
813-
"https://kit.fontawesome.com/fec85b2437.js",
814-
"anonymous",
815-
),
816-
"fontawesomeFree": loadScript(
817-
"https://kit.fontawesome.com/ce15cd202d.js",
818-
"anonymous",
819-
),
820809
"_customcontrols": () => {
821810
// ignore the _customcontrols visibility setting
822811
},
@@ -865,12 +854,6 @@ const Plugin = () => {
865854
.map((k) => {
866855
mergedMetadata[k] = parseType(_mergedMetadata[k]);
867856
});
868-
if (mergedMetadata.fontawesomePro) {
869-
mergedMetadata.fontawesomeFree = false;
870-
}
871-
if (mergedMetadata.fontawesomeFree) {
872-
mergedMetadata.fontawesomePro = false;
873-
}
874857
if (
875858
// since revealjsConfig.controls is true by default, only decktape and
876859
// similar tools are able to override it .. so prefer whatever these tools

0 commit comments

Comments
 (0)