Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

terra-markdown

Package Overview
Dependencies
Maintainers
10
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terra-markdown - npm Package Compare versions

Comparing version 2.24.0 to 2.25.0

lib/terra-dev-site/test/markdown/blockquote.md

13

CHANGELOG.md

@@ -7,2 +7,15 @@ Changelog

2.25.0 - (April 16, 2019)
------------------
### Added
* baseUrl prop
* hasHeadingAnchors prop
* regression test for a greater set of markdown
### Removed
* github-markdown-css dependency
### Changed
* Provide no highlighting for unsupported languages instead of the clike highlighting.
2.24.0 - (March 26, 2019)

@@ -9,0 +22,0 @@ ------------------

@@ -238,3 +238,10 @@ # Terra Markdown

## Props
| Prop Name | Type | Is Required | Default Value | Description |
| ------------- |-------------| -----| -----| -----|
| src | string | optional | '' | Markdown content to parse. |
| baseUrl | string | optional | undefined | A prefix url for any relative link. e.g. '/prefix/'|
| hasHeadingAnchors | bool | optional | undefined | Adds anchor links to heading elements. Anchor elements will not work with the hash router on an SPA. The anchors use negative margins to position to the left of heading. You must have more that 24px of space around this component. |
## Component Features
* [Cross-Browser Support](https://github.com/cerner/terra-ui/blob/master/src/terra-dev-site/contributing/ComponentStandards.e.contributing.md#cross-browser-support)

42

lib/Markdown.js

@@ -7,2 +7,4 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');

@@ -34,4 +36,2 @@

require('github-markdown-css/github-markdown.css');
var _Markdown = require('./Markdown.scss');

@@ -43,9 +43,5 @@

/* github-markdown-css's main entry in package.json resolves to a CSS file and this seems to be causing issues with eslint */
/* eslint-disable import/extensions */
var cx = _bind2.default.bind(_Markdown2.default);
// Create a list of loaded languages, remove functions that aren't actaully languages.
/* eslint-enable import/extensions */
var supportedLanguages = Object.keys(_prismjs2.default.languages).filter(function (lang) {

@@ -55,9 +51,9 @@ return !['extend', 'insertBefore', 'DFS'].includes(lang);

// If the supported language is requested, highlight it.
var highlight = function highlight(code, lang) {
var language = lang;
if (!supportedLanguages.includes(language)) {
language = 'clike';
if (supportedLanguages.includes(lang)) {
return _prismjs2.default.highlight(code, _prismjs2.default.languages[lang], lang);
}
return _prismjs2.default.highlight(code, _prismjs2.default.languages[language], language);
return null;
};

@@ -71,7 +67,23 @@

var renderer = new _marked2.default.Renderer();
// Override how heading renders to add the anchor.
renderer.heading = function (text, level) {
var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return '<h' + level + '>' + ('<a name="' + escapedText + '" class="anchor" aria-hidden="true" href="#' + escapedText + '">') + '<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" class="is-bidi octicon octicon-link"><path d="M10.5 26.3a16 16 0 0 1 .9-5.3L8 17.6a6.73 6.73 0 0 1-2-4.8A6.41 6.41 0 0 1 8 8a6.76 6.76 0 0 1 9.6 0l9 9a6.88 6.88 0 0 1 0 9.6 6.27 6.27 0 0 1-3.4 1.8 2.65 2.65 0 0 0 .5.6l4.1 4.1a11.36 11.36 0 0 0 3.1-2.3 12.8 12.8 0 0 0 0-18.1l-9-9a12.63 12.63 0 0 0-9-3.7 12.63 12.63 0 0 0-9 3.7A12.1 12.1 0 0 0 0 12.8a12.63 12.63 0 0 0 3.7 9l7 7a21.05 21.05 0 0 1-.2-2.5zm27-4.6a16 16 0 0 1-.9 5.3l3.4 3.4a6.79 6.79 0 1 1-9.6 9.6l-9-9a6.88 6.88 0 0 1 0-9.6 6.27 6.27 0 0 1 3.4-1.8 2.65 2.65 0 0 0-.5-.6l-4-4a11.36 11.36 0 0 0-3.1 2.3 12.8 12.8 0 0 0 0 18.1l9 9a12.73 12.73 0 0 0 18-18l-7-7a8 8 0 0 1 .3 2.3z"/></svg>' + '</a>' + ('' + text) + ('</h' + level + '>');
};
var propTypes = {
/**
* Markdown content to parse
* Markdown content to parse.
*/
src: _propTypes2.default.string
src: _propTypes2.default.string,
/**
* A prefix url for any relative link.
*/
baseUrl: _propTypes2.default.string,
/**
* Enable anchors for heading elements.
*/
hasHeadingAnchors: _propTypes2.default.bool
};

@@ -87,4 +99,6 @@

dir: 'ltr',
className: cx(['markdown']) + ' markdown-body',
dangerouslySetInnerHTML: { __html: (0, _marked2.default)(props.src) }
className: cx(['markdown']),
dangerouslySetInnerHTML: {
__html: (0, _marked2.default)(props.src, _extends({}, props.baseUrl && { baseUrl: props.baseUrl }, props.hasHeadingAnchors && { renderer: renderer }))
}
});

@@ -91,0 +105,0 @@ };

@@ -1,16 +0,417 @@

# Terra Markdown
##### Table of Contents
[Headers](#headers)
React component to display the content of markdown files.
[Emphasis](#emphasis)
## Getting Started
[Lists](#lists)
- Install with [npmjs](https://www.npmjs.com):
- `npm install terra-markdown`
- `yarn add terra-markdown`
[Links](#links)
## Test
> This is a quote.
[Images](#images)
[Code and Syntax Highlighting](#code)
## Component Features
* [Cross-Browser Support](https://github.com/cerner/terra-ui/blob/master/src/terra-dev-site/contributing/ComponentStandards.e.contributing.md#cross-browser-support)
[Tables](#tables)
[Blockquotes](#blockquotes)
[Inline HTML](#html)
[Horizontal Rule](#hr)
[Line Breaks](#lines)
[YouTube Videos](#videos)
<a name="headers"/>
## Headers
```no-highlight
# H1
## H2
### H3
#### H4
##### H5
###### H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H1
======
Alt-H2
------
```
# H1
## H2
### H3
#### H4
##### H5
###### H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H1
======
Alt-H2
------
<a name="emphasis"/>
## Emphasis
```no-highlight
Emphasis, aka italics, with *asterisks* or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
Strikethrough uses two tildes. ~~Scratch this.~~
```
Emphasis, aka italics, with *asterisks* or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
Strikethrough uses two tildes. ~~Scratch this.~~
<a name="lists"/>
## Lists
(In this example, leading and trailing spaces are shown with with dots: ⋅)
```no-highlight
1. First ordered list item
2. Another item
⋅⋅* Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
⋅⋅1. Ordered sub-list
4. And another item.
⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
* Unordered list can use asterisks
- Or minuses
+ Or pluses
```
1. First ordered list item
2. Another item
* Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
1. Ordered sub-list
4. And another item.
You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
To have a line break without a paragraph, you will need to use two trailing spaces.
Note that this line is separate, but within the same paragraph.
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
* Unordered list can use asterisks
- Or minuses
+ Or pluses
<a name="links"/>
## Links
There are two ways to create links.
```no-highlight
[I'm an inline-style link](https://www.google.com)
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
[I'm a reference-style link][Arbitrary case-insensitive reference text]
[I'm a relative reference to a repository file](../blob/master/LICENSE)
[You can use numbers for reference-style link definitions][1]
Or leave it empty and use the [link text itself].
URLs and URLs in angle brackets will automatically get turned into links.
http://www.example.com or <http://www.example.com> and sometimes
example.com (but not on Github, for example).
Some text to show that the reference links can follow later.
[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: http://slashdot.org
[link text itself]: http://www.reddit.com
```
[I'm an inline-style link](https://www.google.com)
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
[I'm a reference-style link][Arbitrary case-insensitive reference text]
[I'm a relative reference to a repository file](../blob/master/LICENSE)
[You can use numbers for reference-style link definitions][1]
Or leave it empty and use the [link text itself].
URLs and URLs in angle brackets will automatically get turned into links.
http://www.example.com or <http://www.example.com> and sometimes
example.com (but not on Github, for example).
Some text to show that the reference links can follow later.
[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: http://slashdot.org
[link text itself]: http://www.reddit.com
<a name="images"/>
## Images
```no-highlight
Here's our logo (hover to see the title text):
Inline-style:
![alt text](https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 1")
Reference-style:
![alt text][logo]
[logo]: https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 2"
```
Here's our logo (hover to see the title text):
Inline-style:
![alt text](https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 1")
Reference-style:
![alt text][logo]
[logo]: https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 2"
<a name="code"/>
## Code and Syntax Highlighting
Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and *Markdown Here* -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. *Markdown Here* supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the [highlight.js demo page](http://softwaremaniacs.org/media/soft/highlight/test.html).
```no-highlight
Inline `code` has `back-ticks around` it.
```
Inline `code` has `back-ticks around` it.
Blocks of code are either fenced by lines with three back-ticks <code>```</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.
<pre lang="no-highlight"><code>```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```
```python
s = "Python syntax highlighting"
print s
```
```
No language indicated, so no syntax highlighting.
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
```
</code></pre>
```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```
```python
s = "Python syntax highlighting"
print s
```
```
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
But let's throw in a <b>tag</b>.
```
<a name="tables"/>
## Tables
Tables aren't part of the core Markdown spec, but they are part of GFM and *Markdown Here* supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.
```no-highlight
Colons can be used to align columns.
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
There must be at least 3 dashes separating each header cell.
The outer pipes (|) are optional, and you don't need to make the
raw Markdown line up prettily. You can also use inline Markdown.
Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
```
Colons can be used to align columns.
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
<a name="blockquotes"/>
## Blockquotes
```no-highlight
> Blockquotes are very handy in email to emulate reply text.
> This line is part of the same quote.
Quote break.
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
```
> Blockquotes are very handy in email to emulate reply text.
> This line is part of the same quote.
Quote break.
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
<a name="html"/>
## Inline HTML
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
```no-highlight
<dl>
<dt>Definition list</dt>
<dd>Is something people use sometimes.</dd>
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
```
<dl>
<dt>Definition list</dt>
<dd>Is something people use sometimes.</dd>
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
<a name="hr"/>
## Horizontal Rule
```
Three or more...
---
Hyphens
***
Asterisks
___
Underscores
```
Three or more...
---
Hyphens
***
Asterisks
___
Underscores
<a name="lines"/>
## Line Breaks
My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
Here are some things to try out:
```
Here's a line for us to start with.
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
This line is also a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
```
Here's a line for us to start with.
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
This line is also begins a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
(Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
<a name="videos"/>
## YouTube Videos
They can't be added directly but you can add an image with a link to the video like this:
```no-highlight
<a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
```
Or, in pure Markdown, but losing the image sizing and border:
```no-highlight
[![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
```
Referencing a bug by #bugID in your git commit links it to the slip. For example #1.
---
{
"name": "terra-markdown",
"main": "lib/Markdown.js",
"version": "2.24.0",
"version": "2.25.0",
"description": "React component to display the content of markdown files.",

@@ -29,4 +29,3 @@ "repository": {

"classnames": "^2.2.5",
"github-markdown-css": "^2.4.1",
"marked": "0.5.0",
"marked": "0.6.2",
"prismjs": "~1.16.0",

@@ -33,0 +32,0 @@ "prop-types": "^15.5.8"

@@ -9,6 +9,2 @@ import React from 'react';

import 'prismjs/components/prism-scss';
/* github-markdown-css's main entry in package.json resolves to a CSS file and this seems to be causing issues with eslint */
/* eslint-disable import/extensions */
import 'github-markdown-css/github-markdown.css';
/* eslint-enable import/extensions */
import styles from './Markdown.scss';

@@ -21,9 +17,9 @@

// If the supported language is requested, highlight it.
const highlight = (code, lang) => {
let language = lang;
if (!supportedLanguages.includes(language)) {
language = 'clike';
if (supportedLanguages.includes(lang)) {
return Prism.highlight(code, Prism.languages[lang], lang);
}
return Prism.highlight(code, Prism.languages[language], language);
return null;
};

@@ -37,7 +33,28 @@

const renderer = new marked.Renderer();
// Override how heading renders to add the anchor.
renderer.heading = (text, level) => {
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return `<h${level}>`
+ `<a name="${escapedText}" class="anchor" aria-hidden="true" href="#${escapedText}">`
+ '<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" class="is-bidi octicon octicon-link"><path d="M10.5 26.3a16 16 0 0 1 .9-5.3L8 17.6a6.73 6.73 0 0 1-2-4.8A6.41 6.41 0 0 1 8 8a6.76 6.76 0 0 1 9.6 0l9 9a6.88 6.88 0 0 1 0 9.6 6.27 6.27 0 0 1-3.4 1.8 2.65 2.65 0 0 0 .5.6l4.1 4.1a11.36 11.36 0 0 0 3.1-2.3 12.8 12.8 0 0 0 0-18.1l-9-9a12.63 12.63 0 0 0-9-3.7 12.63 12.63 0 0 0-9 3.7A12.1 12.1 0 0 0 0 12.8a12.63 12.63 0 0 0 3.7 9l7 7a21.05 21.05 0 0 1-.2-2.5zm27-4.6a16 16 0 0 1-.9 5.3l3.4 3.4a6.79 6.79 0 1 1-9.6 9.6l-9-9a6.88 6.88 0 0 1 0-9.6 6.27 6.27 0 0 1 3.4-1.8 2.65 2.65 0 0 0-.5-.6l-4-4a11.36 11.36 0 0 0-3.1 2.3 12.8 12.8 0 0 0 0 18.1l9 9a12.73 12.73 0 0 0 18-18l-7-7a8 8 0 0 1 .3 2.3z"/></svg>'
+ '</a>'
+ `${text}`
+ `</h${level}>`;
};
const propTypes = {
/**
* Markdown content to parse
* Markdown content to parse.
*/
src: PropTypes.string,
/**
* A prefix url for any relative link.
*/
baseUrl: PropTypes.string,
/**
* Enable anchors for heading elements.
*/
hasHeadingAnchors: PropTypes.bool,
};

@@ -53,4 +70,9 @@

dir="ltr"
className={`${cx(['markdown'])} markdown-body`}
dangerouslySetInnerHTML={{ __html: marked(props.src) }}
className={cx(['markdown'])}
dangerouslySetInnerHTML={{
__html: marked(props.src, {
...props.baseUrl && { baseUrl: props.baseUrl },
...props.hasHeadingAnchors && { renderer },
}),
}}
/>

@@ -57,0 +79,0 @@ );

@@ -1,16 +0,417 @@

# Terra Markdown
##### Table of Contents
[Headers](#headers)
React component to display the content of markdown files.
[Emphasis](#emphasis)
## Getting Started
[Lists](#lists)
- Install with [npmjs](https://www.npmjs.com):
- `npm install terra-markdown`
- `yarn add terra-markdown`
[Links](#links)
## Test
> This is a quote.
[Images](#images)
[Code and Syntax Highlighting](#code)
## Component Features
* [Cross-Browser Support](https://github.com/cerner/terra-ui/blob/master/src/terra-dev-site/contributing/ComponentStandards.e.contributing.md#cross-browser-support)
[Tables](#tables)
[Blockquotes](#blockquotes)
[Inline HTML](#html)
[Horizontal Rule](#hr)
[Line Breaks](#lines)
[YouTube Videos](#videos)
<a name="headers"/>
## Headers
```no-highlight
# H1
## H2
### H3
#### H4
##### H5
###### H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H1
======
Alt-H2
------
```
# H1
## H2
### H3
#### H4
##### H5
###### H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H1
======
Alt-H2
------
<a name="emphasis"/>
## Emphasis
```no-highlight
Emphasis, aka italics, with *asterisks* or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
Strikethrough uses two tildes. ~~Scratch this.~~
```
Emphasis, aka italics, with *asterisks* or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
Strikethrough uses two tildes. ~~Scratch this.~~
<a name="lists"/>
## Lists
(In this example, leading and trailing spaces are shown with with dots: ⋅)
```no-highlight
1. First ordered list item
2. Another item
⋅⋅* Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
⋅⋅1. Ordered sub-list
4. And another item.
⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
* Unordered list can use asterisks
- Or minuses
+ Or pluses
```
1. First ordered list item
2. Another item
* Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
1. Ordered sub-list
4. And another item.
You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
To have a line break without a paragraph, you will need to use two trailing spaces.
Note that this line is separate, but within the same paragraph.
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
* Unordered list can use asterisks
- Or minuses
+ Or pluses
<a name="links"/>
## Links
There are two ways to create links.
```no-highlight
[I'm an inline-style link](https://www.google.com)
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
[I'm a reference-style link][Arbitrary case-insensitive reference text]
[I'm a relative reference to a repository file](../blob/master/LICENSE)
[You can use numbers for reference-style link definitions][1]
Or leave it empty and use the [link text itself].
URLs and URLs in angle brackets will automatically get turned into links.
http://www.example.com or <http://www.example.com> and sometimes
example.com (but not on Github, for example).
Some text to show that the reference links can follow later.
[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: http://slashdot.org
[link text itself]: http://www.reddit.com
```
[I'm an inline-style link](https://www.google.com)
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
[I'm a reference-style link][Arbitrary case-insensitive reference text]
[I'm a relative reference to a repository file](../blob/master/LICENSE)
[You can use numbers for reference-style link definitions][1]
Or leave it empty and use the [link text itself].
URLs and URLs in angle brackets will automatically get turned into links.
http://www.example.com or <http://www.example.com> and sometimes
example.com (but not on Github, for example).
Some text to show that the reference links can follow later.
[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: http://slashdot.org
[link text itself]: http://www.reddit.com
<a name="images"/>
## Images
```no-highlight
Here's our logo (hover to see the title text):
Inline-style:
![alt text](https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 1")
Reference-style:
![alt text][logo]
[logo]: https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 2"
```
Here's our logo (hover to see the title text):
Inline-style:
![alt text](https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 1")
Reference-style:
![alt text][logo]
[logo]: https://github.com/cerner/terra-core/raw/master/terra.png "Logo Title Text 2"
<a name="code"/>
## Code and Syntax Highlighting
Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and *Markdown Here* -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. *Markdown Here* supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the [highlight.js demo page](http://softwaremaniacs.org/media/soft/highlight/test.html).
```no-highlight
Inline `code` has `back-ticks around` it.
```
Inline `code` has `back-ticks around` it.
Blocks of code are either fenced by lines with three back-ticks <code>```</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.
<pre lang="no-highlight"><code>```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```
```python
s = "Python syntax highlighting"
print s
```
```
No language indicated, so no syntax highlighting.
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
```
</code></pre>
```javascript
var s = "JavaScript syntax highlighting";
alert(s);
```
```python
s = "Python syntax highlighting"
print s
```
```
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
But let's throw in a <b>tag</b>.
```
<a name="tables"/>
## Tables
Tables aren't part of the core Markdown spec, but they are part of GFM and *Markdown Here* supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.
```no-highlight
Colons can be used to align columns.
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
There must be at least 3 dashes separating each header cell.
The outer pipes (|) are optional, and you don't need to make the
raw Markdown line up prettily. You can also use inline Markdown.
Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
```
Colons can be used to align columns.
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
<a name="blockquotes"/>
## Blockquotes
```no-highlight
> Blockquotes are very handy in email to emulate reply text.
> This line is part of the same quote.
Quote break.
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
```
> Blockquotes are very handy in email to emulate reply text.
> This line is part of the same quote.
Quote break.
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
<a name="html"/>
## Inline HTML
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
```no-highlight
<dl>
<dt>Definition list</dt>
<dd>Is something people use sometimes.</dd>
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
```
<dl>
<dt>Definition list</dt>
<dd>Is something people use sometimes.</dd>
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
<a name="hr"/>
## Horizontal Rule
```
Three or more...
---
Hyphens
***
Asterisks
___
Underscores
```
Three or more...
---
Hyphens
***
Asterisks
___
Underscores
<a name="lines"/>
## Line Breaks
My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
Here are some things to try out:
```
Here's a line for us to start with.
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
This line is also a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
```
Here's a line for us to start with.
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
This line is also begins a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
(Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
<a name="videos"/>
## YouTube Videos
They can't be added directly but you can add an image with a link to the video like this:
```no-highlight
<a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
```
Or, in pure Markdown, but losing the image sizing and border:
```no-highlight
[![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
```
Referencing a bug by #bugID in your git commit links it to the slip. For example #1.
---

@@ -5,5 +5,36 @@ import React from 'react';

const headings = [
'# H1',
'## H2',
'### H3',
'#### H4',
'##### H5',
'###### H6',
].join('\n');
const relative = '![alt text](favicon.ico "relative")';
it('should render correctly', () => {
const singleSelect = mount(<Markdown id="Markdown" src={MockREADME} />);
const singleSelect = mount(<Markdown src={MockREADME} />);
expect(singleSelect).toMatchSnapshot();
});
it('should apply a base url', () => {
const singleSelect = mount(<Markdown src={relative} baseUrl="/derp/" />);
expect(singleSelect).toMatchSnapshot();
});
it('should not apply a base url', () => {
const singleSelect = mount(<Markdown src={relative} />);
expect(singleSelect).toMatchSnapshot();
});
it('should apply anchor tags to headings', () => {
const singleSelect = mount(<Markdown src={headings} hasHeadingAnchors />);
expect(singleSelect).toMatchSnapshot();
});
it('should not apply anchor tags to headings', () => {
const singleSelect = mount(<Markdown src={headings} />);
expect(singleSelect).toMatchSnapshot();
});
describe('Markdown', () => {
before(() => browser.setViewportSize({ width: 1000, height: 2000, name: 'large' }));
before(() => browser.setViewportSize({ width: 1000, height: 10000, name: 'large' }));
describe('Default', () => {
before(() => browser.url('/#/raw/tests/terra-markdown/markdown/markdown'));
Terra.should.validateElement();
Terra.should.validateElement({ selector: '#root' });
});

@@ -52,3 +52,3 @@

describe('Block Quote', () => {
before(() => browser.url('/#/raw/tests/terra-markdown/markdown/markdown'));
before(() => browser.url('/#/raw/tests/terra-markdown/markdown/blockquote'));

@@ -55,0 +55,0 @@ Terra.should.validateElement();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc