Add custom block

This commit is contained in:
🎷🐢 S. P. O. Clayton 2022-06-22 10:15:37 -04:00
parent d146315eca
commit 7724ed3431
Signed by: sean
SSH Key Fingerprint: SHA256:zkuPrRvkEDiQQv1Y5yScWa6I4zhj+eiv7XnP8pxIxVU
14 changed files with 2327 additions and 55 deletions

View File

@ -1,2 +1,2 @@
pnpm 7.2.1
pnpm 7.3.0
nodejs 18.3.0

View File

@ -33,6 +33,9 @@ The game is decided through rounds of engagement, in which players take turns in
This page contains various rules that are referred to elsewhere in this rulebook, and gives an overview of some key concepts that form the basis of the rules in general.
[stat-sheet]
Yooooo I'm uppercase?
=== Scenario
To play a game of Conflict, you must first select a scenario.

View File

@ -3,10 +3,11 @@
"scripts": {
"clean": "rm -rf out/*",
"build:web": "asciidoctor core-rules-document.adoc -D out -o 'Core Rules Document.html'",
"build:book": "asciidoctor-web-pdf core-rules-document.adoc -D out -o 'Core Rules Document.pdf'"
"build:book": "asciidoctor-web-pdf core-rules-document.adoc -r @conflict/stat-sheet-block -D out -o 'Core Rules Document.pdf'"
},
"dependencies": {
"@asciidoctor/core": "^2.2.6",
"@conflict/stat-sheet-block": "workspace:*",
"asciidoctor": "^2.2.6",
"asciidoctor-pdf": "*"
}

1
packages/stat-sheet-block/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
dist

View File

@ -0,0 +1,6 @@
{
"$schema": "http://json.schemastore.org/swcrc",
"jsc": {
"target": "es2019"
}
}

View File

@ -0,0 +1,5 @@
module.exports = {
transform: {
"^.+\\.(c)?(t|j)sx?$": "@swc/jest",
},
};

View File

@ -0,0 +1,5 @@
{
"typeAcquisition": {
"include": ["jest"]
}
}

View File

@ -0,0 +1,3 @@
const StatSheetBlock = require("./src/stat-sheet-block");
module.exports = StatSheetBlock;

View File

@ -1,3 +1,19 @@
{
"name": "@conflict/stat-sheet-block"
"name": "@conflict/stat-sheet-block",
"main": "dist/main.js",
"scripts": {
"build": "spack",
"test": "jest"
},
"dependencies": {
"@asciidoctor/core": "^2.2.6"
},
"devDependencies": {
"@jest/globals": "^28.1.1",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.2.204",
"@swc/jest": "^0.2.21",
"@types/jest": "^28.1.3",
"jest": "^28.1.1"
}
}

View File

@ -0,0 +1,17 @@
const path = require("path");
const { config } = require("@swc/core/spack");
module.exports = config({
target: "browser",
entry: {
main: path.resolve(__dirname, "main.js"),
},
output: {
path: path.resolve(__dirname, "dist"),
},
options: {
jsc: {
target: "es2019",
},
},
});

View File

@ -0,0 +1,18 @@
function StatSheetBlock() {
this.named("stat-sheet");
this.onContext("paragraph");
this.process((parent, reader) => {
const lines = reader.getLines().map((line) => line.toUpperCase());
return this.createBlock(parent, "paragraph", lines);
});
}
module.exports.register = function register(registry) {
if (registry.register) {
registry.register(function () {
this.block(StatSheetBlock);
});
} else {
registry.block(StatSheetBlock);
}
};

View File

@ -0,0 +1,17 @@
import Asciidoctor from "@asciidoctor/core";
import StatSheetBlock from "./stat-sheet-block";
const asciidoctor = Asciidoctor();
const registry = asciidoctor.Extensions.create();
StatSheetBlock.register(registry);
const asciidoc = `
[stat-sheet]
bob marley
`;
test("it works", () => {
expect(
asciidoctor.convert(asciidoc, { extension_registry: registry })
).toEqual(expect.stringContaining("BOB MARLEY"));
});

File diff suppressed because it is too large Load Diff