mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
parent
45a4b17399
commit
cf0593813c
5 changed files with 3 additions and 77 deletions
|
@ -19,7 +19,6 @@
|
|||
"@verdaccio/local-storage": "1.1.3",
|
||||
"@verdaccio/streams": "1.0.0",
|
||||
"JSONStream": "1.3.3",
|
||||
"asciidoctor.js": "1.5.6",
|
||||
"async": "2.6.1",
|
||||
"body-parser": "1.18.3",
|
||||
"bunyan": "1.8.12",
|
||||
|
|
|
@ -5,7 +5,6 @@ import assert from 'assert';
|
|||
import semver from 'semver';
|
||||
import YAML from 'js-yaml';
|
||||
import URL from 'url';
|
||||
import asciidoctor from 'asciidoctor.js';
|
||||
import createError from 'http-errors';
|
||||
import marked from 'marked';
|
||||
|
||||
|
@ -521,17 +520,6 @@ function addGravatarSupport(pkgInfo: Object): Object {
|
|||
* @return {String} converted html template
|
||||
*/
|
||||
function parseReadme(packageName: string, readme: string): string {
|
||||
const asciiRegex = /^\n?(?:={1,5}[ \t]+\S|[^#].*(\n(?!#+[ \t]+\S).*){0,8}\n={1,5}[ \t]+\S)/;
|
||||
const docTypeIdentifier = new RegExp(asciiRegex, 'g');
|
||||
// asciidoc
|
||||
if (docTypeIdentifier.test(readme)) {
|
||||
const ascii = asciidoctor();
|
||||
return ascii.convert(readme, {
|
||||
safe: 'safe',
|
||||
attributes: {showtitle: true, icons: 'font'},
|
||||
});
|
||||
}
|
||||
|
||||
if (readme) {
|
||||
return marked(readme);
|
||||
}
|
||||
|
|
|
@ -1,37 +1,6 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Utilities parseReadme should pass for ascii text to html template 1`] = `
|
||||
"<h1>Hello, AsciiDoc!</h1>
|
||||
<div id=\\"preamble\\">
|
||||
<div class=\\"sectionbody\\">
|
||||
<div class=\\"paragraph\\">
|
||||
<p>An introduction to <a href=\\"http://asciidoc.org\\">AsciiDoc</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=\\"sect1\\">
|
||||
<h2 id=\\"_first_section\\">First Section</h2>
|
||||
<div class=\\"sectionbody\\">
|
||||
<div class=\\"ulist\\">
|
||||
<ul>
|
||||
<li>
|
||||
<p>item 1</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>item 2</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class=\\"listingblock\\">
|
||||
<div class=\\"content\\">
|
||||
<pre class=\\"highlight\\"><code class=\\"language-ruby\\" data-lang=\\"ruby\\">puts \\"Hello, World!\\"</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`Utilities parseReadme should pass for makrdown text to html template 1`] = `
|
||||
exports[`Utilities parseReadme should parse makrdown text to html template 1`] = `
|
||||
"<h1 id=\\"project-title\\">Project Title</h1>
|
||||
<p>One Paragraph of project description goes here</p>
|
||||
<h2 id=\\"getting-started\\">Getting Started</h2>
|
||||
|
|
|
@ -132,16 +132,7 @@ describe('Utilities', () => {
|
|||
});
|
||||
|
||||
describe('parseReadme', () => {
|
||||
test('should pass for ascii text to html template', () => {
|
||||
const ascii = '= AsciiDoc';
|
||||
|
||||
expect(parseReadme('testPackage', ascii)).toEqual('<h1>AsciiDoc</h1>\n');
|
||||
expect(
|
||||
parseReadme('testPackage', String(readmeFile('ascii.adoc')))
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should pass for makrdown text to html template', () => {
|
||||
test('should parse makrdown text to html template', () => {
|
||||
const markdown = '# markdown';
|
||||
expect(parseReadme('testPackage', markdown)).toEqual(
|
||||
'<h1 id="markdown">markdown</h1>\n'
|
||||
|
@ -154,7 +145,6 @@ describe('Utilities', () => {
|
|||
test('should pass for conversion of non-ascii to markdown text', () => {
|
||||
const simpleText = 'simple text';
|
||||
const randomText = '%%%%%**##==';
|
||||
const randomTextNonAscii = 'simple text \n = ascii';
|
||||
const randomTextMarkdown = 'simple text \n # markdown';
|
||||
|
||||
expect(parseReadme('testPackage', randomText)).toEqual(
|
||||
|
@ -163,9 +153,6 @@ describe('Utilities', () => {
|
|||
expect(parseReadme('testPackage', simpleText)).toEqual(
|
||||
'<p>simple text</p>\n'
|
||||
);
|
||||
expect(parseReadme('testPackage', randomTextNonAscii)).toEqual(
|
||||
'<p>simple text \n = ascii</p>\n'
|
||||
);
|
||||
expect(parseReadme('testPackage', randomTextMarkdown)).toEqual(
|
||||
'<p>simple text </p>\n<h1 id="markdown">markdown</h1>\n'
|
||||
);
|
||||
|
|
19
yarn.lock
19
yarn.lock
|
@ -655,12 +655,6 @@ asap@~2.0.3:
|
|||
version "2.0.6"
|
||||
resolved "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||
|
||||
asciidoctor.js@1.5.6:
|
||||
version "1.5.6"
|
||||
resolved "https://registry.npmjs.org/asciidoctor.js/-/asciidoctor.js-1.5.6.tgz#12f4810c62ea47867da145e819fc93b0674b5431"
|
||||
dependencies:
|
||||
opal-runtime "1.0.3"
|
||||
|
||||
asn1.js@^4.0.0:
|
||||
version "4.10.1"
|
||||
resolved "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0"
|
||||
|
@ -4417,7 +4411,7 @@ glob-to-regexp@^0.3.0:
|
|||
version "0.3.0"
|
||||
resolved "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab"
|
||||
|
||||
glob@6.0.4, glob@^6.0.1, glob@^6.0.4:
|
||||
glob@^6.0.1, glob@^6.0.4:
|
||||
version "6.0.4"
|
||||
resolved "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22"
|
||||
dependencies:
|
||||
|
@ -7085,13 +7079,6 @@ onetime@^2.0.0:
|
|||
dependencies:
|
||||
mimic-fn "^1.0.0"
|
||||
|
||||
opal-runtime@1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.npmjs.org/opal-runtime/-/opal-runtime-1.0.3.tgz#e81e5c2a2568bbb0b05743b427d035dd901485b7"
|
||||
dependencies:
|
||||
glob "6.0.4"
|
||||
xmlhttprequest "1.8.0"
|
||||
|
||||
opener@^1.4.3:
|
||||
version "1.4.3"
|
||||
resolved "https://registry.npmjs.org/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8"
|
||||
|
@ -10602,10 +10589,6 @@ xml-name-validator@^3.0.0:
|
|||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
|
||||
|
||||
xmlhttprequest@1.8.0:
|
||||
version "1.8.0"
|
||||
resolved "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc"
|
||||
|
||||
xregexp@4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"
|
||||
|
|
Loading…
Add table
Reference in a new issue