Compare commits

..

No commits in common. "master" and "0.1.9" have entirely different histories.

7 changed files with 15 additions and 24 deletions

5
.gitignore vendored
View file

@ -22,7 +22,4 @@ data.json
.DS_Store
# Test vault
test-vault
# Other
desktop.ini
test-vault

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Cleon Pinto
Copyright (c) 2021 Michael Brenan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -75,8 +75,8 @@ const ans4 = await $.ui.ask( 'Title', 'question 4', ['1', '2', '3'] );
// show a message
await $.ui.message( `Your answers were:\n\n${ans1}, ${ans2}, ${ans3}, ${ans4}` );
// show a 2 line message with title
await $.ui.message( 'A Title', 'A titled message\nLine 2' );
// show a message with title
await $.ui.message( 'A Title', 'A titled <b>message</b>' );
await $.ui.message( 'Math', 13 * 67 );
// rebuild the current view, may be needed if you have an embedded note which was modified

View file

@ -100,8 +100,8 @@ Say your note looks like this:
# My Runnable Note
The template codeblock:
```
Greetings {{name}}, {{message}}
```html
<p>Greetings <strong>{{name}}</strong>, {{message}}</p>
```
The meld-build block to run:
@ -116,7 +116,7 @@ await $.ui.message( result );
````
Running this note will show a message with the following text: 'Greetings John, How are you?'
Running this note will show a message with the following text: 'Greetings **John**, How are you?'
See the `$.io.import` and `$.io.load` [API](api.md) functions for other ways to load templates.

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "meld-build-obsidian-plugin",
"version": "0.1.9",
"version": "0.1.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "meld-build-obsidian-plugin",
"version": "0.1.9",
"version": "0.1.6",
"license": "MIT",
"devDependencies": {
"@types/handlebars": "^4.1.0",

View file

@ -1,5 +1,5 @@
import { DataSet } from "./data-set";
import { TMarkdownHelperRunContext, TMarkdownHelperTableCellFormatter } from "./run-context";
import { TMarkdownHelperRunContext } from "./run-context";
import { RunLogger } from "./run-logger";
export class MarkdownHelperRunContextImplementation implements TMarkdownHelperRunContext{
@ -14,7 +14,7 @@ export class MarkdownHelperRunContextImplementation implements TMarkdownHelperRu
return MarkdownTableHelper.buildTable( headings, rows );
}
buildTableFromDataSet(data: DataSet, cellFormatter?:TMarkdownHelperTableCellFormatter): string {
buildTableFromDataSet(data: DataSet): string {
const headings = data.columns;
const rowValues : any[][] = [];
@ -23,13 +23,7 @@ export class MarkdownHelperRunContextImplementation implements TMarkdownHelperRu
for (const heading of headings) {
const prop = data.getPropertyName(heading);
let value = prop == undefined ? undefined : row[prop];
if (prop != undefined && cellFormatter != null){
const formattedValue = cellFormatter(prop, value);
if (formattedValue != undefined){
value = formattedValue;
}
}
const value = prop == undefined ? undefined : row[prop];
values.push(value);
}
@ -41,7 +35,7 @@ export class MarkdownHelperRunContextImplementation implements TMarkdownHelperRu
public table(arg1: unknown, arg2?: unknown): string {
if (arg1 instanceof DataSet){
return this.buildTableFromDataSet(arg1, arg2 as TMarkdownHelperTableCellFormatter);
return this.buildTableFromDataSet(arg1);
}
if ( Array.isArray(arg1) && Array.isArray(arg2) ){
return this.buildTable(arg1, arg2);

View file

@ -118,9 +118,9 @@ export class MarkerChange{
}
}
export type TMarkdownHelperTableCellFormatter = (propName:string, value:any) => string|undefined;
export type TMarkdownHelperRunContext = {
table( headings:Array<string>, rows:Array<Array<any>> ) : string;
table( data:DataSet, cellFormatter?:TMarkdownHelperTableCellFormatter ) : string;
table( data:DataSet ) : string;
}