parent
d146315eca
commit
7724ed3431
@ -1,2 +1,2 @@ |
||||
pnpm 7.2.1 |
||||
pnpm 7.3.0 |
||||
nodejs 18.3.0 |
||||
|
@ -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")); |
||||
}); |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue