commit 810741d0953aa020eb7ed4209a77f05491709837
parent aaddc7c39cd46d2e35c1a57dad68bec39e7fe6df
Author: Demonstrandum <samuel@knutsen.co>
Date:   Tue, 23 Aug 2022 17:54:32 +0100
Added British English soft-hyphenation to text before linebreaking.
This helps place hyphens in the right places to aid text shaping.
Diffstat:
1 file changed, 42 insertions(+), 5 deletions(-)
diff --git a/shiimoe/templates/layout.html b/shiimoe/templates/layout.html
@@ -24,6 +24,47 @@
 	<link rel="alternate" type="application/atom+xml" title="RSS/Atom feed for shii.moe" href="/rss.xml">
 	<title>{% block title %}{% endblock %} – Shiimoe!!</title>
 	<script src="https://unpkg.com/tex-linebreak2@latest/dist/lib.js"></script>
+	<script src="https://mnater.github.io/Hyphenopoly/min/Hyphenopoly_Loader.js"></script>
+	<script>
+	const flow = () => {
+	    // Only immediate children paragraphs of article tag are considered content.
+	    const paragraphs = document.querySelectorAll("article > p");
+	    texLinebreak.texLinebreakDOM(paragraphs, {
+	        align: 'justify'
+	    });
+	};
+	const hyphenConfig = {
+            require: {
+                "en-gb": "FORCEHYPHENOPOLY",
+            },
+            paths: {
+                patterndir: "https://mnater.github.io/Hyphenopoly/min/patterns/",
+                maindir: "https://mnater.github.io/Hyphenopoly/min/"
+            },
+            setup: {
+		CORScredentials: "omit",
+                selectors: {
+                    "article": {}
+                }
+            },
+	    handleEvent: {
+		hyphenopolyEnd: flow
+	    }
+        };
+	document.fonts.ready.then(() => {
+	    Hyphenopoly.config(hyphenConfig);
+	});
+	</script>
+	<noscript>
+            <style>
+            .article {
+                hyphens: auto;
+                -webkit-hyphens: auto;
+                -ms-hyphens: auto;
+                text-aling: justify;
+            }
+            </style>
+        </noscript>
 	{% endblock %}
 </head>
 <body>
@@ -51,11 +92,7 @@
 		<script>randomMascot(NOVELTY);</script>
 		<!-- Competent text alignment -->
 		<script>
-			// Only immediate children paragraphs of article tag are considered content.
-			const paragraphs = document.querySelectorAll("article > p");
-			texLinebreak.texLinebreakDOM(paragraphs, {
-				align: 'justify'
-			});
+		if (0) document.fonts.ready.then(async );
 		</script>
 	{% endblock %}
 </body>