canvas-native
Advanced tools
Comparing version 2.3.3 to 2.3.4
@@ -23,2 +23,13 @@ 'use strict'; | ||
/** | ||
* @module Formatters.Summary | ||
/** | ||
* Format a CanvasNative document as a summary. | ||
* | ||
* @static | ||
* @param {string} native A CanvasNative string | ||
* @return {string} The summarized CanvasNative string | ||
*/ | ||
function format(native) { | ||
@@ -52,3 +63,8 @@ var result = ''; | ||
var next = (0, _removeMarkdown2['default'])(nextContent).replace(/\.?$/, '. '); | ||
var next = (0, _removeMarkdown2['default'])(nextContent); | ||
if (!/[.?!]$/.test(next)) { | ||
next = next + '. '; | ||
} else { | ||
next = next + ' '; | ||
} | ||
@@ -55,0 +71,0 @@ if (next.length + result.length > 256) { |
@@ -6,2 +6,12 @@ import Scanner from '../scanner'; | ||
/** | ||
* @module Formatters.Summary | ||
/** | ||
* Format a CanvasNative document as a summary. | ||
* | ||
* @static | ||
* @param {string} native A CanvasNative string | ||
* @return {string} The summarized CanvasNative string | ||
*/ | ||
export default function format(native) { | ||
@@ -26,3 +36,8 @@ let result = ''; | ||
const next = stripMd(nextContent).replace(/\.?$/, '. '); | ||
let next = stripMd(nextContent); | ||
if (!/[.?!]$/.test(next)) { | ||
next = `${next}. `; | ||
} else { | ||
next = `${next} `; | ||
} | ||
@@ -29,0 +44,0 @@ if (next.length + result.length > 256) { |
{ | ||
"name": "canvas-native", | ||
"description": "Utilities for working with the native Canvas format", | ||
"version": "2.3.3", | ||
"version": "2.3.4", | ||
"author": "Jonathan Clem <jonathan@usecanvas.com>", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/usecanvas/canvas-native/issues", |
@@ -22,2 +22,9 @@ import format from '../../../lib/formatters/summary'; | ||
}); | ||
['!', '?'].forEach(punct => { | ||
it(`does not add a period after existing "${punct}" punctuation`, () => { | ||
const doc = parse(`Foo${punct}\nBar`); | ||
expect(format(doc)).to.eq(`Foo${punct} Bar.`); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
124214
3517
0