-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix: Do not alter headings depth in user's *.md files Mutating user's documents can be very confusing. And since section's names are optional now, it's even less logical to start from `<h3>`. HTML5 standard also says when `<section>` are used, heading for each section can start with `h1` See: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML_sections_and_outlines * Use `<section>` instead of `<article>` for sub-sections * Use `<article>` when rendering section's content such as markdown document * Added styles for H1 and H2 in markdown document.
- Loading branch information
Showing
9 changed files
with
144 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
Second *Markdown* file. | ||
# Heading 1 | ||
|
||
## Heading 2 | ||
|
||
### Heading 3 | ||
|
||
#### Heading 4 | ||
|
||
##### Heading 5 | ||
|
||
###### Heading 6 | ||
|
||
foo|bar | ||
---|--- | ||
1 |2 | ||
|
||
* list 1 | ||
* list 2 | ||
1. Sub-list | ||
1. Sub-list | ||
1. Sub-list | ||
* list 3 | ||
|
||
* [ ] list 1 | ||
* [ ] list 2 | ||
* [x] list 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/rsg-components/Examples/__snapshots__/Examples.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
exports[`test should render examples 1`] = ` | ||
<div> | ||
<article> | ||
<Playground | ||
code="<button>OK</button>" | ||
evalInContext={[Function]} | ||
index={0} | ||
name="button" /> | ||
<_class | ||
text="Hello *world*!" /> | ||
</div> | ||
</article> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,98 @@ | ||
import React from 'react'; | ||
import Markdown from './Markdown'; | ||
|
||
it('should render Markdown with custom CSS classes', () => { | ||
const markdown = ` | ||
describe('Markdown', () => { | ||
it('should render Markdown with custom CSS classes', () => { | ||
const markdown = ` | ||
# Header | ||
Text with *some* **formatting** and a [link](/foo). | ||
![Image](/bar.png)`; | ||
const actual = render( | ||
<Markdown text={markdown} /> | ||
); | ||
const actual = render( | ||
<Markdown text={markdown} /> | ||
); | ||
|
||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render Markdown in span in inline mode', () => { | ||
const markdown = 'Hello *world*!'; | ||
const actual = render( | ||
<Markdown text={markdown} inline /> | ||
); | ||
|
||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render headings correctly', () => { | ||
const markdown = ` | ||
# one | ||
## two | ||
### three | ||
#### four | ||
##### five | ||
###### six | ||
`; | ||
const actual = render( | ||
<Markdown text={markdown} /> | ||
); | ||
|
||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render unordered lists correctly', () => { | ||
const markdown = ` | ||
* list | ||
* item | ||
* three | ||
`; | ||
const actual = render( | ||
<Markdown text={markdown} /> | ||
); | ||
|
||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render ordered lists correctly', () => { | ||
const markdown = ` | ||
1. list | ||
1. item | ||
1. three | ||
`; | ||
const actual = render( | ||
<Markdown text={markdown} /> | ||
); | ||
|
||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render check-lists correctly', () => { | ||
const markdown = ` | ||
* [ ] list 1 | ||
* [ ] list 2 | ||
* [x] list 3 | ||
`; | ||
const actual = render( | ||
<Markdown text={markdown} /> | ||
); | ||
|
||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render Markdown in span in inline mode', () => { | ||
const markdown = 'Hello *world*!'; | ||
const actual = render( | ||
<Markdown text={markdown} inline /> | ||
); | ||
it('should render mixed nested lists correctly', () => { | ||
const markdown = ` | ||
* list 1 | ||
* list 2 | ||
1. Sub-list | ||
1. Sub-list | ||
1. Sub-list | ||
* list 3 | ||
`; | ||
const actual = render( | ||
<Markdown text={markdown} /> | ||
); | ||
|
||
expect(actual.html()).toMatchSnapshot(); | ||
expect(actual.html()).toMatchSnapshot(); | ||
}); | ||
}); |
14 changes: 12 additions & 2 deletions
14
src/rsg-components/Markdown/__snapshots__/Markdown.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
exports[`test should render Markdown in span in inline mode 1`] = `"<span class=\"base-2877968375\">Hello <em class=\"em-2233019579\">world</em>!</span>"`; | ||
exports[`Markdown should render Markdown in span in inline mode 1`] = `"<span class=\"base-2877968375\">Hello <em class=\"em-2233019579\">world</em>!</span>"`; | ||
exports[`test should render Markdown with custom CSS classes 1`] = `"<div><h3 class=\"h3-2951916027\">Header</h3><p class=\"p-1681777157\">Text with <em class=\"em-2233019579\">some</em> <strong class=\"strong-2282145835\">formatting</strong> and a <a class=\"a-219704402\" href=\"/foo\">link</a>.</p><p class=\"p-1681777157\"><img class=\"img-2656340033\" alt=\"Image\" src=\"/bar.png\"></p></div>"`; | ||
exports[`Markdown should render Markdown with custom CSS classes 1`] = `"<div><h1 class=\"h1-1333784724\">Header</h1><p class=\"p-1681777157\">Text with <em class=\"em-2233019579\">some</em> <strong class=\"strong-2282145835\">formatting</strong> and a <a class=\"a-219704402\" href=\"/foo\">link</a>.</p><p class=\"p-1681777157\"><img class=\"img-2656340033\" alt=\"Image\" src=\"/bar.png\"></p></div>"`; | ||
exports[`Markdown should render check-lists correctly 1`] = `"<ul class=\"ul-1681777157\"><li><input type=\"checkbox\" disabled>list 1</li><li><input type=\"checkbox\" disabled>list 2</li><li><input type=\"checkbox\" checked disabled>list 3</li></ul>"`; | ||
exports[`Markdown should render headings correctly 1`] = `"<div><h1 class=\"h1-1333784724\">one</h1><h2 class=\"h2-365728764\">two</h2><h3 class=\"h3-2951916027\">three</h3><h4 class=\"h4-370263229\">four</h4><h5 class=\"h5-3491702579\">five</h5><h6 class=\"h6-1863710277\">six</h6></div>"`; | ||
exports[`Markdown should render mixed nested lists correctly 1`] = `"<ul class=\"ul-1681777157\"><li class=\"li-4011715572\">list 1</li><li class=\"li-4011715572\"><p class=\"p-1681777157\">list 2</p><ol class=\"ol-65688532\" start=\"1\"><li class=\"li-4011715572\">Sub-list</li><li class=\"li-4011715572\">Sub-list</li><li class=\"li-4011715572\">Sub-list</li></ol></li><li class=\"li-4011715572\">list 3</li></ul>"`; | ||
exports[`Markdown should render ordered lists correctly 1`] = `"<ol class=\"ol-65688532\" start=\"1\"><li class=\"li-4011715572\">list</li><li class=\"li-4011715572\">item</li><li class=\"li-4011715572\">three</li></ol>"`; | ||
exports[`Markdown should render unordered lists correctly 1`] = `"<ul class=\"ul-1681777157\"><li class=\"li-4011715572\">list</li><li class=\"li-4011715572\">item</li><li class=\"li-4011715572\">three</li></ul>"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters