This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
-
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
Showing
12 changed files
with
5,906 additions
and
271 deletions.
There are no files selected for viewing
1,158 changes: 1,158 additions & 0 deletions
1,158
packages/json-schema-producer/factorio.schema.d.ts
Large diffs are not rendered by default.
Oops, something went wrong.
4,455 changes: 4,455 additions & 0 deletions
4,455
packages/json-schema-producer/factorio.schema.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 @@ | ||
export const classNames = [ | ||
"game", | ||
"script", | ||
"remote", | ||
"commands", | ||
"settings", | ||
"rcon", | ||
]; |
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 @@ | ||
export type PageMeta = { baseUrl: string; pageBasename: string }; |
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,26 @@ | ||
import TurndownService from "turndown"; | ||
import { PageMeta } from "./interfaces"; | ||
|
||
export const asUrlCorrectedMarkdown = ( | ||
s: string, | ||
{ baseUrl, pageBasename }: PageMeta | ||
) => { | ||
const turndown = new TurndownService({}); | ||
let md = turndown.turndown(s); | ||
if (s.match(/href/)) { | ||
// cases | ||
// 0. absolute rules | ||
// no op. the following rules should not meddle with http(s):// urls | ||
// 1. on-page-urls/anchors | ||
md = md.replace(new RegExp(`\\]\\(${pageBasename}`, "gi"), `](${baseUrl}`); | ||
// 2. relative urls | ||
const relmatches = md.match(new RegExp(`\\]\\((?!http)(\.+.html)`)); | ||
if (relmatches?.length) { | ||
md = md.replace( | ||
new RegExp(`\\]\\((?!http)\.+.html`, "gi"), | ||
`](${baseUrl.replace(pageBasename, relmatches[1])}` | ||
); | ||
} | ||
} | ||
return md; | ||
}; |
Oops, something went wrong.