Markdown
Markdown is a lightweight markup language for creating formatted text.

Props:

Properties
Descriptions
Required
Default
copyable
MarkdownWhisperCopyMode.Body- Copy the text from the body of the component (including markdown).
body
The content that you want displayed. Supports markdown.
onCopy
Executes the provided function when the Markdown is copied.
tooltip
Text that appears when hovering over the component.
onLinkClick
Whisper event handler that can be used to hook into click events on from links in the markdown component. Receives the label provided for the link when it is clicked.

Markdown Crash Course

Markdown is a shorthand way of adding styling to text. Here's a quick breakdown of some of the ways that you can achieve certain effects using it.
  • Styling: Support markdown including Bold ~~strikethrough, italics, links and etc.
    • Headings: We only support 3 different headings on Olive Helps
    # Heading level 1

    Heading level 1

    ## Heading level 2

    Heading level 2

    ### Heading level 3

    Heading level 3

    • Bold:

      Markdown
      Rendered Output
      I just love **bold text**.
      I just love bold text.
      I just love __bold text__.
      I just love bold text.
    • Italic:

      Markdown
      Rendered Output
      Italicized text is the *cat's meow*.
      Italicized text is the cat’s meow.
      Italicized text is the _cat's meow_.
      Italicized text is the cat’s meow.
      A*cat*meow
      Acatmeow
    • Bold and Italic

      Markdown
      Rendered Output
      This text is ***really important***.
      This text is really important.
      This text is ___really important___.
      This text is really important.
      This text is __*really important*__.
      This text is really important.
      This text is **_really important_**.
      This text is really important.
      This is really***very***important text.
      This is reallyveryimportant text.
    • BlockQuotes:
      1
      > Dorothy followed her through many of the beautiful rooms in her castle.
      Copied!
      The rendered output looks like this:
      Dorothy followed her through many of the beautiful rooms in her castle.
    • Unordered Lists

      To create an unordered list, add dashes (-), asterisks (*), or plus signs (+) in front of line items. Indent one or more items to create a nested list.
      Markdown
      Rendered Output
      - First item - Second item - Third item - Fourth item
      • First item
      • Second item
      • Third item
      • Fourth item
      * First item * Second item * Third item * Fourth item
      • First item
      • Second item
      • Third item
      • Fourth item
      + First item + Second item + Third item + Fourth item
      • First item
      • Second item
      • Third item
      • Fourth item
      - First item - Second item - Third item - Indented item - Indented item - Fourth item
      • First item
      • Second item
      • Third item
        • Indented item
        • Indented item
      • Fourth item
    • Tables:
    • 1
      A table:
      2
      3
      | Table Header 1 | Table header 2 |
      4
      | - | - |
      5
      | Row 1 Col 1 | Row 1 Col 2 |
      6
      | Row 2 Col 1 | Row 2 Col 2 |`;
      Copied!
    • image
1
![Tux, the Linux mascot](/assets/images/tux.png)
Copied!

Examples

Now let's take a closer look of Markdown component! We use different markdown syntaxes to complete this example.
If you hover your cursor to the first component that contains the penguin, you are able to see a tooltip pop up. And if you click that area, you can copy the first component. This is the copied markdown text:
1
<h1>Guess which link is the correct link of Olive Helps dev hub.</h1>
2
<h2>You only have a single chance!</h2>
3
<p><img src="https://d33wubrfki0l68.cloudfront.net/e7ed9fe4bafe46e275c807d63591f85f9ab246ba/e2d28/assets/images/tux.png" alt="Tux"/></p>
4
<p><strong>We have a brief description table for you:</strong></p>
5
<table><thead><tr><th style="text-align:left">People</th><th style="text-align:left">What they say</th></tr></thead><tbody><tr><td style="text-align:left">Josef:</td><td style="text-align:left">Link 3 is the correct one.</td></tr><tr><td style="text-align:left">Michael:</td><td style="text-align:left">Link 1 is not the correct one.</td></tr><tr><td style="text-align:left">Brett:</td><td style="text-align:left">They are all lying.</td></tr></tbody></table>
6
<p>Knowing that only one person is not lying and we only have 1 link that can direct you to Olive Helps, which one is the correct link?</p>
Copied!
Type Script Example
React Example
1
import { whisper } from '@oliveai/ldk';
2
import { MarkdownWhisperCopyMode, WhisperComponentType } from '@oliveai/ldk/dist/whisper/types';
3
4
5
const markdownSampleText = `
6
# Guess which link is the correct link of Olive Helps dev hub.
7
## You only have a single chance!
8
9
![Tux](https://d33wubrfki0l68.cloudfront.net/e7ed9fe4bafe46e275c807d63591f85f9ab246ba/e2d28/assets/images/tux.png)
10
11
**We have a brief description table for you:**
12
13
| People | What they say |
14
| :----------| :----------- |
15
| Josef: | Link 3 is the correct one. |
16
| Michael:| Link 1 is not the correct one. |
17
| Brett: | They are all lying. |
18
19
Knowing that only one person is not lying and we only have 1 link that can direct you to Olive Helps, which one is the correct link?
20
21
22
`;
23
24
const markdown = `
25
# Links:
26
[Link 1](# "A Link")
27
28
[Link 2](#)
29
30
[Link 3](https://www.oliveai.dev/)
31
`;
32
33
export const markdownWhisper = async () => {
34
await whisper.create({
35
label: 'Markdown whisper',
36
onClose: () => {
37
console.debug('closed');
38
},
39
components: [
40
{
41
body: markdownSampleText,
42
type: WhisperComponentType.Markdown,
43
copyable: MarkdownWhisperCopyMode.Body,
44
},
45
{
46
body: markdown,
47
type: WhisperComponentType.Markdown,
48
onLinkClick: (error, linkName) => {
49
console.info(`Received click on the link: ${JSON.stringify(linkName)}`);
50
if (linkName === 'Link 1') {
51
console.log('This is not the correct link.');
52
} else if (linkName === 'Link 2') {
53
console.log('This is not the correct link.');
54
} else if (linkName === 'Link 3') {
55
console.log(
56
'Yes! This is the correct link! You are going to Olive Helps Dev Hub... ',
57
);
58
} else {
59
if (error) {
60
console.log(error.message);
61
}
62
}
63
},
64
tooltip: 'Link 3 is the right answer!',
65
},
66
],
67
});
68
}
69
Copied!
1
import { React, ReactWhisper } from '@oliveai/ldk';
2
import { MarkdownWhisperCopyMode } from '@oliveai/ldk/dist/whisper/types';
3
4
const markdownSampleText = `
5
# Guess which link is the correct link of Olive Helps dev hub.
6
## You only have a single chance!
7
8
![Tux](https://d33wubrfki0l68.cloudfront.net/e7ed9fe4bafe46e275c807d63591f85f9ab246ba/e2d28/assets/images/tux.png)
9
10
**We have a brief description table for you:**
11
12
| People | What they say |
13
| :----------| :----------- |
14
| Josef: | Link 3 is the correct one. |
15
| Michael:| Link 1 is not the correct one. |
16
| Brett: | They are all lying. |
17
18
Knowing that only one person is not lying and we only have 1 link that can direct you to Olive Helps, which one is the correct link?
19
`;
20
21
const markdown = `
22
# Links:
23
[Link 1](# "A Link")
24
25
[Link 2](#)
26
27
[Link 3](https://www.oliveai.dev/)
28
29
`;
30
const ReactMarkdownExample: React.FunctionComponent<Object> = () => {
31
32
return (
33
<oh-whisper
34
label="Markdown whisper"
35
onClose={() => {
36
console.debug('closed');
37
}}
38
>
39
<oh-markdown
40
body={markdownSampleText}
41
copyable={MarkdownWhisperCopyMode.Body}
42
/>
43
<oh-markdown
44
body={markdown}
45
tooltip="Link 3 is the right answer!"
46
onLinkClick={(error, linkName) => {
47
console.info(`Received click on the link: ${JSON.stringify(linkName)}`);
48
if (linkName === 'Link 1') {
49
console.log('This is not the correct link.');
50
} else if (linkName === 'Link 2') {
51
console.log('This is not the correct link.');
52
} else if (linkName === 'Link 3') {
53
console.log('Yes! This is the correct link! You are going to Olive Helps Dev Hub... ');
54
} else {
55
if (error) {
56
console.log(error.message);
57
}
58
}
59
}}
60
/>
61
</oh-whisper>
62
);
63
};
64
65
ReactWhisper.renderNewWhisper(<ReactMarkdownExample/>);
66
Copied!