Skip to content

Commit

Permalink
release new version
Browse files Browse the repository at this point in the history
  • Loading branch information
joethei committed Jun 12, 2022
1 parent 1fb7c4d commit 6b7a219
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Obsidian PlantUML

![GitHub package.json version](https://img.shields.io/github/package-json/v/joethei/obsidian-plantuml)
![Maintenance](https://shields.joethei.xyz:/maintenance/yes/2022)
![GitHub manifest.json dynamic (path)](https://img.shields.io/github/manifest-json/minAppVersion/joethei/obsidian-plantuml?label=lowest%20supported%20app%20version)
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)
Expand Down Expand Up @@ -112,7 +111,7 @@ results in:

## Known issues
Not all methods of using PlantUML support all different diagrams.
Following are a few know issues.
Following are a few known issues.
- ASCII can only ever generate Sequence diagrams
- The PicoWeb server does not support clickable links in png diagrams
- Some languages like chinese are not rendered correctly -> Switch to SVG rendering
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-plantuml",
"name": "PlantUML",
"version": "1.6.3",
"version": "1.6.4",
"minAppVersion": "0.13.0",
"description": "Render PlantUML Diagrams",
"author": "Johannes Theiner",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-plantuml",
"version": "1.6.3",
"version": "1.6.4",
"description": "PlantUML rendering for Obsidian.md",
"main": "main.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Replacer {
this.plugin = plugin;
}

replaceNonBreakingSpaces(text: string): string {
public replaceNonBreakingSpaces(text: string): string {
const lines = text.split(/\r?\n/);
const resultLines: string[] = [];
if (text.startsWith("@startmindmap")) {
Expand All @@ -33,7 +33,7 @@ export class Replacer {
* @param path path of the current file
* @param filetype
*/
replaceLinks(text: string, path: string, filetype: string) : string {
public replaceLinks(text: string, path: string, filetype: string) : string {
return text.replace(/\[\[\[([\s\S]*?)\]\]\]/g, ((_, args) => {
const split = args.split("|");
const file = this.plugin.app.metadataCache.getFirstLinkpathDest(split[0], path);
Expand All @@ -57,7 +57,7 @@ export class Replacer {
* get the absolute path on the users computer
* @param path vault local path
*/
private getFullPath(path: string) {
public getFullPath(path: string) {
if (path.length === 0) {
//@ts-ignore
return this.plugin.app.vault.adapter.getFullPath("");
Expand All @@ -75,7 +75,7 @@ export class Replacer {
return this.plugin.app.vault.adapter.getFullPath(folder.path);
}

getPath(ctx: MarkdownPostProcessorContext) {
public getPath(ctx: MarkdownPostProcessorContext) {
return this.getFullPath(ctx ? ctx.sourcePath : '');
}

Expand Down
15 changes: 8 additions & 7 deletions src/localProcessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class LocalProcessors implements Processor {

async generateLocalMap(source: string, path: string): Promise<string> {
const {exec} = require('child_process');
const args = this.resolveLocalJarCmd(path).concat(['-pipemap']);
const args = this.resolveLocalJarCmd().concat(['-pipemap']);
const child = exec(args.join(" "), {encoding: 'binary', cwd: path});

let stdout = "";
Expand Down Expand Up @@ -66,7 +66,7 @@ export class LocalProcessors implements Processor {

async generateLocalImage(source: string, type: OutputType, path: string): Promise<string> {
const {ChildProcess, exec} = require('child_process');
const args = this.resolveLocalJarCmd(path).concat(['-t' + type, '-pipe']);
const args = this.resolveLocalJarCmd().concat(['-t' + type, '-pipe']);

let child: typeof ChildProcess;
if (type === OutputType.PNG) {
Expand Down Expand Up @@ -128,28 +128,29 @@ export class LocalProcessors implements Processor {
* To support local jar settings with unix-like style, and search local jar file
* from current vault path.
*/
private resolveLocalJarCmd(path: string): string[] {
private resolveLocalJarCmd(): string[] {
const jarFromSettings = this.plugin.settings.localJar;
const {isAbsolute, resolve} = require('path');
const {userInfo} = require('os');
let jarFullPath: string;
const path = this.plugin.replacer.getFullPath("");

if (jarFromSettings[0] === '~') {
// As a workaround, I'm not sure what would isAbsolute() return with unix-like path
jarFullPath = userInfo().homedir + jarFromSettings.slice(1)
jarFullPath = userInfo().homedir + jarFromSettings.slice(1);
}
else {
if (isAbsolute(jarFromSettings)) {
jarFullPath = jarFromSettings
jarFullPath = jarFromSettings;
}
else {
// the default search path is current vault
jarFullPath = resolve(path, jarFromSettings)
jarFullPath = resolve(path, jarFromSettings);
}
}

if (jarFullPath.length == 0) {
throw Error('Invalid local jar file')
throw Error('Invalid local jar file');
}

return [
Expand Down
11 changes: 10 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@ export class PlantUMLSettingsTab extends PluginSettingTab {
);

if(Platform.isDesktopApp) {

const jarDesc = new DocumentFragment();
jarDesc.createDiv().innerHTML = "Path to local JAR<br>Supports:" +
"<ul>" +
"<li>Absolute path</li>" +
"<li>Path relative to vault</li>" +
"<li>Path relative to users home directory <code>~/</code></li>" +
"</ul>";

new Setting(containerEl)
.setName("Local JAR")
.setDesc("Path to local PlantUML Jar")
.setDesc(jarDesc)
.addText(text => text.setPlaceholder(DEFAULT_SETTINGS.localJar)
.setValue(this.plugin.settings.localJar)
.onChange(async (value) => {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"1.6.0": "0.13.0",
"1.6.1": "0.13.0",
"1.6.2": "0.13.0",
"1.6.3": "0.13.0"
"1.6.3": "0.13.0",
"1.6.4": "0.13.0"
}

0 comments on commit 6b7a219

Please sign in to comment.