Add custom block
This commit is contained in:
parent
d146315eca
commit
7724ed3431
|
@ -1,2 +1,2 @@
|
|||
pnpm 7.2.1
|
||||
pnpm 7.3.0
|
||||
nodejs 18.3.0
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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": "*"
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
dist
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/swcrc",
|
||||
"jsc": {
|
||||
"target": "es2019"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
transform: {
|
||||
"^.+\\.(c)?(t|j)sx?$": "@swc/jest",
|
||||
},
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"typeAcquisition": {
|
||||
"include": ["jest"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
const StatSheetBlock = require("./src/stat-sheet-block");
|
||||
|
||||
module.exports = StatSheetBlock;
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
},
|
||||
});
|
|
@ -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);
|
||||
}
|
||||
};
|
|
@ -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"));
|
||||
});
|
2284
pnpm-lock.yaml
2284
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue