Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
20810e4
🚪 Improve handling of self-closing tags
ticky Nov 29, 2016
a33788c
🔤 Use alphabetic hash for string replacements
ticky Jan 24, 2017
70b4bc0
🤔 Rethink HTML processing
ticky Jan 24, 2017
304018f
🚚 Move `elementProps` to the end of tags
ticky Jan 24, 2017
d2c74cc
❌ Allow JSX elements just as you would HTML
ticky Jan 25, 2017
7a0c6ab
😈 Update spec snapshots
ticky Jun 11, 2017
52c98e7
🆕 Latest stuff rebased onto develop
ticky Sep 18, 2017
d442fcd
🎇 `class` must be used here?
ticky Sep 18, 2017
9420831
⚙️ Transform stuff using tsxml
ticky Sep 20, 2017
9598b81
⏮ Okay no no no let's walk that back
ticky Sep 20, 2017
a3945e1
⏮ Keep going...
ticky Sep 20, 2017
059dc3a
🔧 Repair REPL
ticky Sep 20, 2017
86042c6
🎞 Put back jsesc stuff
ticky Sep 20, 2017
61b8678
📜 Rename this thing to be more accurate
ticky Sep 20, 2017
8329226
📊 Restore REPL behaviour
ticky Sep 20, 2017
e22c27e
✏️ This didn't need reformatting?
ticky Sep 20, 2017
c232933
🚚 Move the ~hack zone~ into its own file
ticky Sep 20, 2017
6b4931e
🤦🏻‍♀️ Revert "🎞 Put back jsesc stuff"
ticky Sep 20, 2017
210e759
🍴 Split processor up from loader API
ticky Sep 20, 2017
6e44cbb
☑️ Improved whitespace behaviour, fewer specs
ticky Sep 20, 2017
5928456
🌏 Updated homepage
ticky Sep 20, 2017
04a638e
➡️ Fix indentation
ticky Sep 20, 2017
b43ec9b
🕸 Fix lint
ticky Sep 20, 2017
906d14e
🔩 Improve comment handling
ticky Sep 20, 2017
f130647
✈️ Use hastml
ticky Sep 20, 2017
eab588c
🚛 Move converter
ticky Sep 20, 2017
b6491f4
📦 Split Webpack interop into its own thing
ticky Sep 21, 2017
bda10d8
⭕️ Spec Webpack loader module separately
ticky Sep 21, 2017
08576d0
🕹 Improve interop and fix a spec
ticky Sep 21, 2017
8986ec8
🕳 Fix lint
ticky Sep 21, 2017
2d22b02
🖨 Spec for react output preamble, update fixtures
ticky Sep 21, 2017
c6afb1a
#️⃣ Import SHA256 directly
ticky Sep 21, 2017
117d06c
🌟 Improve clarity of text node conversions
ticky Sep 21, 2017
ab52aee
💡 Disable extra highlighting stuff in web output
ticky Sep 21, 2017
3b7c6c9
📝 Update README
ticky Sep 21, 2017
045cc69
📦 Add a shared JS bundle
ticky Sep 21, 2017
448c18a
🙅🏻 Better ignore setup
ticky Sep 21, 2017
6a7ee62
🐠 Better specs around curlies
ticky Sep 21, 2017
ce689d1
❗️ Explicit regex prefix inclusion
ticky Sep 21, 2017
b40acd9
🙊 Improve escaping behaviour of JSX entities
ticky Sep 21, 2017
779ffe5
👟 Remove unnecessary guards around closing tags
ticky Sep 21, 2017
28d4a1b
🌎 Add homepage-rendering spec
ticky Sep 22, 2017
3ddcc49
🤔 Remove this apparently unnecessary check
ticky Sep 22, 2017
68d0a79
🔨 Fix compilation of the docs site
ticky Sep 22, 2017
b962704
⏪ Add 0.8.0's REPL to a docs subdirectory
ticky Sep 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
coverage
node_modules
*.tgz
stats.json

# `lib` is not included in git repo
lib
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
coverage
__fixtures__
__mocks__
__snapshots__
*.spec.js
app
docs
yarn.lock
stats.json
*.tgz
*.log
/webpack.config.js

# `lib` is included in npm dist
!lib
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ This is a _Markdown Component_ file. Here you can include JSX-style assignment e

Props passed to this component are available as `props`, so you can embed those too! Hello there, {{ props.who || 'world' }}!

Another cool thing you can do is use JSX **directly** - here’s an SVG element, used inline: {{ <svg style={{ display: 'inline', height: '1em' }} viewBox="0 0 304 290"><path fill="none" stroke="currentColor" strokeWidth="16" d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z" /></svg> }}.
Another cool thing you can do is use JSX **directly** - here’s an SVG element, used inline: <svg style={{ display: 'inline', height: '1em' }} viewBox="0 0 304 290"><path fill="none" stroke="currentColor" strokeWidth="16" d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z" /></svg>.

```

Expand All @@ -69,7 +69,6 @@ _**Note**: destructuring imports must be quoted, but others need not be._
The above `mdx` file will produce the following module within Webpack;

```javascript
// Module generated from Markdown by markdown-component-loader v0.8.0
import React from 'react';
import PropTypes from 'prop-types';
import { name, version } from './package.json';
Expand All @@ -88,7 +87,7 @@ function MarkdownComponent(props) {
<div className={className} style={style}>
<p>This is a <em>Markdown Component</em> file. Here you can include JSX-style assignment expressions; this component was generated using version { version } of { name }!</p>
<p>Props passed to this component are available as <code>props</code>, so you can embed those too! Hello there, { props.who || 'world' }!</p>
<p>Another cool thing you can do is use JSX <strong>directly</strong> - here’s an SVG element, used inline: { <svg style={{ display: 'inline', height: '1em' }} viewBox="0 0 304 290"><path fill="none" stroke="currentColor" strokeWidth="16" d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z" /></svg> }.</p>
<p>Another cool thing you can do is use JSX <strong>directly</strong> - here’s an SVG element, used inline: <svg style={{ display: 'inline', height: '1em' }} viewBox="0 0 304 290"><path fill="none" stroke="currentColor" strokeWidth="16" d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z" /></svg>.</p>
</div>
);
};
Expand All @@ -112,7 +111,7 @@ ReactDOM.render(

### Extra Configuration

Markdown Component Loader accepts configuration of options via either the webpack configuration file, or query string parameters.
Markdown Component Loader accepts configuration of options via the Webpack configuration file.

```javascript
module.exports = {
Expand Down Expand Up @@ -163,14 +162,13 @@ The container will have supplied `className` and `style` props passed through to

#### Inner Element Styling

If `passElementProps` is set to `true`, elements within the Markdown Component can be styled on a per-element-name basis. You can set this either in the `webpack.config.js` (see the "Extra Configuration" section) or the loader's query string.
If `passElementProps` is set to `true`, elements within the Markdown Component can be styled on a per-element-name basis. You can set this in the `webpack.config.js` (see the "Extra Configuration" section).

All generated standard elements (read: elements which are known to `React.DOM`) will then have `elementProps['name']` spread onto them (where `name` is the tag name of the element). This option is intended to be used with [Basscss](http://www.basscss.com/) modular CSS.

Here's the above example markdown document converted with this option;

```javascript
// Module generated from Markdown by markdown-component-loader v0.8.0
import React from 'react';
import PropTypes from 'prop-types';
import { name, version } from './package.json';
Expand All @@ -194,7 +192,7 @@ function MarkdownComponent(props) {
<div className={className} style={style}>
<p {...elementProps['p']}>This is a <em {...elementProps['em']}>Markdown Component</em> file. Here you can include JSX-style assignment expressions; this component was generated using version { version } of { name }!</p>
<p {...elementProps['p']}>Props passed to this component are available as <code {...elementProps['code']}>props</code>, so you can embed those too! Hello there, { props.who || 'world' }!</p>
<p {...elementProps['p']}>Another cool thing you can do is use JSX <strong {...elementProps['strong']}>directly</strong> - here’s an SVG element, used inline: { <svg {...elementProps['svg']} style={{ display: 'inline', height: '1em' }} viewBox="0 0 304 290"><path {...elementProps['path']} fill="none" stroke="currentColor" strokeWidth="16" d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z" /></svg> }.</p>
<p {...elementProps['p']}>Another cool thing you can do is use JSX <strong {...elementProps['strong']}>directly</strong> - here’s an SVG element, used inline: <svg style={{ display: 'inline', height: '1em' }} viewBox="0 0 304 290" {...elementProps['svg']}><path fill="none" stroke="currentColor" strokeWidth="16" d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z" {...elementProps['path']} /></svg>.</p>
</div>
);
};
Expand Down
12 changes: 6 additions & 6 deletions app/Homepage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ Use JSX within Markdown. Plus import objects such as shared snippets, fancy libr
```markdown
---
{{<span className="emphasis">{'imports:'}</span>}}
{{<span className="emphasis">{' window: global/window'}</span>}}
{{<span className="emphasis">{' numberFormat: number-format'}</span>}}
{{<span className="emphasis">{' Button: ui/button'}</span>}}
---

Hello, your user agent is {{<span className="emphasis">{'{{ window.navigator.userAgent }}'}</span>}}.
You are visitor number {{<span className="emphasis">{'{{ numberFormat(1000000) }}'}</span>}}!

{{<span className="emphasis">{'{\{ <Button path="/browser-info">Details</Button> }\}'}</span>}}
{{<span className="emphasis">{'<Button path="/browser-info">Details</Button>'}</span>}}
```

Destructured imports, with some added single quotes:

```markdown
---
{{<span className="emphasis">{'imports:'}</span>}}
{{<span className="emphasis">{' \'{ Button, Panel }\': ui'}</span>}}
imports:
{{<span className="emphasis">{' \'{ window, document }\': global'}</span>}}
---

Hello <code>{{<span className="emphasis">{'{\{ <Button /> }\}'}</span>}}</code>
Hello, your user agent is {{<span className="emphasis">{'{{ window.navigator.userAgent }}'}</span>}}.
```

## Give it a go!
Expand Down
15 changes: 5 additions & 10 deletions app/repl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global ace, document */
import markdownComponentLoader from '../src';
import convert from '../src/convert';

require('./repl.css');

Expand Down Expand Up @@ -60,16 +60,11 @@ class REPL {
this.clearOutput();

try {
transformed = markdownComponentLoader.call(
transformed = convert(
code,
{
cacheable() {},
options: {
markdownComponentLoader: {
passElementProps: false
}
}
},
code
passElementProps: false
}
);
} catch (err) {
this.printError(`Errors:\n${err.message}`);
Expand Down
1 change: 1 addition & 0 deletions docs/0.8.0/1e7ea3e8ac242d69c669bb535d4bdcf1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading