Add custom block

main
parent d146315eca
commit 7724ed3431
Signed by: sean
SSH Key Fingerprint: SHA256:zkuPrRvkEDiQQv1Y5yScWa6I4zhj+eiv7XnP8pxIxVU
  1. 2
      .tool-versions
  2. 0
      books/core-rules-document/assets/styles/conflict-web.css
  3. 3
      books/core-rules-document/core-rules-document.adoc
  4. 3
      books/core-rules-document/package.json
  5. 1
      packages/stat-sheet-block/.gitignore
  6. 6
      packages/stat-sheet-block/.swrc
  7. 5
      packages/stat-sheet-block/jest.config.js
  8. 5
      packages/stat-sheet-block/jsconfig.json
  9. 3
      packages/stat-sheet-block/main.js
  10. 18
      packages/stat-sheet-block/package.json
  11. 17
      packages/stat-sheet-block/spack.config.js
  12. 18
      packages/stat-sheet-block/src/stat-sheet-block.js
  13. 17
      packages/stat-sheet-block/src/stat-sheet-block.test.js
  14. 2360
      pnpm-lock.yaml

@ -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,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"));
});

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save