diff --git a/docusaurus-plugin-moonwave/src/components/LuaClass.js b/docusaurus-plugin-moonwave/src/components/LuaClass.js
index a3b9721..31d90bf 100644
--- a/docusaurus-plugin-moonwave/src/components/LuaClass.js
+++ b/docusaurus-plugin-moonwave/src/components/LuaClass.js
@@ -37,6 +37,12 @@ const SECTIONS = [
const capitalize = (text) => text[0].toUpperCase() + text.substring(1)
+const breakCapitalWords = (text) =>
+ text
+ .replace(/([A-Z])/g, " $1")
+ .trim()
+ .split(" ")
+
const ClassSection = ({
luaClass,
section,
@@ -262,7 +268,13 @@ export default function LuaClass({
: "none",
}}
>
- {luaClass.name}
+ {breakCapitalWords(luaClass.name).map(
+ (capitalWord) => (
+
+ {capitalWord}
+
+ )
+ )}
{luaClass.realm?.map((realm) => (
diff --git a/docusaurus-plugin-moonwave/src/components/Redirect.js b/docusaurus-plugin-moonwave/src/components/Redirect.js
index eb0440a..8ae0925 100644
--- a/docusaurus-plugin-moonwave/src/components/Redirect.js
+++ b/docusaurus-plugin-moonwave/src/components/Redirect.js
@@ -2,10 +2,11 @@ import { Redirect as RouterRedirect } from "@docusaurus/router"
import React from "react"
export default function Redirect({ allLuaClassNames, pluginOptions }) {
- const firstLuaClassName =
+ const firstLuaClassName = (
allLuaClassNames[0].type === "link"
? allLuaClassNames[0].label
: allLuaClassNames[0].items[0].label
+ ).replace(/[\u200B]/g, "") // Strip out any extraneous 0-width spaces
return (
diff --git a/docusaurus-plugin-moonwave/src/components/styles.module.css b/docusaurus-plugin-moonwave/src/components/styles.module.css
index 4def94b..2cbdf9c 100644
--- a/docusaurus-plugin-moonwave/src/components/styles.module.css
+++ b/docusaurus-plugin-moonwave/src/components/styles.module.css
@@ -21,6 +21,10 @@
width: 100vw;
}
+:global a.menu__link {
+ word-break: break-word;
+}
+
.divider {
border-top: 1px solid var(--ifm-color-emphasis-300);
margin: 1rem 0;
@@ -66,8 +70,11 @@
font-family: inherit;
}
+.docPage .member code {
+ word-break: break-word;
+}
+
.docPage .member h3 code {
- word-break: "break-word";
display: "inline";
}
@@ -259,6 +266,7 @@
font-size: 3rem;
margin-bottom: calc(var(--ifm-leading-desktop) * var(--ifm-leading));
display: inline-block;
+ word-break: break-word;
}
.docSidebarContainer {
diff --git a/docusaurus-plugin-moonwave/src/index.js b/docusaurus-plugin-moonwave/src/index.js
index 2cdee1d..4a86e66 100644
--- a/docusaurus-plugin-moonwave/src/index.js
+++ b/docusaurus-plugin-moonwave/src/index.js
@@ -3,6 +3,9 @@ const fs = require("fs")
const { promisify } = require("util")
const exec = promisify(require("child_process").exec)
+const breakCapitalWordsZeroWidth = (text) =>
+ text.replace(/([A-Z])/g, "\u200B$1") // Adds a zero-width space before each capital letter. This way, the css word-break: break-word; rule can apply correctly
+
const mapLinks = (nameSet, items) =>
items.map((name) => {
if (!nameSet.has(name)) {
@@ -14,7 +17,7 @@ const mapLinks = (nameSet, items) =>
return {
type: "link",
href: `/api/${name}`,
- label: name,
+ label: breakCapitalWordsZeroWidth(name),
}
})
@@ -28,7 +31,7 @@ function parseSimpleClassOrder(content, classOrder, nameSet) {
.map((name) => ({
type: "link",
href: `/api/${name}`,
- label: name,
+ label: breakCapitalWordsZeroWidth(name),
}))
return [...listedLinks, ...unlistedLinks]
@@ -59,7 +62,7 @@ function parseSectionalClassOrder(content, classOrder, nameSet) {
.map((name) => ({
type: "link",
href: `/api/${name}`,
- label: name,
+ label: breakCapitalWordsZeroWidth(name),
}))
return [...listedSidebar, ...unlistedSidebar]
@@ -70,7 +73,7 @@ function parseClassOrder(content, classOrder, nameSet) {
return [...nameSet].sort().map((name) => ({
type: "link",
href: `/api/${name}`,
- label: name,
+ label: breakCapitalWordsZeroWidth(name),
}))
}