Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Apr 7, 2022
1 parent af5f8e5 commit 92a6539
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 22 deletions.
62 changes: 62 additions & 0 deletions website/_dogfooding/_pages tests/code-block-tests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,65 @@ Multi-line text inside `pre` will turn into one-liner, but it's okay (https://gi
</strong>cd", at which time b is a substring.
<br />
</CodeBlock>

## Code blocks with line numbering tests

```jsx
function PageLayout(props) {
// highlight-next-line
return <Layout title="Awesome Docusaurus page" description="Test Test Test Test Test Test Test Test Test Test Test Test Test Test ">;
}
```

```jsx showLineNumbers
function PageLayout(props) {
// highlight-next-line
return <Layout title="Awesome Docusaurus page" description="Test Test Test Test Test Test Test Test Test Test Test Test Test Test ">;
}
```

```jsx {1,3,6} showLineNumbers
function PageLayout(props) {
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
console.log(
'Test Test Test Test Test Test Test Test Test Test Test Test Test Test ',
);
}
```

```jsx {1,4-6,11} showLineNumbers
import React from 'react';

function MyComponent(props) {
if (props.isBar) {
return <div>Bar</div>;
}

return <div>Foo</div>;
}

export default MyComponent;
```
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,6 @@ function HelloCodeTitle(props) {

</BrowserWindow>

## Code line numbering

You can enable line numbering for your code block by using `showLineNumbers` key within the language meta string (don't forget to add space directly before the key).

````md
```jsx showLineNumbers
function PageLayout(props) {
return <Layout title="Awesome Docusaurus page" description="Just one more awesome page on my Docusaurus site">;
}
```
````

<BrowserWindow>

```jsx showLineNumbers
function PageLayout(props) {
return <Layout title="Awesome Docusaurus page" description="Just one more awesome page on my Docusaurus site">;
}
```

</BrowserWindow>

## Syntax highlighting {#syntax-highlighting}

Code blocks are text blocks wrapped around by strings of 3 backticks. You may check out [this reference](https://github.com/mdx-js/specification) for the specifications of MDX.
Expand Down Expand Up @@ -297,6 +275,44 @@ In the future, we may extend the magic comment system and let you define custom

:::

## Line numbering {#line-numbering}

You can enable line numbering for your code block by using `showLineNumbers` key within the language meta string (don't forget to add space directly before the key).

````md
```jsx {1,4-6,11} showLineNumbers
import React from 'react';

function MyComponent(props) {
if (props.isBar) {
return <div>Bar</div>;
}

return <div>Foo</div>;
}

export default MyComponent;
```
````

<BrowserWindow>

```jsx {1,4-6,11} showLineNumbers
import React from 'react';

function MyComponent(props) {
if (props.isBar) {
return <div>Bar</div>;
}

return <div>Foo</div>;
}

export default MyComponent;
```

</BrowserWindow>

## Interactive code editor {#interactive-code-editor}

(Powered by [React Live](https://github.com/FormidableLabs/react-live))
Expand Down

0 comments on commit 92a6539

Please sign in to comment.