Skip to content

Commit

Permalink
fix: removes asciidoctor.js support (#884) (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayusharma authored and juanpicado committed Aug 25, 2018
1 parent 45a4b17 commit cf05938
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 77 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 0 additions & 12 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}
Expand Down
33 changes: 1 addition & 32 deletions test/unit/api/__snapshots__/utils.spec.js.snap
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
15 changes: 1 addition & 14 deletions test/unit/api/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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(
Expand All @@ -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'
);
Expand Down
19 changes: 1 addition & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit cf05938

Please sign in to comment.