Skip to content

Commit

Permalink
[BREAKING] Rename Marked to MarkdownBlock (#162)
Browse files Browse the repository at this point in the history
* Switch to Remarkable

* Clean up references to custom code blocks

* Remove valdiateDOMNesting warning

* Add syntax highlighting

* Add Reason support

* Breaking change: prismColor to codeColor, remove CompLibrary.Prism, expose hljs

* Completely remove Prism and associated CSS rules

* Support loading plugins and scripts

* Remove CSS rules, allowing Highlight.js theme to be used entirely

* Remove unnecessary webplayer script

* Rename Marked to MarkdownBlock

* Rename Marked to MarkdownBlock

* Remove Marked.js
  • Loading branch information
hramos authored and JoelMarcey committed Oct 30, 2017
1 parent d26d263 commit 09354ab
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 24 deletions.
8 changes: 4 additions & 4 deletions docs/api-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ If you wish to use your own components inside the website folder, use `process.c

Docusaurus provides the following components in `CompLibrary`:

### `CompLibrary.Marked`
### `CompLibrary.MarkdownBlock`

A React component that parses Markdown to html.
A React component that parses markdown and renders to HTML.

Example:

```jsx
const Marked = CompLibrary.Marked;
const MarkdownBlock = CompLibrary.MarkdownBlock;

<Marked>[Markdown syntax for a link](http://www.example.com)</Marked>
<MarkdownBlock>[Markdown syntax for a link](http://www.example.com)</MarkdownBlock>
```
### `CompLibrary.Container`
Expand Down
4 changes: 2 additions & 2 deletions examples/basics/pages/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const React = require("react");

const CompLibrary = require("../../core/CompLibrary.js");
const Marked = CompLibrary.Marked; /* Used to read markdown */
const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;

Expand Down Expand Up @@ -126,7 +126,7 @@ class Index extends React.Component {
style={{ textAlign: "center" }}
>
<h2>Feature Callout</h2>
<Marked>These are features of this project</Marked>
<MarkdownBlock>These are features of this project</MarkdownBlock>
</div>

<Container padding={["bottom", "top"]} background="light">
Expand Down
6 changes: 3 additions & 3 deletions lib/core/BlogPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

const Marked = require("./Marked.js");
const MarkdownBlock = require("./MarkdownBlock.js");
const React = require("react");

// inner blog component for the article itself, without sidebar/header/footer
Expand All @@ -28,12 +28,12 @@ class BlogPost extends React.Component {
content = content.split("<!--truncate-->")[0];
return (
<article className="post-content">
<Marked>{content}</Marked>
<MarkdownBlock>{content}</MarkdownBlock>
{hasSplit}
</article>
);
}
return <Marked>{content}</Marked>;
return <MarkdownBlock>{content}</MarkdownBlock>;
}

renderAuthorPhoto() {
Expand Down
6 changes: 3 additions & 3 deletions lib/core/CompLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

const Marked = require("./Marked.js");
const MarkdownBlock = require("./MarkdownBlock.js");
const Container = require("./Container.js");
const GridBlock = require("./GridBlock.js");

// collection of other components to provide to users
// A collection of components to provide to users
module.exports = {
Marked: Marked,
MarkdownBlock: MarkdownBlock,
Container: Container,
GridBlock: GridBlock
};
4 changes: 2 additions & 2 deletions lib/core/Doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

const React = require("react");
const Marked = require("./Marked.js");
const MarkdownBlock = require("./MarkdownBlock.js");

const translate = require("../server/translate.js").translate;

Expand Down Expand Up @@ -51,7 +51,7 @@ class Doc extends React.Component {
<h1>{this.props.title}</h1>
</header>
<article>
<Marked>{this.props.content}</Marked>
<MarkdownBlock>{this.props.content}</MarkdownBlock>
</article>
</div>
);
Expand Down
10 changes: 5 additions & 5 deletions lib/core/GridBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const React = require("react");
const classNames = require("classnames");

const Marked = require("./Marked.js");
const MarkdownBlock = require("./MarkdownBlock.js");

class GridBlock extends React.Component {
renderBlock(block) {
Expand Down Expand Up @@ -38,9 +38,9 @@ class GridBlock extends React.Component {
{topLeftImage}
<div className="blockContent">
{this.renderBlockTitle(block.title)}
<Marked>
<MarkdownBlock>
{block.content}
</Marked>
</MarkdownBlock>
</div>
{bottomRightImage}
</div>
Expand Down Expand Up @@ -73,9 +73,9 @@ class GridBlock extends React.Component {
if (title) {
return (
<h2>
<Marked>
<MarkdownBlock>
{title}
</Marked>
</MarkdownBlock>
</h2>
);
} else {
Expand Down
9 changes: 6 additions & 3 deletions lib/core/Marked.js → lib/core/MarkdownBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
* LICENSE file in the root directory of this source tree.
*/

/* Marked component is used to parse markdown to html */
/**
* The MarkdownBlock component is used to parse markdown and render to HTML.
*/

const React = require('react');
const Remarkable = require('./Remarkable');

class Marked extends React.Component {
class MarkdownBlock extends React.Component {
render() {
return (
<Remarkable source={this.props.children} />
);
}
}

module.exports = Marked;
module.exports = MarkdownBlock;

2 changes: 1 addition & 1 deletion lib/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function execute(port) {
if (metadata.layout && siteConfig.layouts[metadata.layout]) {
Doc = siteConfig.layouts[metadata.layout]({
React,
Marked: require("../core/Marked.js")
MarkdownBlock: require("../core/MarkdownBlock.js")
});
}

Expand Down
2 changes: 1 addition & 1 deletion website/pages/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
const React = require("react");

const CompLibrary = require("../../core/CompLibrary.js");
const Marked = CompLibrary.Marked; /* Used to read markdown */
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;
const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */

const siteConfig = require(process.cwd() + "/siteConfig.js");

Expand Down
1 change: 1 addition & 0 deletions website/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ const siteConfig = {
}
};


module.exports = siteConfig;

0 comments on commit 09354ab

Please sign in to comment.