+
diff --git a/lib/tabbedPageBuilder.js b/lib/tabbedPageBuilder.js
index 2b17481d1..9bf283e88 100644
--- a/lib/tabbedPageBuilder.js
+++ b/lib/tabbedPageBuilder.js
@@ -1,6 +1,7 @@
import fse from "fs-extra";
import * as pageBuilderUtils from "./pageBuilderUtils.js";
import * as processor from "./processor.js";
+import CleanCSS from "clean-css";
/**
* Replace the template tag with the CSS source, or an empty string
@@ -46,6 +47,24 @@ function addJS(currentPage, tmpl) {
return tmpl;
}
+/**
+ * Adds optional hidden CSS to tabbed example.
+ * Its primary use case is adding new font to the example, without displaying @font-face to the user
+ * @param {Object} currentPage - The current page as an Object
+ * @param {String} tmpl - The template as a string
+ * @returns the processed template string
+ */
+function addHiddenCSS(currentPage, tmpl) {
+ if (currentPage.cssHiddenSrc) {
+ const content = fse.readFileSync(currentPage.cssHiddenSrc, "utf8");
+ const minified = new CleanCSS().minify(content).styles;
+
+ return tmpl.replace("%example-hidden-css-src%", minified);
+ } else {
+ return tmpl.replace("%example-hidden-css-src%", "");
+ }
+}
+
/**
* Builds and returns the HTML source for a tabbed example
* @param {String} tmpl - The template as a string
@@ -70,5 +89,7 @@ export function buildTabbedExample(tmpl, currentPage) {
tmpl = addHTML(currentPage, tmpl);
// add the example JS
tmpl = addJS(currentPage, tmpl);
+ // add hidden example-dependent CSS
+ tmpl = addHiddenCSS(currentPage, tmpl);
return tmpl;
}
diff --git a/live-examples/fonts/molot.css b/live-examples/fonts/molot.css
new file mode 100644
index 000000000..d6e91685c
--- /dev/null
+++ b/live-examples/fonts/molot.css
@@ -0,0 +1,4 @@
+@font-face {
+ font-family: molot;
+ src: url("/media/fonts/molot.woff2") format("woff2");
+}
diff --git a/live-examples/html-examples/table-content/caption.html b/live-examples/html-examples/table-content/caption.html
new file mode 100644
index 000000000..c0e53b83f
--- /dev/null
+++ b/live-examples/html-examples/table-content/caption.html
@@ -0,0 +1,25 @@
+