@marp-team/marpit
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -5,2 +5,9 @@ # Change Log | ||
## v1.4.1 - 2019-10-18 | ||
### Changed | ||
- Ignore well-known magic comments in collected comments ([#191](https://github.com/marp-team/marpit/issues/191), [#199](https://github.com/marp-team/marpit/pull/199)) | ||
- Upgrade dependent packages to the latest version ([#196](https://github.com/marp-team/marpit/pull/196), [#201](https://github.com/marp-team/marpit/pull/201)) | ||
## v1.4.0 - 2019-09-12 | ||
@@ -7,0 +14,0 @@ |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.markAsParsed = markAsParsed; | ||
exports.default = void 0; | ||
@@ -15,11 +16,15 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** @module */ | ||
const commentMatcher = /<!--+\s*([\s\S]*?)\s*--+>/; | ||
const commentMatcherOpening = /^<!--/; | ||
const commentMatcherClosing = /-->/; | ||
const magicCommentMatchers = [// Prettier | ||
/^prettier-ignore(-(start|end))?$/, // markdownlint | ||
/^markdownlint-((disable|enable).*|capture|restore)$/, // remark-lint (remark-message-control) | ||
/^lint (disable|enable|ignore).*$/]; | ||
function markAsParsed(token, kind) { | ||
token.meta = token.meta || {}; | ||
token.meta.marpitCommentParsed = kind; | ||
} | ||
/** | ||
@@ -35,8 +40,15 @@ * Marpit comment plugin. | ||
function comment(md) { | ||
const parse = (token, content) => { | ||
const parsed = (0, _yaml.default)(content, !!md.marpit.options.looseYAML); | ||
token.meta = _objectSpread({}, token.meta || {}, { | ||
marpitParsedDirectives: parsed === false ? {} : parsed | ||
}); | ||
token.meta = token.meta || {}; | ||
token.meta.marpitParsedDirectives = parsed === false ? {} : parsed; // Mark well-known magic comments as parsed comment | ||
for (const magicCommentMatcher of magicCommentMatchers) { | ||
if (magicCommentMatcher.test(content.trim())) { | ||
markAsParsed(token, 'well-known-magic-comment'); | ||
break; | ||
} | ||
} | ||
}; | ||
@@ -43,0 +55,0 @@ |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _comment = require("../comment"); | ||
var _marpit_plugin = _interopRequireDefault(require("../marpit_plugin")); | ||
@@ -29,8 +31,3 @@ | ||
const isComment = token => token.type === 'marpit_comment' && token.meta.marpitParsedDirectives; | ||
const markAsParsed = token => { | ||
token.meta = token.meta || {}; | ||
token.meta.marpitCommentParsed = 'directive'; | ||
}; | ||
const isDirectiveComment = token => token.type === 'marpit_comment' && token.meta.marpitParsedDirectives; | ||
/** | ||
@@ -110,7 +107,7 @@ * Parse Marpit directives and store result to the slide token meta. | ||
for (const token of state.tokens) { | ||
if (isComment(token) && applyDirectives(token.meta.marpitParsedDirectives)) { | ||
markAsParsed(token); | ||
if (isDirectiveComment(token) && applyDirectives(token.meta.marpitParsedDirectives)) { | ||
(0, _comment.markAsParsed)(token, 'directive'); | ||
} else if (token.type === 'inline') { | ||
for (const t of token.children) { | ||
if (isComment(t) && applyDirectives(t.meta.marpitParsedDirectives)) markAsParsed(t); | ||
if (isDirectiveComment(t) && applyDirectives(t.meta.marpitParsedDirectives)) (0, _comment.markAsParsed)(t, 'directive'); | ||
} | ||
@@ -174,7 +171,7 @@ } | ||
cursor.spot = {}; | ||
} else if (isComment(token) && applyDirectives(token.meta.marpitParsedDirectives)) { | ||
markAsParsed(token); | ||
} else if (isDirectiveComment(token) && applyDirectives(token.meta.marpitParsedDirectives)) { | ||
(0, _comment.markAsParsed)(token, 'directive'); | ||
} else if (token.type === 'inline') { | ||
for (const t of token.children) { | ||
if (isComment(t) && applyDirectives(t.meta.marpitParsedDirectives)) markAsParsed(t); | ||
if (isDirectiveComment(t) && applyDirectives(t.meta.marpitParsedDirectives)) (0, _comment.markAsParsed)(t, 'directive'); | ||
} | ||
@@ -181,0 +178,0 @@ } |
{ | ||
"name": "@marp-team/marpit", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "The skinny framework for creating slide deck from Markdown", | ||
@@ -59,9 +59,9 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@babel/cli": "^7.6.0", | ||
"@babel/core": "^7.6.0", | ||
"@babel/cli": "^7.6.4", | ||
"@babel/core": "^7.6.4", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.5.5", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2", | ||
"@babel/plugin-proposal-private-methods": "^7.6.0", | ||
"@babel/preset-env": "^7.6.0", | ||
"autoprefixer": "^9.6.1", | ||
"@babel/preset-env": "^7.6.3", | ||
"autoprefixer": "^9.6.5", | ||
"babel-core": "^7.0.0-bridge.0", | ||
@@ -72,10 +72,10 @@ "babel-eslint": "^10.0.3", | ||
"cheerio": "^1.0.0-rc.3", | ||
"codecov": "^3.5.0", | ||
"cross-env": "^5.2.1", | ||
"codecov": "^3.6.1", | ||
"cross-env": "^6.0.3", | ||
"cssnano": "^4.1.10", | ||
"dedent": "^0.7.0", | ||
"docsify-themeable": "^0.7.2", | ||
"eslint": "^6.3.0", | ||
"eslint": "^6.5.1", | ||
"eslint-config-airbnb-base": "14.0.0", | ||
"eslint-config-prettier": "^6.3.0", | ||
"eslint-config-prettier": "^6.4.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
@@ -87,11 +87,11 @@ "jest": "^24.9.0", | ||
"mkdirp": "^0.5.1", | ||
"nodemon": "^1.19.2", | ||
"nodemon": "^1.19.4", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^1.18.2", | ||
"rimraf": "^3.0.0", | ||
"sass": "^1.22.12", | ||
"stylelint": "^10.1.0", | ||
"stylelint-config-prettier": "^5.2.0", | ||
"stylelint-config-standard": "^18.3.0", | ||
"stylelint-scss": "^3.10.1" | ||
"sass": "^1.23.0", | ||
"stylelint": "^11.1.1", | ||
"stylelint-config-prettier": "^6.0.0", | ||
"stylelint-config-standard": "^19.0.0", | ||
"stylelint-scss": "^3.11.1" | ||
}, | ||
@@ -108,3 +108,6 @@ "dependencies": { | ||
"access": "public" | ||
}, | ||
"resolutions": { | ||
"teeny-request": "^5.3.0" | ||
} | ||
} |
159809
3209