{"id":4421,"url":"https://github.com/iamacup/react-native-markdown-display","last_synced_at":"2025-08-04T01:32:27.963Z","repository":{"id":35540401,"uuid":"218278456","full_name":"iamacup/react-native-markdown-display","owner":"iamacup","description":"React Native 100% compatible CommonMark renderer","archived":false,"fork":true,"pushed_at":"2024-04-17T11:16:10.000Z","size":5008,"stargazers_count":608,"open_issues_count":43,"forks_count":173,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-01T05:39:06.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mientjan/react-native-markdown-renderer","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamacup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-29T12:10:24.000Z","updated_at":"2024-11-29T09:55:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/iamacup/react-native-markdown-display","commit_stats":null,"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamacup%2Freact-native-markdown-display","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamacup%2Freact-native-markdown-display/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamacup%2Freact-native-markdown-display/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamacup%2Freact-native-markdown-display/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamacup","download_url":"https://codeload.github.com/iamacup/react-native-markdown-display/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582487,"owners_count":17940587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:11.391Z","updated_at":"2024-12-07T08:30:39.030Z","avatar_url":"https://github.com/iamacup.png","language":"JavaScript","funding_links":[],"categories":["Components","JavaScript"],"sub_categories":["Text \u0026 Rich Content"],"readme":"# React Native Markdown Display [![npm version](https://badge.fury.io/js/react-native-markdown-display.svg)](https://badge.fury.io/js/react-native-markdown-display) [![Known Vulnerabilities](https://snyk.io/test/github/iamacup/react-native-markdown-display/badge.svg)](https://snyk.io/test/github/iamacup/react-native-markdown-display)\n\nIt a 100% compatible CommonMark renderer, a react-native markdown renderer done right. This is __not__ a web-view markdown renderer but a renderer that uses native components for all its elements. These components can be overwritten and styled as needed.\n\n### Compatibility with react-native-markdown-renderer\n\nThis is intended to be a replacement for react-native-markdown-renderer, with a variety of bug fixes and enhancements - **Due to how the new style rules work, there may be some tweaking needed**, [see how to style stuff section below](#How-to-style-stuff)\n\n### Install\n\n#### Yarn\n```npm\nyarn add react-native-markdown-display\n```\n\n#### NPM\n```npm\nnpm install -S react-native-markdown-display\n```\n\n### Get Started\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar } from 'react-native';\n\nimport Markdown from 'react-native-markdown-display';\n\nconst copy = `# h1 Heading 8-)\n\n**This is some bold text!**\n\nThis is normal text\n`;\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n          \u003cMarkdown\u003e\n            {copy}\n          \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n\n### Props and Functions\n\nThe `\u003cMarkdown\u003e` object takes the following common props:\n\n| Property | Default | Required | Description                                                      \n| --- | --- | --- | ---\n| `children` | N/A | `true` | The markdown string to render, or the [pre-processed tree](#pre-processing)\n| `style` | [source](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/styles.js) | `false` | An object to override the styling for the various rules, [see style section below](#rules-and-styles) for more info\n| `mergeStyle` | `true` | `false` | If true, when a style is supplied, the individual items are merged with the default styles instead of overwriting them\n| `rules` | [source](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js) | `false` | An object of rules that specify how to render each markdown item, [see rules section below](#rules) for more info\n| `onLinkPress` | `import { Linking } from 'react-native';` and `Linking.openURL(url);` | `false` | A handler function to change click behaviour, [see handling links section below](#handling-links) for more info\n| `debugPrintTree` | `false` | `false` | Will print the AST tree to the console to help you see what the markdown is being translated to\n\n\nAnd some additional, less used options:\n\n| Property | Default | Required | Description    \n| --- | ---  | --- | ---\n| `renderer` | `instanceOf(AstRenderer)` | `false` | Used to specify a custom renderer, you can not use the rules or styles props with a custom renderer.\n| `markdownit` | `instanceOf(MarkdownIt)` | `false` | A custom markdownit instance with your configuration, default is `MarkdownIt({typographer: true})`\n| `maxTopLevelChildren` | `null` | `false` | If defined as a number will only render out first `n` many top level children, then will try to render out `topLevelMaxExceededItem`\n| `topLevelMaxExceededItem` | `\u003cText key=\"dotdotdot\"\u003e...\u003c/Text\u003e` | `false` | Will render when `maxTopLevelChildren` is hit. Make sure to give it a key!\n| `allowedImageHandlers` | `['data:image/png;base64', 'data:image/gif;base64', 'data:image/jpeg;base64', 'https://', 'http://']` | `false` | Any image that does not start with one of these will have the `defaultImageHandler` value prepended to it (unless `defaultImageHandler` is null in which case it won't try to render anything)\n| `defaultImageHandler` | `http://` | `false` | Will be prepended to an image url if it does not start with something in the `allowedImageHandlers` array, if this is set to null, it won't try to recover but will just not render anything instead.\n\n\n# Syntax Support\n\n\u003cdetails\u003e\u003csummary\u003eHeadings\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  # h1 Heading 8-)\n  ## h2 Heading\n  ### h3 Heading\n  #### h4 Heading\n  ##### h5 Heading\n  ###### h6 Heading\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-1.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-1.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eHorizontal Rules\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  Some text above\n  ___\n\n  Some text in the middle\n\n  ---\n\n  Some text below\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-2.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-2.png\"/\u003e  \n\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\u003csummary\u003eEmphasis\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  **This is bold text**\n\n  __This is bold text__\n\n  *This is italic text*\n\n  _This is italic text_\n\n  ~~Strikethrough~~\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-4.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-4.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eBlockquotes\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  \u003e Blockquotes can also be nested...\n  \u003e\u003e ...by using additional greater-than signs right next to each other...\n  \u003e \u003e \u003e ...or with spaces between arrows.\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-5.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-5.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eLists\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  Unordered\n\n  + Create a list by starting a line with `+`, `-`, or `*`\n  + Sub-lists are made by indenting 2 spaces:\n    - Marker character change forces new list start:\n      * Ac tristique libero volutpat at\n      + Facilisis in pretium nisl aliquet. This is a very long list item that will surely wrap onto the next line.\n      - Nulla volutpat aliquam velit\n  + Very easy!\n\n  Ordered\n\n  1. Lorem ipsum dolor sit amet\n  2. Consectetur adipiscing elit. This is a very long list item that will surely wrap onto the next line.\n  3. Integer molestie lorem at massa\n\n  Start numbering with offset:\n\n  57. foo\n  58. bar\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-6.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-6.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eCode\u003c/summary\u003e\n\u003cp\u003e\n  \n```\n  Inline \\`code\\`\n\n  Indented code\n\n      // Some comments\n      line 1 of code\n      line 2 of code\n      line 3 of code\n\n\n  Block code \"fences\"\n\n  \\`\\`\\`\n  Sample text here...\n  \\`\\`\\`\n\n  Syntax highlighting\n\n  \\`\\`\\` js\n  var foo = function (bar) {\n    return bar++;\n  };\n\n  console.log(foo(5));\n  \\`\\`\\`\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-7.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-7.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eTables\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  | Option | Description |\n  | ------ | ----------- |\n  | data   | path to data files to supply the data that will be passed into templates. |\n  | engine | engine to be used for processing templates. Handlebars is the default. |\n  | ext    | extension to be used for dest files. |\n\n  Right aligned columns\n\n  | Option | Description |\n  | ------:| -----------:|\n  | data   | path to data files to supply the data that will be passed into templates. |\n  | engine | engine to be used for processing templates. Handlebars is the default. |\n  | ext    | extension to be used for dest files. |\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-8.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-8.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eLinks\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  [link text](https://www.google.com)\n\n  [link with title](https://www.google.com \"title text!\")\n\n  Autoconverted link https://www.google.com (enable linkify to see)\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-9.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-9.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eImages\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  ![Minion](https://octodex.github.com/images/minion.png)\n  ![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg \"The Stormtroopocat\")\n\n  Like links, Images also have a footnote style syntax\n\n  ![Alt text][id]\n\n  With a reference later in the document defining the URL location:\n\n  [id]: https://octodex.github.com/images/dojocat.jpg  \"The Dojocat\"\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-10.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-10.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eTypographic Replacements\u003c/summary\u003e\n\u003cp\u003e\n\n```\n  Enable typographer option to see result.\n\n  (c) (C) (r) (R) (tm) (TM) (p) (P) +-\n\n  test.. test... test..... test?..... test!....\n\n  !!!!!! ???? ,,  -- ---\n\n  \"Smartypants, double quotes\" and 'single quotes'\n```\n\n| iOS | Android\n| --- | ---\n| \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/ios-3.png\"/\u003e  | \u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/android-3.png\"/\u003e  \n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003ePlugins and Extensions\u003c/summary\u003e\n\u003cp\u003e\n\n  Plugins for **extra** syntax support can be added using any markdown-it compatible plugins - [see plugins](https://www.npmjs.com/browse/keyword/markdown-it-plugin) for documentation from markdown-it. An example for integration follows:\n\n\n#### Step 1\n\nIdentify the new components and integrate the plugin with a rendered component. We can use the `debugPrintTree` property to see what rules we are rendering:\n\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar } from 'react-native';\n\nimport Markdown, { MarkdownIt } from 'react-native-markdown-display';\nimport blockEmbedPlugin from 'markdown-it-block-embed';\n\nconst markdownItInstance = \n    MarkdownIt({typographer: true})\n      .use(blockEmbedPlugin, {\n        containerClassName: \"video-embed\"\n      });\n\nconst copy = `\n# Some header\n\n@[youtube](lJIrF4YjHfQ)\n`;\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n            \u003cMarkdown\n              debugPrintTree\n              markdownit={markdownItInstance}\n            \u003e\n              {copy}\n            \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n\n```\n\nIn the console, we will see the following rendered tree:\n\n```\nbody\n-heading1\n--textgroup\n---text\n-video\n```\n\nWith the following error message:\n\n```\nWarning, unknown render rule encountered: video. 'unknown' render rule used (by default, returns null - nothing rendered) \n```\n\n\n#### Step 2\n\nWe need to create the **render rules** and **styles** to handle this new **'video'** component\n\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar } from 'react-native';\n\nimport Markdown, { MarkdownIt } from 'react-native-markdown-display';\nimport blockEmbedPlugin from 'markdown-it-block-embed';\n\nconst markdownItInstance = \n    MarkdownIt({typographer: true})\n      .use(blockEmbedPlugin, {\n        containerClassName: \"video-embed\"\n      });\n\nconst copy = `\n# Some header\n\n@[youtube](lJIrF4YjHfQ)\n`;\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n            \u003cMarkdown\n              debugPrintTree\n              markdownit={markdownItInstance}\n              style={{\n                  video: {\n                    color: 'red',\n                  }\n                }}\n              rules={{\n                  video: (node, children, parent, styles) =\u003e{\n                    // examine the node properties to see what video we need to render\n                    console.log(node); // expected output of this is in readme.md below this code snip\n\n                    return (\u003cText key={node.key} style={styles.video}\u003e\n                      Return a video component instead of this text component!\n                    \u003c/Text\u003e);\n                  }\n                   \n                }}\n            \u003e\n              {copy}\n            \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\nAnd all of the video properties needed to render something meaningful are on the node, like this:\n\n```\n{type: \"video\", sourceType: \"video\", sourceInfo: {…}, sourceMeta: null, block: true, …}\n  attributes: {}\n  block: true\n  children: []\n  content: \"\"\n  index: 1\n  key: \"rnmr_1720a98f540_video\"\n  markup: \"@[youtube](lJIrF4YjHfQ)\"\n  sourceInfo:\n    service: YouTubeService\n      env: PluginEnvironment {md: MarkdownIt, options: {…}, services: {…}}\n      name: \"youtube\"\n      options:\n        height: 390\n        width: 640\n      serviceName: \"youtube\"\n      videoID: \"lJIrF4YjHfQ\"\n      videoReference: \"lJIrF4YjHfQ\"\n  sourceMeta: null\n  sourceType: \"video\"\n  tokenIndex: 5\n  type: \"video\"\n```\n\n#### Other Debugging\n\nYou can do some additional debugging of what the markdown instance is spitting out like this:\n\n```jsx\nimport Markdown, { MarkdownIt } from 'react-native-markdown-display';\nimport blockEmbedPlugin from 'markdown-it-block-embed';\n\nconst markdownItInstance = \n    MarkdownIt({typographer: true})\n      .use(blockEmbedPlugin, {\n        containerClassName: \"video-embed\"\n      });\n\nconst copy = `\n# Some header\n\n@[youtube](lJIrF4YjHfQ)\n`;\n\n// this shows you the tree that is used by the react-native-markdown-display\nconst astTree = markdownItInstance.parse(copy, {});\nconsole.log(astTree);\n\n//this contains the html that would be generated - not used by react-native-markdown-display but useful for reference\nconst html = markdownItInstance.render(copy);\nconsole.log(html);\n\n```\n\nThe above code will output something like this:\n\n```\nastTree:\n\n(4) [Token, Token, Token, Token]\n\n0: Token {type: \"heading_open\", tag: \"h1\", attrs: null, map: Array(2), nesting: 1, …}\n1: Token {type: \"inline\", tag: \"\", attrs: null, map: Array(2), nesting: 0, …}\n2: Token {type: \"heading_close\", tag: \"h1\", attrs: null, map: null, nesting: -1, …}\n3: Token {type: \"video\", tag: \"div\", attrs: null, map: Array(2), nesting: 0, …}\n\nlength: 4\n```\n\n```\nhtml:\n\n\n\u003ch1\u003eSome header\u003c/h1\u003e\n\u003cdiv class=\"video-embed block-embed-service-youtube\"\u003e\u003ciframe type=\"text/html\" src=\"//www.youtube.com/embed/lJIrF4YjHfQ\" frameborder=\"0\" width=\"640\" height=\"390\" webkitallowfullscreen mozallowfullscreen allowfullscreen\u003e\u003c/iframe\u003e\u003c/div\u003e\n```\n\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\u003csummary\u003eAll Markdown for Testing\u003c/summary\u003e\n\u003cp\u003e\n\nThis is all of the markdown in one place for testing that your applied styles work in all cases\n\n```\nHeadings\n\n  # h1 Heading 8-)\n  ## h2 Heading\n  ### h3 Heading\n  #### h4 Heading\n  ##### h5 Heading\n  ###### h6 Heading\n\n\nHorizontal Rules\n\n  Some text above\n  ___\n\n  Some text in the middle\n\n  ---\n\n  Some text below\n\n\nEmphasis\n\n  **This is bold text**\n\n  __This is bold text__\n\n  *This is italic text*\n\n  _This is italic text_\n\n  ~~Strikethrough~~\n\n\nBlockquotes\n\n  \u003e Blockquotes can also be nested...\n  \u003e\u003e ...by using additional greater-than signs right next to each other...\n  \u003e \u003e \u003e ...or with spaces between arrows.\n\n\nLists\n\n  Unordered\n\n  + Create a list by starting a line with `+`, `-`, or `*`\n  + Sub-lists are made by indenting 2 spaces:\n    - Marker character change forces new list start:\n      * Ac tristique libero volutpat at\n      + Facilisis in pretium nisl aliquet. This is a very long list item that will surely wrap onto the next line.\n      - Nulla volutpat aliquam velit\n  + Very easy!\n\n  Ordered\n\n  1. Lorem ipsum dolor sit amet\n  2. Consectetur adipiscing elit. This is a very long list item that will surely wrap onto the next line.\n  3. Integer molestie lorem at massa\n\n  Start numbering with offset:\n\n  57. foo\n  58. bar\n\n\nCode\n\n  Inline \\`code\\`\n\n  Indented code\n\n      // Some comments\n      line 1 of code\n      line 2 of code\n      line 3 of code\n\n\n  Block code \"fences\"\n\n  \\`\\`\\`\n  Sample text here...\n  \\`\\`\\`\n\n  Syntax highlighting\n\n  \\`\\`\\` js\n  var foo = function (bar) {\n    return bar++;\n  };\n\n  console.log(foo(5));\n  \\`\\`\\`\n\n\nTables\n\n  | Option | Description |\n  | ------ | ----------- |\n  | data   | path to data files to supply the data that will be passed into templates. |\n  | engine | engine to be used for processing templates. Handlebars is the default. |\n  | ext    | extension to be used for dest files. |\n\n  Right aligned columns\n\n  | Option | Description |\n  | ------:| -----------:|\n  | data   | path to data files to supply the data that will be passed into templates. |\n  | engine | engine to be used for processing templates. Handlebars is the default. |\n  | ext    | extension to be used for dest files. |\n\n\nLinks\n\n  [link text](https://www.google.com)\n\n  [link with title](https://www.google.com \"title text!\")\n\n  Autoconverted link https://www.google.com (enable linkify to see)\n\n\nImages\n\n  ![Minion](https://octodex.github.com/images/minion.png)\n  ![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.jpg \"The Stormtroopocat\")\n\n  Like links, Images also have a footnote style syntax\n\n  ![Alt text][id]\n\n  With a reference later in the document defining the URL location:\n\n  [id]: https://octodex.github.com/images/dojocat.jpg  \"The Dojocat\"\n\n\nTypographic Replacements\n\n  Enable typographer option to see result.\n\n  (c) (C) (r) (R) (tm) (TM) (p) (P) +-\n\n  test.. test... test..... test?..... test!....\n\n  !!!!!! ???? ,,  -- ---\n\n  \"Smartypants, double quotes\" and 'single quotes'\n\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n# Rules and Styles\n\n### How to style stuff\n\nText styles are applied in a way that makes it much more convenient to manage changes to global styles while also allowing fine tuning of individual elements.\n\nThink of the implementation like applying styles in CSS. changes to the `body` effect everything, but can be overwritten further down the style / component tree.\n\n**Be careful when styling 'text':** the text rule is not applied to all rendered text, most notably list bullet points. If you want to, for instance, color all text, change the `body` style.\n\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\n\u003cp\u003e\n\n\u003cimg src=\"https://github.com/iamacup/react-native-markdown-display/raw/master/doc/images/style-example.png\"/\u003e \n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar } from 'react-native';\n\nimport Markdown from 'react-native-markdown-display';\n\nconst copy = `\nThis is some text which is red because of the body style, which is also really small!\n\n\\`\\`\\`\n//This is a code block woooo\n\nconst cool = () =\u003e {\n  console.log('????');\n};\n\\`\\`\\`\n\nand some more small text\n\n# This is a h1\n## this is a h2\n### this is a h3\n`;\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n            \u003cMarkdown\n              style={{\n                body: {color: 'red', fontSize: 10},\n                heading1: {color: 'purple'},\n                code_block: {color: 'black', fontSize: 14}\n              }}\n            \u003e\n              {copy}\n            \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n### Styles \n\nStyles are used to override how certain rules are styled. The existing implementation is [here](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/styles.js)\n\n**NOTE:** By default styles are merged with the existing implementation, to change this, see the `mergeStyle` prop\n\n\u003cdetails\u003e\u003csummary\u003eExample Implementation\u003c/summary\u003e\n\u003cp\u003e\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar, StyleSheet } from 'react-native';\n\nimport Markdown from 'react-native-markdown-display';\n\nconst styles = StyleSheet.create({\n  heading1: {\n    fontSize: 32,\n    backgroundColor: '#000000',\n    color: '#FFFFFF',\n  },\n  heading2: {\n    fontSize: 24,\n  },\n  heading3: {\n    fontSize: 18,\n  },\n  heading4: {\n    fontSize: 16,\n  },\n  heading5: {\n    fontSize: 13,\n  },\n  heading6: {\n    fontSize: 11,\n  }\n});\n\nconst copy = `\n# h1 Heading 8-)\n## h2 Heading 8-)\n### h3 Heading 8-)\n\n| Option | Description |\n| ------ | ----------- |\n| data   | path to data files to supply the data that will be passed into templates. |\n| engine | engine to be used for processing templates. Handlebars is the default. |\n| ext    | extension to be used for dest files. |\n`;\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n            \u003cMarkdown\n              style={styles}\n            \u003e\n              {copy}\n            \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n### Rules\n\nRules are used to specify how you want certain elements to be displayed. The existing implementation is [here](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js)\n\n\u003cdetails\u003e\u003csummary\u003eExample Implementation\u003c/summary\u003e\n\u003cp\u003e\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar, Text } from 'react-native';\n\nimport Markdown from 'react-native-markdown-display';\n\nconst rules = {\n    heading1: (node, children, parent, styles) =\u003e\n      \u003cText key={node.key} style={[styles.heading, styles.heading1]}\u003e\n        \u003e\u003e H1 TEXT HERE \u003e\u003e \"{children}\"\n      \u003c/Text\u003e,\n    heading2: (node, children, parent, styles) =\u003e\n      \u003cText key={node.key} style={[styles.heading, styles.heading2]}\u003e\n        \u003e\u003e H2 TEXT HERE \u003e\u003e \"{children}\"\n      \u003c/Text\u003e,\n    heading3: (node, children, parent, styles) =\u003e\n      \u003cText key={node.key} style={[styles.heading, styles.heading3]}\u003e\n        \u003e\u003e H3 TEXT HERE \u003e\u003e \"{children}\"\n      \u003c/Text\u003e,\n};\n\nconst copy = `\n# h1 Heading 8-)\n## h2 Heading 8-)\n### h3 Heading 8-)\n\n| Option | Description |\n| ------ | ----------- |\n| data   | path to data files to supply the data that will be passed into templates. |\n| engine | engine to be used for processing templates. Handlebars is the default. |\n| ext    | extension to be used for dest files. |\n`;\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n            \u003cMarkdown\n              rules={rules}\n            \u003e\n              {copy}\n            \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n### All rules and their associated styles:\n\n| Render Rule | Style(s) |\n| ------ | ----------- |\n| `body` | `body` | \n| `heading1` | `heading1` |\n| `heading2` | `heading2` |\n| `heading3` | `heading3` |\n| `heading4` | `heading4` |\n| `heading5` | `heading5` |\n| `heading6` | `heading6` | \n| `hr` | `hr` | \n| `strong` | `strong` | \n| `em` | `em` | \n| `s` | `s` | \n| `blockquote` | `blockquote` | \n| `bullet_list` | `bullet_list` | \n| `ordered_list` | `ordered_list` | \n| `list_item` | `list_item` - This is a special case that contains a set of pseudo classes that don't align to the render rule: `ordered_list_icon`, `ordered_list_content`, `bullet_list_icon`, `bullet_list_content` | \n| `code_inline` | `code_inline` | \n| `code_block` | `code_block` | \n| `fence` | `fence` | \n| `table` | `table` | \n| `thead` | `thead` | \n| `tbody` | `tbody` | \n| `th` | `th` | \n| `tr` | `tr` | \n| `td` | `td` | \n| `link` | `link` | \n| `blocklink` | `blocklink` | \n| `image` | `image` | \n| `text` | `text` | \n| `textgroup` | `textgroup` | \n| `paragraph` | `paragraph` | \n| `hardbreak` | `hardbreak` | \n| `softbreak` | `softbreak` | \n| `pre` | `pre` | \n| `inline` | `inline` | \n| `span` | `span` | \n\n# Handling Links\n\nLinks, by default, will be handled with the `import { Linking } from 'react-native';` import and `Linking.openURL(url);` call.\n\nIt is possible to overwrite this behaviour in one of two ways:\n\n\u003cdetails\u003e\u003csummary\u003eonLinkPress Callback\u003c/summary\u003e\n\u003cp\u003e\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar } from 'react-native';\n\nimport Markdown from 'react-native-markdown-display';\n\nconst copy = `[This is a link!](https://github.com/iamacup/react-native-markdown-display/)`;\n\nconst onLinkPress = (url) =\u003e {\n    if (url) {\n      // some custom logic\n      return false;\n    }\n    \n    // return true to open with `Linking.openURL\n    // return false to handle it yourself\n    return true\n  }\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n          \u003cMarkdown\n             onLinkPress={onLinkPress}\n          \u003e\n            {copy}\n          \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eUsing a Custom Rule\u003c/summary\u003e\n\u003cp\u003e\n\nYou will need to overwrite one or both of `link` and `blocklink`, the original defenitions can be [found here](https://github.com/iamacup/react-native-markdown-display/blob/master/src/lib/renderRules.js)\n\nSomething like this with `yourCustomHandlerFunctionOrLogicHere`:\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar, Text } from 'react-native';\n\nimport Markdown from 'react-native-markdown-display';\n\nconst copy = `[This is a link!](https://github.com/iamacup/react-native-markdown-display/)`;\n\nconst rules = {\n  link: (node, children, parent, styles) =\u003e {\n    return (\n      \u003cText key={node.key} style={styles.link} onPress={() =\u003e yourCustomHandlerFunctionOrLogicHere(node.attributes.href) }\u003e\n        {children}\n      \u003c/Text\u003e\n    );\n  },\n};\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n          \u003cMarkdown\n             rules={rules}\n          \u003e\n            {copy}\n          \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\n# Disabling Specific Types of Markdown\n\nYou can dissable any type of markdown you want, which is very useful in a mobile environment, by passing the markdownit property like below. Note that for convenience we also export the `MarkdownIt` instance so you don't have to include it as a project dependency directly just to remove some types of markdown.\n\nThis example will stop images and links.\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar, Text } from 'react-native';\n\nimport Markdown, { MarkdownIt } from 'react-native-markdown-display';\n\nconst copy = `\n# This heading will show with formatting\n\n[but this link will just](be displayed as this text)\n`;\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n            \u003cMarkdown\n              markdownit={\n                MarkdownIt({typographer: true}).disable([ 'link', 'image' ])\n              }\n            \u003e\n              {copy}\n            \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\nA full list of things you can turn off is [here](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js)\n\n\n### Pre Processing\n\nIt is possible to need to pre-process the data outside of this library ([related discussion here](https://github.com/iamacup/react-native-markdown-display/issues/79)). As a result, you can pass an AST tree directly as the children like this:\n\n```jsx\nimport React from 'react';\nimport { SafeAreaView, ScrollView, StatusBar, Text } from 'react-native';\n\nimport Markdown, { MarkdownIt, tokensToAST, stringToTokens } from 'react-native-markdown-display';\n\nconst markdownItInstance = MarkdownIt({typographer: true});\n\nconst copy = `\n# Hello this is a title\n\nThis is some text with **BOLD!**\n`;\n\nconst ast = tokensToAST(stringToTokens(copy, markdownItInstance))\n\nconst App: () =\u003e React$Node = () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cStatusBar barStyle=\"dark-content\" /\u003e\n      \u003cSafeAreaView\u003e\n        \u003cScrollView\n          contentInsetAdjustmentBehavior=\"automatic\"\n          style={{height: '100%'}}\n        \u003e\n            \u003cMarkdown\n            \u003e\n              {ast}\n            \u003c/Markdown\u003e\n        \u003c/ScrollView\u003e\n      \u003c/SafeAreaView\u003e\n    \u003c/\u003e\n  );\n};\n\nexport default App;\n```\n\n\n### Other Notes\n\nThis is a fork of [react-native-markdown-renderer](https://github.com/mientjan/react-native-markdown-renderer), a library that unfortunately has not been updated for some time so i took all of the outstanding pull requests from that library and tested + merged as necessary.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamacup%2Freact-native-markdown-display","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamacup%2Freact-native-markdown-display","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamacup%2Freact-native-markdown-display/lists"}