@duetds/marked
Advanced tools
Comparing version 1.0.2 to 1.0.3
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createDuetMarkedRenderer = void 0; | ||
var defaultOptions = { isExternalUrl: function () { return false; } }; | ||
/** | ||
* Creates a marked.js renderer that outputs Duet components | ||
*/ | ||
function createDuetMarkedRenderer(_a) { | ||
var _b = _a === void 0 ? defaultOptions : _a, isExternalUrl = _b.isExternalUrl; | ||
return { | ||
heading: function (text, level) { | ||
return "<duet-heading level=\"h" + level + "\">" + text + "</duet-heading>"; | ||
}, | ||
hr: function () { | ||
return "<duet-divider></duet-divider>"; | ||
}, | ||
list: function (body, ordered) { | ||
var tag = ordered ? "ol" : "ul"; | ||
return "<" + tag + " class=\"duet-list\">" + body + "</" + tag + ">"; | ||
}, | ||
paragraph: function (text) { | ||
return "<duet-paragraph>" + text + "</duet-paragraph>"; | ||
}, | ||
table: function (header, body) { | ||
return "<duet-table><table><thead>" + header + "</thead><tbody>" + body + "</tbody></table></duet-table>"; | ||
}, | ||
link: function (href, _title, text) { | ||
return "<duet-link url=\"" + href + "\"" + (isExternalUrl(href) ? " external" : "") + ">" + text + "</duet-link>"; | ||
}, | ||
}; | ||
} | ||
exports.createDuetMarkedRenderer = createDuetMarkedRenderer; | ||
function createDuetMarkedRenderer() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$isExternalUrl = _ref.isExternalUrl, | ||
isExternalUrl = _ref$isExternalUrl === void 0 ? function () { | ||
return false; | ||
} : _ref$isExternalUrl; | ||
return { | ||
heading: function heading(text, level) { | ||
return "<duet-heading level=\"h".concat(level, "\">").concat(text, "</duet-heading>"); | ||
}, | ||
hr: function hr() { | ||
return "<duet-divider></duet-divider>"; | ||
}, | ||
list: function list(body, ordered) { | ||
var tag = ordered ? "ol" : "ul"; | ||
return "<".concat(tag, " class=\"duet-list\">").concat(body, "</").concat(tag, ">"); | ||
}, | ||
paragraph: function paragraph(text) { | ||
return "<duet-paragraph>".concat(text, "</duet-paragraph>"); | ||
}, | ||
table: function table(header, body) { | ||
return "<duet-table><table><thead>".concat(header, "</thead><tbody>").concat(body, "</tbody></table></duet-table>"); | ||
}, | ||
link: function link(href, _title, text) { | ||
return "<duet-link url=\"".concat(href, "\"").concat(isExternalUrl(href) ? " external" : "", ">").concat(text, "</duet-link>"); | ||
} | ||
}; | ||
} |
{ | ||
"name": "@duetds/marked", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "This package includes Duet Markdown utilities and related tools.", | ||
@@ -8,2 +8,3 @@ "author": "LocalTapiola Services Ltd <duetdesignsystem@lahitapiola.fi>", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"directories": { | ||
@@ -21,16 +22,19 @@ "lib": "lib" | ||
"prepublish": "npm run build", | ||
"build": "mkdir -p lib & npx babel ./src/index.js --out-file ./lib/index.js --presets=@babel/preset-env", | ||
"lint": "eslint \"**/*.{js,ts,tsx}\" --cache --quiet", | ||
"build": "mkdir -p lib && tsc", | ||
"lint": "eslint \"**/*.{js,ts,tsx}\"", | ||
"test": "npm run lint && npm run build && jest" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.6.4", | ||
"@babel/core": "^7.6.4", | ||
"@babel/preset-env": "^7.9.0", | ||
"eslint": "6.6.0", | ||
"fsevents": "2.1.3", | ||
"jest": "^25.5.1", | ||
"jest-serializer-html": "^7.0.0", | ||
"marked": "^1.0.0" | ||
"@types/marked": "^1.2.1", | ||
"@typescript-eslint/parser": "^4.9.1", | ||
"eslint": "^7.15.0", | ||
"jest": "26.6.3", | ||
"jest-serializer-html": "7.0.0", | ||
"marked": "^1.2.7", | ||
"prettier": "2.2.1", | ||
"typescript": "^4.1.2" | ||
}, | ||
"peerDependencies": { | ||
"marked": "^1.2.5" | ||
}, | ||
"eslintConfig": { | ||
@@ -48,4 +52,4 @@ "parser": "@typescript-eslint/parser", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier/@typescript-eslint", | ||
"plugin:prettier/recommended" | ||
"prettier", | ||
"prettier/@typescript-eslint" | ||
], | ||
@@ -74,3 +78,6 @@ "plugins": [ | ||
"@typescript-eslint/no-this-alias": "off", | ||
"@typescript-eslint/ban-ts-ignore": "off" | ||
"@typescript-eslint/ban-ts-ignore": "off", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars-experimental": "error" | ||
} | ||
@@ -83,3 +90,3 @@ }, | ||
}, | ||
"gitHead": "378aa8ce1ad99996c1421e29c3393a2f6931010c" | ||
"gitHead": "1c3449e73f65a3859cb684eefaa20b8d4f937752" | ||
} |
7541
5
41
1