Comments (8)
@timwis Just FYI, I added a note about this to the README: https://github.com/yaycmyk/markdown-to-jsx/blob/master/README.md
Thanks for bringing it up - I hadn't run into that usage style yet.
from markdown-to-jsx.
Hmm that's bizarre. Yeah it definitely supports paragraphs.
Could you post more of a complete example of how you're using the library and what OS, etc?
from markdown-to-jsx.
Sure, here's how I'm attempting to use it:
import React from 'react'
import Markdown from 'markdown-to-jsx'
export default class IntroText extends React.Component {
render () {
return (
<Markdown>
# incidents_part1_part2
This dataset is published to [carto](https://carto.com), which allows you to query the data using SQL (specifically the PostgreSQL flavor with the PostGIS extension). Rather than executing the queries in a database program, you execute them through HTTP (ie. the web browser) via Carto's [SQL API](https://carto.com/docs/carto-engine/sql-api), passing your query as the `q` parameter. For example:
```
https://phl.carto.com/api/v2/sql?q=SELECT * FROM incidents_part1_part2
```
You can do just about everyting you'd expect from a PostgreSQL+PostGIS database - even joins between tables.
</Markdown>
)
}
}
I'm using macOS Sierra.
This would be a separate issue, but I've also noticed that if I try to reference {this.props.xxxxx}
within the markdown, I get a few console errors:
Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `Component`, expected `string`.
Uncaught Error: markdown-to-jsx: the first argument must be a string
Thanks for your time.
from markdown-to-jsx.
I am having a similar issue. When I am using a single line string in brackets {"# foo\n\n## bar"}
it works fine, but using multiline text results in everything after the first line becoming a child of the first line.
export function Content() {
return (
<Markdown>
# This is the first headline
## This is the second headline
here is something else
</Markdown>);
}
The displayed hierarchy is
<h1 data-reactid=".0.2.0.0">This is the first headline ## This is the second headline here is something else</h1>
I am also using macOS Sierra. I wonder if it is related to the upgrade of browserify?
UPDATE I was checking how react interprets raw text in the context of children. Apparently it does not acknowledge line breaks. When I made a random function
function Child(props) {
console.log(props.children);
return (
<div>
</div>
);
}
and placed it in the context of a render:
...
return (
<div>
<Child>
# This is a text
## this is more text
### Last bit of text
</Child>
</div>
);
the console output was # This is a text ## this is more text ### Last bit of text
from markdown-to-jsx.
Hmm, what if you do:
<Child>
{` # This is a text
## this is more text
### Last bit of text
`}
</Child>
Hacky, I know but maybe it'll preserve the newlines.
from markdown-to-jsx.
FWIW, I use this component every day in enigma-io/boundless on markdown brought in by the webpack raw-loader and it definitely preserves the newlines there.
from markdown-to-jsx.
Going to close this, since it doesn't seem like an issue with the component.
from markdown-to-jsx.
Thanks. FYI I ended up doing something similar to what the readme suggests, but without using a loader:
https://github.com/CityOfPhiladelphia/carto-api-explorer/blob/master/src/components/encoded-markdown.js
from markdown-to-jsx.
Related Issues (20)
- Cannot render tag if formatted in a certain way. HOT 3
- Supply original string for special case processing HOT 2
- <blockquote> rendering is broken in Firefox after v7.4.0 HOT 2
- Version 7.4.1 has a strange consol.log in index.cjs and index.umd.js - console.log("AHHHHHHHH") HOT 4
- Slow Regex HTML_BLOCK_ELEMENT_R because of issue with self closing tags HOT 5
- Mutli-line bold/italic text not rendering correctly HOT 1
- Support multiline footnotes
- Firefox unable to render link tags HOT 1
- markdown-to-json refuses to work on some aspects HOT 9
- Can't disable HTML sanitization HOT 2
- Component is rendering too frequently, when dependencies have not changed HOT 1
- [Critical] Page freezes with this raw text HOT 4
- Reopen #568
- follow up on #520 HOT 1
- 在引用块第一位使用 kbd标签后面链接无法正常解析
- Unexpected nested list behavior
- Ordered list is not generated if there's no newline at the end
- Double line breaks (\n\n) are not converted properly
- Error using divider with `---`
- Empty `<style></style>` or `<style />` causes library to crash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdown-to-jsx.