Skip to content

Commit

Permalink
Migrate contents out of monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
captainsafia committed Apr 7, 2020
1 parent 7348871 commit 9a5eeda
Show file tree
Hide file tree
Showing 19 changed files with 7,777 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ dist

# TernJS port file
.tern-port

lib/
43 changes: 41 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# markdown
A package for rendering Markdown within Jupyter notebooks
# @nteract/markdown

This package contains components that allow us to render Markdown text per the Commonmark specification. It also supports rendering in-line and block math using the LaTeX syntax.

## Installation

```
$ yarn add @nteract/markdown
```

```
$ npm install --save @nteract/markdown
```

## Usage

The example below shows how we can use this package to render Commonmark-specified Markdown with LaTeX math.

```javascript
import MarkdownRender from "@nteract/markdown";

export default () => {
return (
<MarkdownRender
source={`Just some $\delta_{\alpha}$ math and __formatting__.`}
/>
);
};
```

## Documentation

You can view the reference documentation for `@nteract/markdown` in the the [examples](./examples.md).

## Support

If you experience an issue while using this package or have a feature request, please file an issue on the [issue board](https://github.com/nteract/markdown/issues).

## License

[BSD-3-Clause](https://choosealicense.com/licenses/bsd-3-clause/)
287 changes: 287 additions & 0 deletions __tests__/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`markdown works as it should lets see: watching-paint-dry 1`] = `
<MarkdownRender
source="
# Watching Paint Dry
The composited _color_ of the **paint** must not change during drying. The
optical blending function is used with this constraint to compensate for the new
dry layer $C_{d}^{prime}$, when some volume $delta_{alpha}$ is removed from
the wet layer.
$$
C_{d}^{prime} = \\\\frac{alpha}{}
$$
The dry layer of the canvas uses a relative height field to allow for unlimited
volume of paint to be added, with a constraint only on the relative change in
height between texels.
"
>
<ReactMarkdown
astPlugins={Array []}
className="markdown-body "
escapeHtml={false}
parserOptions={Object {}}
plugins={
Array [
[Function],
]
}
rawSourcePos={false}
renderers={
Object {
"code": [Function],
"inlineMath": [Function],
"math": [Function],
}
}
skipHtml={false}
source="
# Watching Paint Dry
The composited _color_ of the **paint** must not change during drying. The
optical blending function is used with this constraint to compensate for the new
dry layer $C_{d}^{prime}$, when some volume $delta_{alpha}$ is removed from
the wet layer.
$$
C_{d}^{prime} = \\\\frac{alpha}{}
$$
The dry layer of the canvas uses a relative height field to allow for unlimited
volume of paint to be added, with a constraint only on the relative change in
height between texels.
"
sourcePos={false}
transformLinkUri={[Function]}
>
<Root
className="markdown-body "
key="root-1-1-0"
>
<div
className="markdown-body "
>
<Heading
key="heading-2-1-0"
level={1}
>
<h1>
<TextRenderer
key="text-2-3-0"
nodeKey="text-2-3-0"
value="Watching Paint Dry"
>
Watching Paint Dry
</TextRenderer>
</h1>
</Heading>
<p
key="paragraph-4-1-1"
>
<TextRenderer
key="text-4-1-0"
nodeKey="text-4-1-0"
value="The composited "
>
The composited
</TextRenderer>
<em
key="emphasis-4-16-1"
>
<TextRenderer
key="text-4-17-0"
nodeKey="text-4-17-0"
value="color"
>
color
</TextRenderer>
</em>
<TextRenderer
key="text-4-23-2"
nodeKey="text-4-23-2"
value=" of the "
>
of the
</TextRenderer>
<strong
key="strong-4-31-3"
>
<TextRenderer
key="text-4-33-0"
nodeKey="text-4-33-0"
value="paint"
>
paint
</TextRenderer>
</strong>
<TextRenderer
key="text-4-40-4"
nodeKey="text-4-40-4"
value=" must not change during drying. The
optical blending function is used with this constraint to compensate for the new
dry layer "
>
must not change during drying. The
optical blending function is used with this constraint to compensate for the new
dry layer
</TextRenderer>
<inlineMath
data={
Object {
"hChildren": Array [
Object {
"type": "text",
"value": "C_{d}^{prime}",
},
],
"hName": "span",
"hProperties": Object {
"className": "inlineMath",
},
}
}
key="inlineMath-6-11-5"
value="C_{d}^{prime}"
>
<MathJaxNode
inline={true}
onRender={null}
>
<Provider
delay={0}
didFinishTypeset={null}
input="tex"
loading={null}
noGate={false}
onError={[Function]}
onLoad={null}
options={Object {}}
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"
>
<MathJaxNode
inline={true}
onRender={null}
/>
</Provider>
</MathJaxNode>
</inlineMath>
<TextRenderer
key="text-6-26-6"
nodeKey="text-6-26-6"
value=", when some volume "
>
, when some volume
</TextRenderer>
<inlineMath
data={
Object {
"hChildren": Array [
Object {
"type": "text",
"value": "delta_{alpha}",
},
],
"hName": "span",
"hProperties": Object {
"className": "inlineMath",
},
}
}
key="inlineMath-6-45-7"
value="delta_{alpha}"
>
<MathJaxNode
inline={true}
onRender={null}
>
<Provider
delay={0}
didFinishTypeset={null}
input="tex"
loading={null}
noGate={false}
onError={[Function]}
onLoad={null}
options={Object {}}
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"
>
<MathJaxNode
inline={true}
onRender={null}
/>
</Provider>
</MathJaxNode>
</inlineMath>
<TextRenderer
key="text-6-60-8"
nodeKey="text-6-60-8"
value=" is removed from
the wet layer."
>
is removed from
the wet layer.
</TextRenderer>
</p>
<math
data={
Object {
"hChildren": Array [
Object {
"type": "text",
"value": "C_{d}^{prime} = \\\\frac{alpha}{}",
},
],
"hName": "div",
"hProperties": Object {
"className": "math",
},
}
}
key="math-9-1-2"
value="C_{d}^{prime} = \\\\frac{alpha}{}"
>
<MathJaxNode
inline={false}
onRender={null}
>
<Provider
delay={0}
didFinishTypeset={null}
input="tex"
loading={null}
noGate={false}
onError={[Function]}
onLoad={null}
options={Object {}}
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"
>
<MathJaxNode
inline={false}
onRender={null}
/>
</Provider>
</MathJaxNode>
</math>
<p
key="paragraph-13-1-3"
>
<TextRenderer
key="text-13-1-0"
nodeKey="text-13-1-0"
value="The dry layer of the canvas uses a relative height field to allow for unlimited
volume of paint to be added, with a constraint only on the relative change in
height between texels."
>
The dry layer of the canvas uses a relative height field to allow for unlimited
volume of paint to be added, with a constraint only on the relative change in
height between texels.
</TextRenderer>
</p>
</div>
</Root>
</ReactMarkdown>
</MarkdownRender>
`;
36 changes: 36 additions & 0 deletions __tests__/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { mount } from "enzyme";
import toJson from "enzyme-to-json";
import * as React from "react";

import Markdown from "../src";

const cases = [
{
source: `
# Watching Paint Dry
The composited _color_ of the **paint** must not change during drying. The
optical blending function is used with this constraint to compensate for the new
dry layer $C_{d}^{\prime}$, when some volume $\delta_{\alpha}$ is removed from
the wet layer.
$$
C_{d}^{\prime} = \\frac{\alpha}{}
$$
The dry layer of the canvas uses a relative height field to allow for unlimited
volume of paint to be added, with a constraint only on the relative change in
height between texels.
`,
name: "watching-paint-dry"
}
];

describe("markdown works as it should", () => {
test("lets see", () => {
cases.forEach(({ source, name }) => {
const wrapper = mount(<Markdown source={source} />);
expect(toJson(wrapper)).toMatchSnapshot(name);
});
});
});
Loading

0 comments on commit 9a5eeda

Please sign in to comment.