Skip to content

Commit

Permalink
feat: Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
HPouyanmehr committed Jun 25, 2023
1 parent e4f6622 commit b5f98f5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 43 deletions.
75 changes: 33 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Props available for `MuiMarkdown` component:
| prismTheme | PrismTheme | vsDark | **optional** |
| Highlight | HighlightComponent | - | **optional** |
| themes | HighlightThemes | - | **optional** |
| showLineNumbers | boolean | true | **optional** |
| hideLineNumbers | boolean | false | **optional** |

Note: You cannot use overrides and options at the same time.

Expand Down Expand Up @@ -93,7 +93,7 @@ const App = () => {
return (
<MuiMarkdown
overrides={{
...getOverrides({}), // This will keep the other default overrides.
...getOverrides(), // This will keep the other default overrides.
h1: {
component: 'p',
props: {
Expand Down Expand Up @@ -123,7 +123,7 @@ const App = () => {
return (
<MuiMarkdown
overrides={{
...getOverrides({}), // This will keep the other default overrides.
...getOverrides(), // This will keep the other default overrides.
h1: {
component: CustomTypography,
props: {
Expand Down Expand Up @@ -153,43 +153,7 @@ const App = () => {
return (
<MuiMarkdown
overrides={{
...getOverrides({}), // This will keep the other default overrides.
h1: {
component: CustomTypography,
props: {
// custom props
} as CustomTypographyProps,
},
}}
>
{`# Hello markdown!`}
</MuiMarkdown>
);
};

export default App;
```

**An example of override that further customizes code blocks:**

TS and TSX:

```tsx
import React from 'react';
import { MuiMarkdown, getOverrides } from 'mui-markdown';
import { Highlight, themes, Prism } from 'prism-react-renderer';
import CustomTypography, {
CustomTypographyProps,
} from './components/CustomTypography';

(typeof global !== "undefined" ? global : window).Prism = Prism
require("prismjs/components/prism-python")

const App = () => {
return (
<MuiMarkdown
overrides={{
...getOverrides({ Highlight, themes, theme: themes.vsDark, showLineNumbers: false })
...getOverrides(), // This will keep the other default overrides.
h1: {
component: CustomTypography,
props: {
Expand Down Expand Up @@ -251,7 +215,9 @@ const App = () => {
Highlight={Highlight}
themes={themes}
prismTheme={themes.github}
>{`# Hello markdown!`}</MuiMarkdown>
>
{`# Hello markdown!`}
</MuiMarkdown>
);
};

Expand All @@ -271,7 +237,32 @@ const App = () => {
Highlight={Highlight}
themes={themes}
prismTheme={themes.github}
>{`# Hello markdown!`}</MuiMarkdown>
>
{`# Hello markdown!`}
</MuiMarkdown>
);
};

export default App;
```

Also to disable the line numbers in the code block you can use the `hideLineNumbers`.

```tsx
import React from 'react';
import { MuiMarkdown } from 'mui-markdown';
import { Highlight, themes } from 'prism-react-renderer';

const App = () => {
return (
<MuiMarkdown
Highlight={Highlight}
themes={themes}
prismTheme={themes.github}
hideLineNumbers
>
{`# Hello markdown!`}
</MuiMarkdown>
);
};

Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mui-markdown",
"version": "1.1.1",
"version": "1.1.2",
"private": false,
"author": {
"name": "Hosein Pouyanmehr",
Expand Down

0 comments on commit b5f98f5

Please sign in to comment.