generated from moonlight-mod/sample-extension
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c96b60
commit d33fb74
Showing
9 changed files
with
189 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ExtensionWebpackModule } from "@moonlight-mod/types"; | ||
|
||
export const webpackModules: Record<string, ExtensionWebpackModule> = { | ||
greentext: { | ||
entrypoint: true, | ||
dependencies: [{ ext: "markdown", id: "markdown" }, { id: "react" }] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://moonlight-mod.github.io/manifest.schema.json", | ||
"id": "greentext", | ||
"version": "1.0.0", | ||
"meta": { | ||
"name": "Greentext", | ||
"tagline": ">has to explain what it does", | ||
"authors": [ | ||
"Cynosphere" | ||
], | ||
"tags": [ | ||
"chat" | ||
], | ||
"source": "https://github.com/Cynosphere/moonlight-extensions" | ||
}, | ||
"apiLevel": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.theme-dark .greentext { | ||
color: #afc960; | ||
} | ||
|
||
.theme-light .greentext { | ||
color: #789922; | ||
} | ||
|
||
.greentext-ban { | ||
font-weight: bold; | ||
color: var(--red-400); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from "@moonlight-mod/wp/react"; | ||
import * as Markdown from "@moonlight-mod/wp/markdown_markdown"; | ||
|
||
Markdown.addRule( | ||
"greentext", | ||
(rules) => ({ | ||
order: rules.text.order, | ||
// @ts-expect-error i cant care enough to get this type working | ||
match: function (text, state) { | ||
if (state.inGreentext || state.inQuote) return null; | ||
|
||
return /^$|\n$/.test(state.prevCapture != null ? state.prevCapture[0] : "") && /^(>.+?)(?:\n|$)/.exec(text); | ||
}, | ||
parse: function (capture, parse, state) { | ||
state.inGreentext = true; | ||
const node = { | ||
content: parse(capture[0], state) | ||
}; | ||
delete state.inGreentext; | ||
return node; | ||
}, | ||
react: function (node, recurseOutput, state) { | ||
return <span className="greentext">{recurseOutput(node.content, state)}</span>; | ||
} | ||
}), | ||
() => ({ | ||
type: "inlineStyle", | ||
before: "", | ||
after: "" | ||
}), | ||
"greentext" | ||
); | ||
Markdown.blacklistFromRuleset("INLINE_REPLY_RULES", "greentext"); | ||
|
||
Markdown.addRule( | ||
"greentext-ban", | ||
(rules) => ({ | ||
order: rules.strong.order - 1, | ||
match: function (text, state) { | ||
if (state.inGreentextBan) return null; | ||
return /^\*\*\(USER WAS BANNED FOR THIS POST\)\*\*/.exec(text); | ||
}, | ||
parse: function (capture, parse, state) { | ||
state.inGreentextBan = true; | ||
const node = { | ||
content: parse(capture[0], state) | ||
}; | ||
delete state.inGreentextBan; | ||
return node; | ||
}, | ||
react: function (node, recurseOutput, state) { | ||
return <span className="greentext-ban">{recurseOutput(node.content, state)}</span>; | ||
} | ||
}), | ||
() => ({ | ||
type: "inlineStyle", | ||
before: "", | ||
after: "" | ||
}), | ||
"greentext-ban" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ExtensionWebpackModule } from "@moonlight-mod/types"; | ||
|
||
export const webpackModules: Record<string, ExtensionWebpackModule> = { | ||
shiftjis: { | ||
entrypoint: true, | ||
dependencies: [{ ext: "markdown", id: "markdown" }, { id: "react" }] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://moonlight-mod.github.io/manifest.schema.json", | ||
"id": "shiftjis", | ||
"version": "1.0.0", | ||
"meta": { | ||
"name": "ShiftJIS Codeblocks", | ||
"tagline": "Renders codeblocks with the `sjis` language as normal text in a ShiftJIS supported font", | ||
"authors": [ | ||
"Cynosphere" | ||
], | ||
"tags": [ | ||
"chat" | ||
], | ||
"source": "https://github.com/Cynosphere/moonlight-extensions" | ||
}, | ||
"apiLevel": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.shiftjis { | ||
font-size: 16px; | ||
line-height: 17px; | ||
white-space: pre; | ||
font-family: "IPAMonaPGothic", "Mona", "MS PGothic", monospace; | ||
overflow: auto; | ||
display: block; | ||
clear: left; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from "@moonlight-mod/wp/react"; | ||
import * as Markdown from "@moonlight-mod/wp/markdown_markdown"; | ||
|
||
Markdown.addRule( | ||
"shiftjis", | ||
(rules) => ({ | ||
order: rules.codeBlock.order - 1, | ||
match: function (text, state) { | ||
if (state.inShiftjis || state.inQuote) return null; | ||
return /^```sjis(?:\n)?((?:\\[\s\S]|[^\\])+?)```(?!`)/.exec(text); | ||
}, | ||
parse: function (capture, parse, state) { | ||
state.inShiftjis = true; | ||
const node = { | ||
content: parse( | ||
capture[1] | ||
.replace(/\\/g, "\\\\") | ||
.replace(/`/g, "\\`") | ||
.replace(/_/g, "\\_") | ||
.replace(/\*/g, "\\*") | ||
.replace(/~/g, "\\~") | ||
.replace(/\|/g, "\\|"), | ||
state | ||
) | ||
}; | ||
delete state.inShiftjis; | ||
return node; | ||
}, | ||
react: function (node, recurseOutput, state) { | ||
return <span className="shiftjis">{recurseOutput(node.content, state)}</span>; | ||
} | ||
}), | ||
() => ({ | ||
type: "inlineObject" | ||
}) | ||
); | ||
Markdown.blacklistFromRuleset("INLINE_REPLY_RULES", "shiftjis"); |