-
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.
feat: inital commit with first working version (#1)
* include all but travis * add plantuml.jar version v1.2023.10 * wip * wip * remove unused dep * update packages * try fix tests * fixes * remove not needed file * fix test * node 16 * wip
- Loading branch information
Showing
14 changed files
with
5,001 additions
and
0 deletions.
There are no files selected for viewing
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,17 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": ["eslint:recommended", "plugin:prettier/recommended"], | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
}, | ||
"rules": {} | ||
} |
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,30 @@ | ||
name: Node.js Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm test | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
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,106 @@ | ||
# ======================================== | ||
# Generated by gibo | ||
# | ||
# See details about gibo: | ||
# https://github.com/simonwhitaker/gibo | ||
# ======================================== | ||
|
||
### node | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
|
||
### visualstudiocode | ||
|
||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json |
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,3 @@ | ||
{ | ||
"spec": "test/**/*.js" | ||
} |
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,5 @@ | ||
{ | ||
"useTabs": false, | ||
"printWidth": 120, | ||
"tabWidth": 2 | ||
} |
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,5 @@ | ||
{ | ||
"recommendations": [ | ||
"streetsidesoftware.code-spell-checker" | ||
] | ||
} |
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,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"plantuml" | ||
] | ||
} |
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,83 @@ | ||
|
||
# Remark Simple PlantUML Plugin with local Rendering | ||
|
||
TODO: build status | ||
|
||
`remark-local-plantuml` is a simple plugin for [remarkjs](https://github.com/remarkjs/remark) that converts PlantUML code locally int inline html image nodes. | ||
|
||
## Installing | ||
|
||
```bash | ||
npm install --save @mstroppel/remark-local-plantuml | ||
``` | ||
|
||
## Example | ||
|
||
You can use this plugin like following | ||
|
||
### Markdown | ||
|
||
````markdown | ||
# Your markdown including PlantUML code block | ||
|
||
```plantuml Your title | ||
class SimplePlantUMLPlugin { | ||
+ transform(syntaxTree: AST): AST | ||
} | ||
``` | ||
```` | ||
|
||
### JavaScript | ||
|
||
```javascript | ||
const remark = require("remark"); | ||
const simplePlantUML = require("@mstroppel/remark-local-plantuml"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const input = fs.readFileSync(path.resolve(__dirname, "./your-markdown.md")).toString(); | ||
const output = remark().use(simplePlantUML).processSync(input).toString(); | ||
|
||
console.log(output); | ||
// will be | ||
// > # Your markdown including PlantUML code block | ||
// > | ||
// > ![Your title](https://www.plantuml.com/plantuml/png/Iyv9B2vM2CxCBSX93SX9p2i9zVK9o2bDpynJgEPI009jXPAYnBpYjFoYN8tYohoIn8gGejHKAmN7u11DCCbL2m00) | ||
``` | ||
|
||
## Plugin Options | ||
|
||
You can use specific PlantUML server by the option 'baseUrl'. | ||
(The default is `https://www.plantuml.com/plantuml/png`) | ||
|
||
If you want to use SVG, you can configure like following. | ||
|
||
```javascript | ||
remark().use(simplePlantUML, { baseUrl: "https://www.plantuml.com/plantuml/svg" }).processSync(input); | ||
``` | ||
|
||
## Integration | ||
|
||
You can use this plugin in any frameworks support remarkjs. | ||
|
||
If you want to use in the classic preset of [Docusaurus 2](https://v2.docusaurus.io/), like me, set configuration in your `docusaurus.config.js` like following. | ||
|
||
```javascript | ||
const simplePlantUML = require("@mstroppel/remark-local-plantuml"); | ||
|
||
// your configurations... | ||
|
||
presets: [ | ||
[ | ||
"@docusaurus/preset-classic", | ||
{ | ||
docs: { | ||
sidebarPath: require.resolve("./sidebars.js"), | ||
remarkPlugins: [simplePlantUML] | ||
} | ||
} | ||
] | ||
], | ||
|
||
//... | ||
``` |
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,46 @@ | ||
const visit = require("unist-util-visit"); | ||
const plantuml = require("node-plantuml"); | ||
|
||
/** | ||
* Plugin for remark-js | ||
* | ||
* See details about plugin API: | ||
* https://github.com/unifiedjs/unified#plugin | ||
*/ | ||
function remarkSimplePlantumlPlugin() { | ||
return async function transformer(syntaxTree) { | ||
const nodes = []; | ||
visit(syntaxTree, "code", node => { | ||
let { lang, value } = node; | ||
if (lang && value && lang === "plantuml") { | ||
nodes.push(node); | ||
} | ||
}); | ||
|
||
let promises = []; | ||
for (const node of nodes) { | ||
let { value, alt } = node; | ||
let svgString = ""; | ||
const plantumlGenerator = plantuml.generate(value, { format: "svg" }); | ||
|
||
let promise = new Promise(resolve => { | ||
plantumlGenerator.out.on("data", data => { | ||
svgString += data.toString("utf8"); | ||
}); | ||
|
||
plantumlGenerator.out.on("end", () => { | ||
node.type = "html"; | ||
node.value = `<div class="plantuml-diagram">${svgString}</div>`; | ||
node.alt = alt; | ||
node.meat = undefined; | ||
resolve(); | ||
}); | ||
}); | ||
promises.push(promise); | ||
} | ||
|
||
await Promise.all(promises); | ||
}; | ||
} | ||
|
||
module.exports = remarkSimplePlantumlPlugin; |
Oops, something went wrong.