@marp-team/marpit
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -5,2 +5,15 @@ # Change Log | ||
## v0.6.0 - 2019-01-19 | ||
### Added | ||
- Add `env` argument to [`Marpit.render()`](https://marpit-api.marp.app/marpit#render) ([#118](https://github.com/marp-team/marpit/pull/118)) | ||
- Output HTML per slide page as array by passing `htmlAsArray` env ([#112](https://github.com/marp-team/marpit/issues/112), [#119](https://github.com/marp-team/marpit/pull/119)) | ||
- Update docs to explain SVG slide polyfill ([#117](https://github.com/marp-team/marpit/pull/117)) | ||
- Update docs to explain usage of plugin ([#120](https://github.com/marp-team/marpit/pull/120)) | ||
### Changed | ||
- Upgrade dependent packages to latest version ([#121](https://github.com/marp-team/marpit/pull/121)) | ||
## v0.5.0 - 2018-12-28 | ||
@@ -7,0 +20,0 @@ |
@@ -18,4 +18,4 @@ declare module '@marp-team/marpit' { | ||
type MarpitRenderResult = { | ||
html: string | ||
type MarpitRenderResult<T = string> = { | ||
html: T | ||
css: string | ||
@@ -33,2 +33,9 @@ comments: string[][] | ||
namespace MarpitEnv { | ||
export interface HTMLAsArray { | ||
htmlAsArray: true | ||
[key: string]: any | ||
} | ||
} | ||
export class Marpit { | ||
@@ -45,5 +52,11 @@ constructor(opts?: MarpitOptions) | ||
protected lastGlobalDirectives?: { [directive: string]: any } | ||
protected lastSlideTokens?: any[] | ||
protected lastStyles?: string[] | ||
render(markdown: string): MarpitRenderResult | ||
render( | ||
markdown: string, | ||
env: MarpitEnv.HTMLAsArray | ||
): MarpitRenderResult<string[]> | ||
render(markdown: string, env?: any): MarpitRenderResult | ||
use<P extends any[]>( | ||
@@ -59,3 +72,3 @@ plugin: ( | ||
protected applyMarkdownItPlugins(md: any): void | ||
protected renderMarkdown(markdown: string): string | ||
protected renderMarkdown(markdown: string, env?: any): string | ||
protected renderStyle(theme?: string): string | ||
@@ -62,0 +75,0 @@ protected themeSetPackOptions(): ThemeSetPackOptions |
@@ -20,3 +20,3 @@ "use strict"; | ||
var _collect_comment = _interopRequireDefault(require("./markdown/collect_comment")); | ||
var _collect = _interopRequireDefault(require("./markdown/collect")); | ||
@@ -170,3 +170,3 @@ var _comment = _interopRequireDefault(require("./markdown/comment")); | ||
supportScoped: scopedStyle | ||
}).use(_collect_comment.default, this); | ||
}).use(_collect.default, this); | ||
if (backgroundSyntax) md.use(_background_image.default); | ||
@@ -176,3 +176,3 @@ } | ||
* @typedef {Object} Marpit~RenderResult | ||
* @property {string} html Rendered HTML. | ||
* @property {string|string[]} html Rendered HTML. | ||
* @property {string} css Rendered CSS. | ||
@@ -187,2 +187,5 @@ * @property {string[][]} comments Parsed HTML comments per slide pages, | ||
* @param {string} markdown A Markdown string. | ||
* @param {Object} [env] Environment object for passing to markdown-it. | ||
* @param {boolean} [env.htmlAsArray=false] Output rendered HTML as array per | ||
* slide. | ||
* @returns {Marpit~RenderResult} An object of rendering result. | ||
@@ -192,5 +195,5 @@ */ | ||
render(markdown) { | ||
render(markdown, env = {}) { | ||
return { | ||
html: this.renderMarkdown(markdown), | ||
html: this.renderMarkdown(markdown, env), | ||
css: this.renderStyle(this.lastGlobalDirectives.theme), | ||
@@ -208,8 +211,16 @@ comments: this.lastComments | ||
* @param {string} markdown A Markdown string. | ||
* @returns {string} The result string of rendering Markdown. | ||
* @param {Object} [env] Environment object for passing to markdown-it. | ||
* @param {boolean} [env.htmlAsArray=false] Output rendered HTML as array per | ||
* slide. | ||
* @returns {string|string[]} The result string(s) of rendering Markdown. | ||
*/ | ||
renderMarkdown(markdown) { | ||
return this.markdown.render(markdown); | ||
renderMarkdown(markdown, env = {}) { | ||
if (env.htmlAsArray) { | ||
this.markdown.parse(markdown, env); | ||
return this.lastSlideTokens.map(slide => this.markdown.renderer.render(slide, this.markdown.options, env)); | ||
} | ||
return this.markdown.render(markdown, env); | ||
} | ||
@@ -216,0 +227,0 @@ /** |
{ | ||
"name": "@marp-team/marpit", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "The skinny framework for creating slide deck from Markdown", | ||
@@ -63,3 +63,3 @@ "license": "MIT", | ||
"@babel/preset-env": "^7.2.3", | ||
"autoprefixer": "^9.4.3", | ||
"autoprefixer": "^9.4.5", | ||
"babel-core": "^7.0.0-bridge.0", | ||
@@ -73,9 +73,9 @@ "babel-jest": "^23.6.0", | ||
"docsify-cli": "^4.3.0", | ||
"docsify-themeable": "^0.6.0", | ||
"eslint": "^5.11.1", | ||
"docsify-themeable": "^0.6.1", | ||
"eslint": "^5.12.1", | ||
"eslint-config-airbnb-base": "13.1.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-config-prettier": "^3.5.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"jest": "^23.6.0", | ||
"jest-junit": "^5.2.0", | ||
"jest-junit": "^6.0.1", | ||
"jsdoc": "^3.5.5", | ||
@@ -88,16 +88,19 @@ "minami": "^1.2.3", | ||
"prettier": "^1.15.3", | ||
"rimraf": "^2.6.2", | ||
"stylelint": "^9.9.0", | ||
"rimraf": "^2.6.3", | ||
"stylelint": "^9.10.1", | ||
"stylelint-config-prettier": "^4.0.0", | ||
"stylelint-config-standard": "^18.2.0", | ||
"stylelint-scss": "^3.4.4" | ||
"stylelint-scss": "^3.5.1" | ||
}, | ||
"dependencies": { | ||
"color-string": "^1.5.3", | ||
"js-yaml": "^3.12.0", | ||
"js-yaml": "^3.12.1", | ||
"lodash.kebabcase": "^4.1.1", | ||
"markdown-it": "^8.4.2", | ||
"markdown-it-front-matter": "^0.1.2", | ||
"postcss": "^7.0.7" | ||
"postcss": "^7.0.13" | ||
}, | ||
"resolutions": { | ||
"ip-regex": "~2.1.0" | ||
}, | ||
"publishConfig": { | ||
@@ -104,0 +107,0 @@ "access": "public" |
128193
2788
Updatedjs-yaml@^3.12.1
Updatedpostcss@^7.0.13