### Convert Markdown to Notion Blocks Source: https://github.com/tryfabric/martian/blob/master/README.md This example shows how to convert standard Markdown blockquotes, GFM alerts, and emoji-style callouts into Notion blocks using the `markdownToBlocks` function. It illustrates the output for each type of input, including how emoji callouts are rendered with specific icons and background colors when `enableEmojiCallouts` is true. ```typescript markdownToBlocks('> A regular blockquote'); markdownToBlocks('> [!NOTE]\n> Important information'); markdownToBlocks('> 📘 Note: Important information', { enableEmojiCallouts: true, }); ``` -------------------------------- ### Convert Markdown to Notion RichText Source: https://github.com/tryfabric/martian/blob/master/README.md An example of using the `markdownToRichText` function to convert a simple Markdown string containing bold and italic text into Notion API RichText objects. This function is useful for creating formatted text content within Notion. ```javascript markdownToRichText(`**Hello _world_**`); ``` -------------------------------- ### Handle Notion API Limits with Custom Error Callback Source: https://github.com/tryfabric/martian/blob/master/README.md This example demonstrates how to implement a custom error handling mechanism for Notion API limit issues in Martian. By providing an `onError` callback function within the `notionLimits` option, you can execute custom logic (e.g., logging the error) when an item exceeds Notion's limits. This callback is invoked even if truncation is enabled by default. ```typescript const options = { notionLimits: { // truncate: true, // by default onError: (err: Error) => { // Something has appened! console.error(err); }, }, }; markdownToBlocks('input', options); markdownToRichText('input', options); ``` -------------------------------- ### Enable Emoji Callouts in Martian Source: https://github.com/tryfabric/martian/blob/master/README.md This snippet demonstrates how to enable emoji-style callouts in Martian by setting the `enableEmojiCallouts` option to `true`. When enabled, blockquotes starting with an emoji are converted into callouts, with the emoji determining the background color. Supported emojis include 📘 (blue), 👍 (green), ❗ (red), and 🚧 (yellow). ```typescript const options = { enableEmojiCallouts: true, }; ``` -------------------------------- ### GFM Alerts in Markdown Source: https://github.com/tryfabric/martian/blob/master/README.md Shows how to use GitHub Flavored Markdown (GFM) alerts for important notes and warnings. These are often rendered with distinct visual styles in platforms that support GFM. ```markdown > [!NOTE] > Important information that users should know > [!WARNING] > Critical information that needs attention ``` -------------------------------- ### Emoji-Style Callouts in Markdown Source: https://github.com/tryfabric/martian/blob/master/README.md Illustrates emoji-style callouts, similar to those used in ReadMe's markdown, allowing for visually distinct notes and warnings with custom icons and colors. ```markdown > 📘 **Note:** This is a callout with a blue background > It supports all markdown formatting and can span multiple lines > ❗ **Warning:** This is a callout with a red background > Perfect for important warnings ``` -------------------------------- ### Import Martian Parser Functions (JavaScript/TypeScript) Source: https://github.com/tryfabric/martian/blob/master/README.md Demonstrates how to import the `markdownToBlocks` and `markdownToRichText` functions from the Martian package. These functions are essential for converting Markdown content into Notion API compatible formats. Supports both CommonJS (require) and ES Modules (import) syntax. ```javascript const {markdownToBlocks, markdownToRichText} = require('@tryfabric/martian'); ``` ```typescript import {markdownToBlocks, markdownToRichText} from '@tryfabric/martian'; ``` -------------------------------- ### Convert Markdown to Notion Blocks Source: https://github.com/tryfabric/martian/blob/master/README.md Illustrates the basic usage of the `markdownToBlocks` function. This function takes a Markdown string as input and converts it into an array of Notion API block objects, suitable for creating or updating pages in Notion. ```javascript markdownToBlocks(` hello _world_ *** `); ``` -------------------------------- ### Standard Markdown Blockquote Source: https://github.com/tryfabric/martian/blob/master/README.md Demonstrates a standard markdown blockquote that can span multiple lines. This is a basic text formatting feature supported by many markdown parsers. ```markdown > This is a regular blockquote > It can span multiple lines ``` -------------------------------- ### Handle Notion API Limits with Truncation Source: https://github.com/tryfabric/martian/blob/master/README.md This code configures Martian to manage potential Notion API limit errors (children or character limits) by disabling truncation. When `truncate` is set to `false` within `notionLimits`, Martian will attempt to redistribute content instead of truncating it. This configuration applies to both `markdownToBlocks` and `markdownToRichText` functions. ```typescript const options = { notionLimits: { truncate: false, }, }; markdownToBlocks('input', options); markdownToRichText('input', options); ``` -------------------------------- ### Configure Martian to Ignore Invalid Image URLs Source: https://github.com/tryfabric/martian/blob/master/README.md This snippet shows how to configure Martian to convert images with invalid URLs into text, preventing request rejections. The `strictImageUrls` option can be set to `false` to enable this behavior. By default, invalid image URLs would cause the Notion API to reject the entire request. ```typescript const options = { strictImageUrls: false, }; markdownToBlocks('![](InvalidURL)', { strictImageUrls: false, }); ``` -------------------------------- ### Handle Non-Inline Elements in Rich Text Parsing Source: https://github.com/tryfabric/martian/blob/master/README.md This snippet demonstrates how Martian's `markdownToRichText` function handles non-inline elements. By default, it ignores them and only parses paragraphs. Setting the `nonInline` option to `'throw'` will cause the function to throw an error when a non-inline element is detected, such as a header. ```typescript markdownToRichText('# Header\nAbc', { // nonInline: 'ignore', // Default }); ``` ```typescript markdownToRichText('# Header\nAbc', { nonInline: 'throw', }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.