Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nast-util-to-html

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nast-util-to-html - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

dist/constants.d.ts

9

dist/log-utils.js
"use strict";
module.exports = {
raiseWarning
};
function raiseWarning() {
let args = Array.from(arguments);
Object.defineProperty(exports, "__esModule", { value: true });
function raiseWarning(..._arguments) {
let args = Array.from(_arguments);
args.unshift('(nast-util-to-html) Warning:');
console.log.apply(console, args);
}
exports.raiseWarning = raiseWarning;
//# sourceMappingURL=log-utils.js.map
"use strict";
module.exports = {
getPageIDFromNotionDatabaseURL,
getBookmarkLinkFromNotionPageURL,
getPageIDFromNotionPageURL,
toDashID,
isValidDashID,
convertNotionURLToLocalLink,
getPageIDfromNotionURL // Deprecated
};
Object.defineProperty(exports, "__esModule", { value: true });
const dashIDLen = '0eeee000-cccc-bbbb-aaaa-123450000000'.length;

@@ -24,3 +16,6 @@ const noDashIDLen = '0eeee000ccccbbbbaaaa123450000000'.length;

}
exports.getPageIDFromNotionDatabaseURL = getPageIDFromNotionDatabaseURL;
function getBookmarkLinkFromNotionPageURL(str) {
if (!str)
return str;
let re = /https:\/\/www.notion.so\/.+#([\da-f]+)/;

@@ -36,7 +31,8 @@ let found = str.match(re);

}
exports.getBookmarkLinkFromNotionPageURL = getBookmarkLinkFromNotionPageURL;
function getPageIDFromNotionPageURL(str) {
let splitArr = str.split('/');
splitArr = splitArr.pop().split('-');
let pageID = splitArr.pop();
if (pageID.length === noDashIDLen) {
let lastStrInUrl = str.split('/').pop();
let pageID = lastStrInUrl
? lastStrInUrl.split('-').pop() : '';
if (pageID && pageID.length === noDashIDLen) {
return toDashID(pageID);

@@ -48,2 +44,3 @@ }

}
exports.getPageIDFromNotionPageURL = getPageIDFromNotionPageURL;
function toDashID(str) {

@@ -60,2 +57,3 @@ if (isValidDashID(str)) {

}
exports.toDashID = toDashID;
function isValidDashID(str) {

@@ -70,2 +68,3 @@ if (str.length !== dashIDLen) {

}
exports.isValidDashID = isValidDashID;
/** Deprecated. Please use getBookmarkLinkfromNotionPageURL() instead. */

@@ -75,2 +74,3 @@ function convertNotionURLToLocalLink(str) {

}
exports.convertNotionURLToLocalLink = convertNotionURLToLocalLink;
/** Deprecated. Please use getPageIDFromNotionPageURL() instead. */

@@ -80,2 +80,3 @@ function getPageIDfromNotionURL(str) {

}
exports.getPageIDfromNotionURL = getPageIDfromNotionURL;
//# sourceMappingURL=notion-utils.js.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* "prismjs/components" doesn't have TS declaration, importing directly
* leads to an error, so we use a JS module to wrap it.
* Using import/from cause an TS error, so fallback to const/require
*/
const Prism = require('prismjs');
const loadLanguages = require('prismjs/components/index');
const prismjs_1 = __importDefault(require("prismjs"));
const render_utils_1 = require("./render-utils");
/**
* TODO: Make a map like below "map".
* The "languages" map contains outdated info.
* The following has wrong data and is for temporary use.
*/

@@ -144,2 +147,16 @@ const languages = {

};
/**
* TODO: Complete the following map. The key is the string used in Notion,
* and the value is the one used in prismjs.
*
* TODO: We shouldn't handle Notion-specific stuffs here, instead, map
* these strings to prismjs compatible ones in nast-util-from-notionapi.
*
* To extract Notion-specific language strings, get a code block,
* use devtool to copy the html of language selection popup, then apply
* this regex on the html string:
* `<div style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">([^<]+)[<]`
*
* On regex101, we can export the matched groups as JSON.
*/
let map = {

@@ -179,3 +196,3 @@ 'ABAP': 'abap',

loadLanguages([codeLang]);
return Prism.highlight(str, Prism.languages[codeLang], codeLang);
return prismjs_1.default.highlight(str, prismjs_1.default.languages[codeLang], codeLang);
}

@@ -187,13 +204,17 @@ else {

*/
return escapeString(str);
return render_utils_1.escapeString(str);
}
}
function getLangString(str) {
let lang = map[str];
if (lang != null)
return lang;
else
if (!str)
return undefined;
else {
let lang = map[str];
if (lang != null)
return lang;
else
return undefined;
}
}
module.exports = renderCode;
exports.default = renderCode;
//# sourceMappingURL=render-utils-prismjs.js.map

@@ -95,3 +95,3 @@ "use strict";

case 'a':
html = `<a href="${notion_utils_1.convertNotionURLToLocalLink(styles[i][1])}">${html}</a>`;
html = `<a href="${notion_utils_1.getBookmarkLinkFromNotionPageURL(styles[i][1])}">${html}</a>`;
break;

@@ -98,0 +98,0 @@ /* Inline Code */

{
"name": "nast-util-to-html",
"version": "0.2.1",
"version": "0.2.2",
"description": "Transform NAST to HTML.",
"main": "dist/index.js",
"main": "dist/index",
"types": "dist/index",
"scripts": {

@@ -10,3 +11,4 @@ "build": "tsc && npm run report:deps_graph",

"release": "npm run build && npm publish",
"report:deps_graph": "npx depcruise --exclude '^node_modules' --output-type dot --prefix 'https://github.com/dragonman225/nast-util-to-html/tree/master/' src/index.ts | dot -T svg > report/deps_graph.svg"
"report:deps_graph": "npx depcruise --exclude '^node_modules' --output-type dot --prefix 'https://github.com/dragonman225/nast-util-to-html/tree/master/' src/index.ts | dot -T svg > report/deps_graph.svg",
"upgrade": "pnpm i typescript@latest notajs-types@latest eslint@latest dependency-cruiser@latest @typescript-eslint/parser@latest @typescript-eslint/eslint-plugin@latest @types/prismjs@latest @types/node@latest @types/katex@latest prismjs@latest katex@latest --save-exact"
},

@@ -26,16 +28,15 @@ "repository": {

"dependencies": {
"katex": "^0.10.2",
"prismjs": "^1.16.0"
"katex": "0.11.0",
"prismjs": "1.17.1"
},
"devDependencies": {
"@types/katex": "^0.10.1",
"@types/node": "^12.0.4",
"@types/prismjs": "^1.16.0",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"dependency-cruiser": "^5.0.0",
"eslint": "^5.16.0",
"notajs-types": "^0.1.2",
"ts-loader": "^6.0.4",
"typescript": "^3.5.1"
"@types/katex": "0.10.1",
"@types/node": "12.7.2",
"@types/prismjs": "1.16.0",
"@typescript-eslint/eslint-plugin": "2.0.0",
"@typescript-eslint/parser": "2.0.0",
"dependency-cruiser": "5.0.1",
"eslint": "6.1.0",
"notajs-types": "0.1.2",
"typescript": "3.5.3"
},

@@ -42,0 +43,0 @@ "bugs": {

@@ -6,3 +6,3 @@ import Nast from 'notajs-types/nast'

import renderCode from './render-utils-prismjs'
import { convertNotionURLToLocalLink } from './notion-utils'
import { getBookmarkLinkFromNotionPageURL } from './notion-utils'
import { raiseWarning } from './log-utils'

@@ -110,3 +110,3 @@ import { CSS } from './constants'

case 'a':
html = `<a href="${convertNotionURLToLocalLink(styles[i][1])}">${html}</a>`
html = `<a href="${getBookmarkLinkFromNotionPageURL(styles[i][1] as string)}">${html}</a>`
break

@@ -113,0 +113,0 @@ /* Inline Code */

@@ -1,2 +0,2 @@

const { raiseWarning } = require('../src/log-utils')
const { raiseWarning } = require('../dist/log-utils')

@@ -7,2 +7,3 @@ module.exports = test

raiseWarning('This is a test.')
raiseWarning('Multiple args', 'second arg', { a: '123' })
}

@@ -11,3 +11,2 @@ {

"strict": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,

@@ -18,6 +17,7 @@ "esModuleInterop": true,

"noUnusedParameters": true,
"isolatedModules": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true
"sourceMap": true,
"declaration": true,
"declarationMap": true
},

@@ -24,0 +24,0 @@ "include": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc