-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
877217d
commit f9d776c
Showing
8 changed files
with
1,670 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,19 @@ | ||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Large diffs are not rendered by default.
Oops, something went wrong.
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,96 @@ | ||
# [Pintorita - Pintora plugin for typst ](https://github.com/taylorh140/typst-pintora) | ||
|
||
[Pintora](https://pintorajs.vercel.app/) | ||
|
||
Typst package for drawing the following from markup: | ||
- Sequence Diagram | ||
- Entity Relationship Diagram | ||
- Component Diagram | ||
- Activity Diagram | ||
- Mind Map Experiment | ||
- Gantt Diagram Experiment | ||
- DOT Diagram Experiment | ||
|
||
![](pintorita.svg) | ||
|
||
|
||
````typ | ||
#import "@preview/pintorita:0.1.2" | ||
#set page(height: auto, width: auto, fill: black, margin: 2em) | ||
#set text(fill: white) | ||
#show raw.where(lang: "pintora"): it => pintorita.render(it.text) | ||
= pintora | ||
Typst just got a load of diagrams. | ||
```pintora | ||
mindmap | ||
@param layoutDirection TB | ||
+ UML Diagrams | ||
++ Behavior Diagrams | ||
+++ Sequence Diagram | ||
+++ State Diagram | ||
+++ Activity Diagram | ||
++ Structural Diagrams | ||
+++ Class Diagram | ||
+++ Component Diagram | ||
``` | ||
``` | ||
mindmap | ||
@param layoutDirection TB | ||
+ UML Diagrams | ||
++ Behavior Diagrams | ||
+++ Sequence Diagram | ||
+++ State Diagram | ||
+++ Activity Diagram | ||
++ Structural Diagrams | ||
+++ Class Diagram | ||
+++ Component Diagram | ||
``` | ||
```` | ||
|
||
|
||
## Documentation | ||
|
||
### `render` | ||
|
||
Render a pintora string to an image | ||
|
||
#### Arguments | ||
|
||
* `src`: `str` - pintora source string | ||
* `factor`: scale output svg, "factor:0.5" will scale images down by half, so scale can be consistent across renders. | ||
* `style`: `str` diagram style, `default` or `dark` or `larkLight` or `larkDark` | ||
* `font`: `str` font family, default is `Source Code Pro, sans-serif` | ||
* All other arguments are passed to `image.decode` so you can customize the image size | ||
|
||
#### Returns | ||
|
||
The image, of type `content` | ||
|
||
### `render_svg` | ||
|
||
Render a pintora string to an image | ||
|
||
#### Arguments | ||
|
||
* `src`: `str` - pintora source string | ||
* `factor`: scale output svg, "factor:0.5" will scale images down by half, so scale can be consistent across renders. | ||
* `style`: `str` diagram style, `default` or `dark` or `larkLight` or `larkDark` | ||
* `font`: `str` font family, default is `Source Code Pro, sans-serif` | ||
* All other arguments are passed to `image.decode` so you can customize the image size | ||
|
||
#### Returns | ||
|
||
The svg image | ||
|
||
## History | ||
|
||
* 0.1.0 - Inital Release | ||
* 0.1.1 - Updated to Jogs 0.2.3 and pintora 0.7.3 | ||
* 0.1.2 - Fixed strange offset of text rows in class diagram, added `render_svg` function and more customization options |
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 @@ | ||
#import "./pintorita.typ": render, render_svg | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,40 @@ | ||
#import "@preview/jogs:0.2.3": compile-js, call-js-function | ||
|
||
#let pintora-src = read("./pintora.js") | ||
#let pintora-bytecode = compile-js(pintora-src) | ||
|
||
#let render(src, ..args) = { | ||
let named-args = args.named() | ||
let factor = named-args.at("factor",default:none) | ||
let style = named-args.at("style",default:"larkLight") | ||
let font = named-args.at("font",default:"Arial") | ||
let svg-output = call-js-function(pintora-bytecode, "PintoraRender", src, style, font) | ||
|
||
if (factor != none){ | ||
let svg-width = svg-output.find(regex("width=\"(\d+)")).find(regex("\d+")) | ||
|
||
let new-width = int(svg-width) * factor * 1pt | ||
named-args.insert("width", new-width) | ||
let junk = named-args.remove("factor") | ||
} | ||
image.decode(svg-output, ..args.pos(), ..named-args) | ||
} | ||
|
||
#let render_svg(src, ..args) = { | ||
// style: ["default", "larkLight", "larkDark", "dark"] | ||
let named-args = args.named() | ||
let factor = named-args.at("factor",default:none) | ||
let style = named-args.at("style",default:"larkLight") | ||
let font = named-args.at("font",default:"Arial") | ||
let svg-output = call-js-function(pintora-bytecode, "PintoraRender", src, style, font) | ||
|
||
if (factor != none){ | ||
let svg-width = svg-output.find(regex("width=\"(\d+)")).find(regex("\d+")) | ||
|
||
let new-width = int(svg-width) * factor * 1pt | ||
named-args.insert("width", new-width) | ||
let junk = named-args.remove("factor") | ||
} | ||
svg-output | ||
} | ||
|
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,21 @@ | ||
[package] | ||
name = "pintorita" | ||
version = "0.1.2" | ||
entrypoint = "lib.typ" | ||
authors = ["Min Chen (hikerpig)","Taylorh140"] | ||
license = "MIT" | ||
description = "Package to draw Sequence Diagrams, Entity Relationship Diagrams, Component Diagrams, Activity Diagrams, Mind Maps, Gantt Diagrams, and DOT Diagrams based on Pintora which is heavily influenced by mermaid.js and plantuml." | ||
categories = ["visualization"] | ||
|
||
homepage = "https://github.com/taylorh140/typst-pintora" | ||
Check failure on line 10 in packages/preview/pintorita/0.1.2/typst.toml Typst package check / @preview/pintorita:0.1.2packages/preview/pintorita/0.1.2/typst.toml#L10
|
||
repository = "https://github.com/taylorh140/typst-pintora" | ||
keywords = [ | ||
"js", | ||
"javascript", | ||
"pintora", | ||
"gantt", | ||
"sequence", | ||
] | ||
exclude = [ | ||
"pintorita.svg", | ||
] |