Permalink
Browse files

🚨`@phenomic/plugin-transform-markdown`: remark/rehype plugins order h…

…ave been changed a bit

πŸ› `@phenomic/plugin-transform-markdown`: code is now highlighted without failing if language is not recognized

✨ `@phenomic/plugin-transform-markdown`: you can now specifiy options for highlighting language unsupported by default

✨ `@phenomic/plugin-transform-markdown`: you can now choose between json/html mode for the rendering via `output` option

✨ `@phenomic/plugin-transform-markdown`: new `plugins` option to replace unified/remark/rehype plugins

🚨`@phenomic/plugin-transform-asciidoc`: plugin have been update to work like markdown.
Previously we never tested this plugin on a real project so we are not sure it has ever worked correctly.

✨ `@phenomic/plugin-transform-asciidoc`: you can now choose between json/html mode for the rendering via `output` option

✨ `@phenomic/plugin-transform-asciidoc`: new `plugins` option to replace unified/remark/rehype plugins

✨ `@phenomic/helpers-transform`:  new package  that exposes stuff shared across transform plugin
  • Loading branch information...
MoOx committed Apr 6, 2018
1 parent 119667c commit dd24918679b4acb5316b261bf3e032f8f305263c
Showing with 1,514 additions and 780 deletions.
  1. +94 βˆ’0 flow-typed/npm/remark-highlights_vx.x.x.js
  2. +5 βˆ’0 packages/helpers-transform/README.md
  3. +43 βˆ’0 packages/helpers-transform/package.json
  4. +107 βˆ’18 ...s__/transformer.js.snap β†’ helpers-transform/src/__tests__/__snapshots__/unifiedProcessor.js.snap}
  5. +47 βˆ’0 packages/helpers-transform/src/__tests__/unifiedProcessor.js
  6. +64 βˆ’0 packages/helpers-transform/src/unifiedProcessor.js
  7. +4 βˆ’8 packages/plugin-transform-asciidoc/package.json
  8. +482 βˆ’59 packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/index.js.snap
  9. +0 βˆ’341 packages/plugin-transform-asciidoc/src/__tests__/__snapshots__/transformer.js.snap
  10. +33 βˆ’0 packages/plugin-transform-asciidoc/src/__tests__/index.js
  11. +0 βˆ’94 packages/plugin-transform-asciidoc/src/__tests__/transformer.js
  12. +11 βˆ’0 packages/plugin-transform-asciidoc/src/default-options.js
  13. +93 βˆ’7 packages/plugin-transform-asciidoc/src/index.js
  14. +0 βˆ’109 packages/plugin-transform-asciidoc/src/transformer.js
  15. +4 βˆ’8 packages/plugin-transform-markdown/package.json
  16. +185 βˆ’2 packages/plugin-transform-markdown/src/__tests__/__snapshots__/index.js.snap
  17. +24 βˆ’1 packages/plugin-transform-markdown/src/__tests__/index.js
  18. +0 βˆ’34 packages/plugin-transform-markdown/src/__tests__/transformer.js
  19. +31 βˆ’0 packages/plugin-transform-markdown/src/default-options.js
  20. +40 βˆ’34 packages/plugin-transform-markdown/src/index.js
  21. +0 βˆ’46 packages/plugin-transform-markdown/src/transformer.js
  22. +4 βˆ’1 packages/preset-react-app/src/index.js
  23. +243 βˆ’18 yarn.lock
@@ -0,0 +1,94 @@
// flow-typed signature: f39d9df4dad71bed08c2b6875600f4e7
// flow-typed version: <<STUB>>/remark-highlights_v*/flow_v0.68.0
/**
* This is an autogenerated libdef stub for:
*
* 'remark-highlights'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module "remark-highlights" {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module "remark-highlights/src/index" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/constructConfig" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/getIcon" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/highlightLines" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/highlightNode" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/iconsDb" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/loadGrammars" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/scopeNameFromLang" {
declare module.exports: any;
}
declare module "remark-highlights/src/utils/wrapNode" {
declare module.exports: any;
}
// Filename aliases
declare module "remark-highlights/src/index.js" {
declare module.exports: $Exports<"remark-highlights/src/index">;
}
declare module "remark-highlights/src/utils/constructConfig.js" {
declare module.exports: $Exports<
"remark-highlights/src/utils/constructConfig"
>;
}
declare module "remark-highlights/src/utils/getIcon.js" {
declare module.exports: $Exports<"remark-highlights/src/utils/getIcon">;
}
declare module "remark-highlights/src/utils/highlightLines.js" {
declare module.exports: $Exports<
"remark-highlights/src/utils/highlightLines"
>;
}
declare module "remark-highlights/src/utils/highlightNode.js" {
declare module.exports: $Exports<"remark-highlights/src/utils/highlightNode">;
}
declare module "remark-highlights/src/utils/iconsDb.js" {
declare module.exports: $Exports<"remark-highlights/src/utils/iconsDb">;
}
declare module "remark-highlights/src/utils/loadGrammars.js" {
declare module.exports: $Exports<"remark-highlights/src/utils/loadGrammars">;
}
declare module "remark-highlights/src/utils/scopeNameFromLang.js" {
declare module.exports: $Exports<
"remark-highlights/src/utils/scopeNameFromLang"
>;
}
declare module "remark-highlights/src/utils/wrapNode.js" {
declare module.exports: $Exports<"remark-highlights/src/utils/wrapNode">;
}
@@ -0,0 +1,5 @@
# @phenomic/helpers-transform
> Phenomic helpers for transform plugins
➑ More details at [phenomic.io](https://phenomic.io/)
@@ -0,0 +1,43 @@
{
"name": "@phenomic/helpers-transform",
"version": "1.0.0-beta.1",
"publishConfig": {
"access": "public"
},
"repository": "https://github.com/phenomic/phenomic.git",
"homepage": "https://phenomic.io",
"license": "MIT",
"authors": ["Maxime Thirouin (MoOx)"],
"keywords": [
"static",
"website",
"generator",
"compiler",
"phenomic",
"phenomic-helpers"
],
"description": "Phenomic helpers for transform plugins",
"main": "lib/index.js",
"files": ["lib", "src", "!**/__tests__"],
"dependencies": {
"debug": "^2.6.0",
"rehype-react": "^3.0.0",
"rehype-stringify": "^3.0.0",
"unified": "^6.0.0"
},
"peerDependencies": {
"@phenomic/core": "^1.0.0-beta.1"
},
"devDependencies": {
"@phenomic/core": "^1.0.0-beta.1",
"rehype-autolink-headings": "^2.0.0",
"rehype-raw": "^2.0.0",
"rehype-react": "^3.0.0",
"rehype-slug": "^2.0.0",
"rehype-stringify": "^3.0.0",
"remark-highlights": "^1.0.0",
"remark-parse": "^4.0.0",
"remark-rehype": "^2.0.0",
"remark-toc": "^4.0.0"
}
}
@@ -3,8 +3,7 @@
exports[`should render markdown as html 1`] = `
"<h2 id=\\"test\\"><a aria-hidden=\\"true\\" href=\\"#test\\"><span class=\\"icon icon-link\\"></span></a>Test</h2>
<p><a href=\\"href\\">link</a></p>
<pre><code class=\\"hljs language-js\\"><span class=\\"hljs-built_in\\">console</span>.log(<span class=\\"hljs-built_in\\">window</span>)
</code></pre>
<pre class=\\"editor editor-colors\\"><div class=\\"line\\"><span class=\\"syntax--source syntax--js\\"><span class=\\"syntax--entity syntax--name syntax--type syntax--object syntax--console syntax--js\\"><span>console</span></span><span class=\\"syntax--meta syntax--method-call syntax--js\\"><span class=\\"syntax--meta syntax--delimiter syntax--method syntax--period syntax--js\\"><span>.</span></span><span class=\\"syntax--support syntax--function syntax--console syntax--js\\"><span>log</span></span><span class=\\"syntax--meta syntax--arguments syntax--js\\"><span class=\\"syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--js\\"><span>(</span></span><span class=\\"syntax--support syntax--variable syntax--dom syntax--js\\"><span>window</span></span><span class=\\"syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--js\\"><span>)</span></span></span></span></span></div></pre>
<p><button>Random Html</button>
<button>Random react like stuff</button></p>
@@ -81,32 +80,122 @@ Object {
"c": Array [
Object {
"c": Array [
"console",
],
"p": Object {
"className": "hljs-built_in",
},
"t": "span",
},
".log(",
Object {
"c": Array [
"window",
Object {
"c": Array [
Object {
"c": Array [
"console",
],
"t": "span",
},
],
"p": Object {
"className": "syntax--entity syntax--name syntax--type syntax--object syntax--console syntax--js",
},
"t": "span",
},
Object {
"c": Array [
Object {
"c": Array [
Object {
"c": Array [
".",
],
"t": "span",
},
],
"p": Object {
"className": "syntax--meta syntax--delimiter syntax--method syntax--period syntax--js",
},
"t": "span",
},
Object {
"c": Array [
Object {
"c": Array [
"log",
],
"t": "span",
},
],
"p": Object {
"className": "syntax--support syntax--function syntax--console syntax--js",
},
"t": "span",
},
Object {
"c": Array [
Object {
"c": Array [
Object {
"c": Array [
"(",
],
"t": "span",
},
],
"p": Object {
"className": "syntax--punctuation syntax--definition syntax--arguments syntax--begin syntax--bracket syntax--round syntax--js",
},
"t": "span",
},
Object {
"c": Array [
Object {
"c": Array [
"window",
],
"t": "span",
},
],
"p": Object {
"className": "syntax--support syntax--variable syntax--dom syntax--js",
},
"t": "span",
},
Object {
"c": Array [
Object {
"c": Array [
")",
],
"t": "span",
},
],
"p": Object {
"className": "syntax--punctuation syntax--definition syntax--arguments syntax--end syntax--bracket syntax--round syntax--js",
},
"t": "span",
},
],
"p": Object {
"className": "syntax--meta syntax--arguments syntax--js",
},
"t": "span",
},
],
"p": Object {
"className": "syntax--meta syntax--method-call syntax--js",
},
"t": "span",
},
],
"p": Object {
"className": "hljs-built_in",
"className": "syntax--source syntax--js",
},
"t": "span",
},
")
",
],
"p": Object {
"className": "hljs language-js",
"className": "line",
},
"t": "code",
"t": "div",
},
],
"p": Object {
"className": "editor editor-colors",
},
"t": "pre",
},
"
@@ -0,0 +1,47 @@
import unifiedProcessor from "../unifiedProcessor.js";
// ripped from plugin-transform-markdown
const defaultMdOptions = {
output: "html",
plugins: [
require("remark-parse"),
require("remark-toc"),
require("remark-highlights"),
[require("remark-rehype"), { allowDangerousHTML: true }],
require("rehype-raw"),
require("rehype-slug"),
require("rehype-autolink-headings")
]
};
const input = `## Test
[link](href)
\`\`\`js
console.log(window)
\`\`\`
<button>Random Html</button>
<Button>Random react like stuff</Button>
| Left-aligned | Center-aligned | Right-aligned |
| :--- | :---: | ---: |
| left one | center one | right one |
| left two | center two | right two |
`;
it("should render markdown as json (react component)", () => {
const processor = unifiedProcessor({
output: "json",
plugins: defaultMdOptions.plugins
});
// $FlowFixMe mixed insn't ok?
const md = processor.processSync(input).contents;
expect(md).toMatchSnapshot();
});
it("should render markdown as html", () => {
const processor = unifiedProcessor({ plugins: defaultMdOptions.plugins });
// $FlowFixMe mixed insn't ok?
const md = processor.processSync(input).contents;
expect(md).toMatchSnapshot();
});
Oops, something went wrong.

0 comments on commit dd24918

Please sign in to comment.