Skip to content

Commit

Permalink
Merge pull request #6 from bchainhub/update/fixes-03
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rastislavcore authored Mar 2, 2024
2 parents 0ea85e5 + 3e3194e commit 5a35431
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 10 deletions.
17 changes: 17 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { type Node } from 'unist';
interface CorebcOptions {
enableIcanCheck?: boolean;
enableSkippingIcanCheck?: boolean;
linkNetworks?: boolean;
explorerUrl?: string;
explorerTestnetUrl?: string;
urlPathAddress?: string;
urlPathBlockNo?: string;
urlPathBlockHash?: string;
checkAddress?: boolean;
checkBlockNumber?: boolean;
checkBlockHash?: boolean;
debug?: boolean;
}
export default function remarkCorebc(options?: CorebcOptions): (ast: Node) => void;
export {};
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remark-corebc",
"version": "0.1.3",
"version": "0.1.4",
"description": "A Remark plugin to transform Core Blockchain notations into markdown links.",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand All @@ -19,7 +19,6 @@
"files": [
"src/",
"dist/",
"types/",
"LICENSE",
"README.md"
],
Expand All @@ -40,22 +39,22 @@
"license": "CORE",
"dependencies": {
"@blockchainhub/ican": "^0.3.0",
"@types/unist": "^3.0.2",
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@types/node": "^20.9.2",
"@types/unist": "^3.0.2",
"@types/node": "^20.11.24",
"esm": "^3.2.25",
"remark-parse": "^11.0.0",
"remark-stringify": "^11.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"undici-types": "^5.27.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"undici-types": "^6.6.2",
"unified": "^11.0.4",
"uvu": "^0.5.6"
},
"engines": {
"node": ">=13.2.0"
"node": ">=16"
},
"exports": {
".": {
Expand Down
43 changes: 42 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,55 @@
import { Node } from 'unist';
import { type Node } from 'unist';
import { visit } from 'unist-util-visit';
import Ican from '@blockchainhub/ican';

interface CorebcOptions {
/**
* Enable ICAN check for addresses
*/
enableIcanCheck?: boolean;
/**
* Enable skipping ICAN check with "!" sign
*/
enableSkippingIcanCheck?: boolean;
/**
* Enable linking networks
*/
linkNetworks?: boolean;
/**
* Mainnet explorer URL
*/
explorerUrl?: string;
/**
* Testnet explorer URL
*/
explorerTestnetUrl?: string;
/**
* URL path for addresses
*/
urlPathAddress?: string;
/**
* URL path for block numbers
*/
urlPathBlockNo?: string;
/**
* URL path for block hashes
*/
urlPathBlockHash?: string;
/**
* Enabled checking address
*/
checkAddress?: boolean;
/**
* Enabled checking block number
*/
checkBlockNumber?: boolean;
/**
* Enabled checking block hash
*/
checkBlockHash?: boolean;
/**
* Debug mode
*/
debug?: boolean;
}

Expand Down Expand Up @@ -251,6 +287,11 @@ const transformMatchesIntoNodes = (matches: Match[], options: CorebcOptions): No
});
};

/**
* A remark transformer to transform Core Blockchain values (Addresses, Block Numbers, Block Hashes) into links.
* @param options - Options for the CoreBC plugin.
* @returns A transformer for the AST.
*/
export default function remarkCorebc(options: CorebcOptions = {}): (ast: Node) => void {
const finalOptions = {
enableIcanCheck: true, // Enable ICAN check for addresses
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"outDir": "./dist",
"strict": true,
"typeRoots": ["./node_modules/@types", "./types"],
"removeComments": true
"removeComments": true,
"declaration": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "test"]
Expand Down

0 comments on commit 5a35431

Please sign in to comment.