### Markdown Lists Syntax Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Illustrates the syntax for creating unordered and ordered lists in Markdown. It covers using asterisks or hyphens for unordered lists, indentation for nesting, and the format for ordered lists, noting that the starting number is sequential. ```markdown * Lists must be preceded by a blank line (or block element) * Unordered lists start each item with a `*` - `-` works too * Indent a level to make a nested list 1. Ordered lists are supported. 2. Start each item (number-period-space) like `1. ` 42. It doesn't matter what number you use, I will render them sequentially 1. So you might want to start each line with `1.` and let me sort it out ``` -------------------------------- ### Open File with MacDown CLI (Bash) Source: https://github.com/macdownapp/macdown/wiki/Advanced-Usage This example demonstrates how to use the 'macdown' command (defined previously or via Homebrew) to open a specified file. If the file exists, it will be opened in MacDown. If it does not exist, a new document with that name will be created. ```bash $ macdown file.md ``` -------------------------------- ### Open Multiple Files with MacDown CLI (Bash) Source: https://github.com/macdownapp/macdown/wiki/Advanced-Usage This example shows how to open multiple files simultaneously using the 'macdown' command. Provide a space-separated list of file paths as arguments to the 'macdown' command. ```bash $ macdown file.md another_file.md yet_another_file.md ``` -------------------------------- ### Open Application by Name (macOS) Source: https://github.com/macdownapp/macdown/wiki/Advanced-Usage This example uses the macOS 'open' command with the application name to open a file in MacDown. Similar to using the bundle identifier, this method also requires the file to exist prior to execution and will not create a new file if it's absent. ```bash open -a MacDown file.md ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/macdownapp/macdown/wiki/Building-MacDown Resolves errors like 'stdio.h file not found' by ensuring the necessary command-line build tools are installed. This is crucial for building project dependencies. For OS X 10.9 and later, use `xcode-select --install`. Older versions may require manual installation from Xcode preferences or Apple's download site. ```shell xcode-select --install ``` -------------------------------- ### Resolve CocoaPods Yacc Build Errors with Bundler Source: https://github.com/macdownapp/macdown/wiki/Building-MacDown Addresses Xcode errors related to `yacc` failing, often caused by bugs in CocoaPods versions 0.35.x and 0.36.x. It recommends using Bundler to manage CocoaPods versions and execute installations. This ensures compatibility and avoids known issues. ```shell bundle install bundle exec pod install ``` -------------------------------- ### Manage HTML Resources with MPAsset Source: https://context7.com/macdownapp/macdown/llms.txt This Objective-C snippet illustrates how to create and manage CSS and JavaScript resources using the MPAsset class. It shows how to generate HTML snippets for both embedded and linked resource options, and how to handle custom asset types. ```objectivec // Create stylesheet asset NSURL *cssURL = [NSURL fileURLWithPath:@"/path/to/style.css"]; MPStyleSheet *stylesheet = [MPStyleSheet CSSWithURL:cssURL]; // Create JavaScript asset NSURL *jsURL = [NSURL fileURLWithPath:@"/path/to/script.js"]; MPScript *script = [MPScript javaScriptWithURL:jsURL]; // Generate HTML with different options NSString *embeddedCSS = [stylesheet htmlForOption:MPAssetEmbedded]; // Produces: NSString *linkedCSS = [stylesheet htmlForOption:MPAssetFullLink]; // Produces: NSString *embeddedJS = [script htmlForOption:MPAssetEmbedded]; // Produces: NSString *linkedJS = [script htmlForOption:MPAssetFullLink]; // Produces: // Use with custom asset type MPAsset *asset = [MPAsset assetWithURL:cssURL andType:kMPCSSType]; NSString *html = [asset htmlForOption:MPAssetEmbedded]; ``` -------------------------------- ### Graphviz Hashmap Diagram Syntax Source: https://github.com/macdownapp/macdown/blob/master/assets/demo.md Renders a hashmap data structure visualization using Graphviz DOT language. This diagram shows nodes and their connections, suitable for representing key-value pairs or associative arrays. Requires a Graphviz engine. ```dot digraph G { nodesep=.05; rankdir=LR; node [shape=record,width=1.1,height=.1]; node0 [label = " | | | | | | | ", height=2.5]; node [width = 1.5]; node1 [label = "{ n14 | 719 |

}"]; node2 [label = "{ a1 | 805 |

}"]; node3 [label = "{ i9 | 718 |

}"]; node4 [label = "{ e5 | 989 |

}"]; node5 [label = "{ t20 | 959 |

}"] ; node6 [label = "{ o15 | 794 |

}"] ; node7 [label = "{ s19 | 659 |

}"] ; node0:f0 -> node1:n; node0:f1 -> node2:n; node0:f2 -> node3:n; node0:f5 -> node4:n; node0:f6 -> node5:n; node2:p -> node6:n; node4:p -> node7:n; } ``` -------------------------------- ### Graphviz Process Diagram with Clusters Syntax Source: https://github.com/macdownapp/macdown/blob/master/assets/demo.md Illustrates a process diagram with distinct clusters using Graphviz DOT language. This enables grouping related nodes within a subgraph, enhancing clarity for complex workflows. Requires a Graphviz engine. ```dot digraph G { subgraph cluster0 { node [style=filled,color=white]; style=filled; color=lightgrey; a0 -> a1 -> a2 -> a3; label = "process #1"; } subgraph cluster1 { node [style=filled]; b0 -> b1 -> b2 -> b3; label = "process #2"; color=blue } start -> a0; start -> b0; a1 -> b3; b2 -> a3; a3 -> a0; a3 -> end; b3 -> end; start [shape=Mdiamond]; end [shape=Msquare]; } ``` -------------------------------- ### Displaying TeX-like Math Syntax in MacDown Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Demonstrates how MacDown renders TeX-like math syntaxes, both for inline math using single backslashes and parentheses, and for block math using double backslashes and square brackets. It also shows MathML representations. ```tex \( 1 + 1 \) ``` ```mathml 1+1 ``` ```tex \[ A^T_S = B \] ``` ```mathml A S T = B ``` -------------------------------- ### Objective-C MPRendererDelegate Implementation for Custom Rendering Source: https://context7.com/macdownapp/macdown/llms.txt Implements the MPRendererDelegate protocol to customize Markdown rendering behavior. This includes enabling various Hoedown extensions, configuring smarty pants, table of contents, syntax highlighting, Mermaid, Graphviz, MathJax, and code block accessory types. It also demonstrates how to set the renderer's data source and delegate, and how to parse and render Markdown content. ```objectivec @interface MyMarkdownController : NSObject @property (strong) NSString *sourceMarkdown; @property (strong) MPRenderer *renderer; @end @implementation MyMarkdownController - (instancetype)init { self = [super init]; if (self) { _renderer = [[MPRenderer alloc] init]; _renderer.dataSource = self; _renderer.delegate = self; } return self; } // MPRendererDataSource methods - (BOOL)rendererLoading { return NO; } - (NSString *)rendererMarkdown:(MPRenderer *)renderer { return self.sourceMarkdown; } - (NSString *)rendererHTMLTitle:(MPRenderer *)renderer { return [self.sourceMarkdown titleString]; } // MPRendererDelegate methods - (int)rendererExtensions:(MPRenderer *)renderer { return HOEDOWN_EXT_TABLES | HOEDOWN_EXT_FENCED_CODE | HOEDOWN_EXT_AUTOLINK | HOEDOWN_EXT_STRIKETHROUGH | HOEDOWN_EXT_UNDERLINE | HOEDOWN_EXT_HIGHLIGHT | HOEDOWN_EXT_FOOTNOTES | HOEDOWN_EXT_QUOTE; } - (BOOL)rendererHasSmartyPants:(MPRenderer *)renderer { return YES; } - (BOOL)rendererRendersTOC:(MPRenderer *)renderer { return YES; } - (NSString *)rendererStyleName:(MPRenderer *)renderer { return @"GitHub"; } - (BOOL)rendererDetectsFrontMatter:(MPRenderer *)renderer { return YES; } - (BOOL)rendererHasSyntaxHighlighting:(MPRenderer *)renderer { return YES; } - (BOOL)rendererHasMermaid:(MPRenderer *)renderer { return YES; } - (BOOL)rendererHasGraphviz:(MPRenderer *)renderer { return YES; } - (MPCodeBlockAccessoryType)rendererCodeBlockAccesory:(MPRenderer *)renderer { return MPCodeBlockAccessoryLanguageName; } - (BOOL)rendererHasMathJax:(MPRenderer *)renderer { return YES; } - (NSString *)rendererHighlightingThemeName:(MPRenderer *)renderer { return @"tomorrow"; } - (void)renderer:(MPRenderer *)renderer didProduceHTMLOutput:(NSString *)html { NSLog(@"Rendered HTML length: %lu", (unsigned long)html.length); // Handle the rendered output } // Usage - (void)convertMarkdown { self.sourceMarkdown = @"# Example\n\n```python\nprint('Hello')\n```"; [self.renderer parseAndRenderNow]; NSString *html = [self.renderer currentHtml]; } @end ``` -------------------------------- ### Markdown Strong and Emphasize Syntax Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Illustrates the syntax for applying strong (bold) and emphasize (italic) formatting to text in Markdown. Supports both asterisk and underscore delimiters. Keyboard shortcuts Command-B and Command-I are mentioned. ```markdown **Strong** or __Strong__ *Emphasize* or _Emphasize_ ``` -------------------------------- ### Markdown Inline Links and Emails Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Explains how to create clickable inline links for emails and URLs by enclosing them in angle brackets. Also demonstrates linking text to a URL with an optional title attribute. ```markdown [Macdown Website](https://macdown.uranusjr.com "Title") ``` -------------------------------- ### Markdown Headers Syntax Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Shows the different ways to define headers in Markdown, including the underline style with equals signs for Header 1 and hyphens for Header 2, as well as the pound sign syntax for headers 1 through 6. ```markdown Header 1 ======== Header 2 -------- # Header 1 ## Header 2 ### Header 3 #### Header 4 ##### Header 5 ###### Header 6 ``` -------------------------------- ### MPRenderer: Markdown to HTML Conversion with Extensions Source: https://context7.com/macdownapp/macdown/llms.txt The MPRenderer class handles Markdown parsing and HTML rendering. It supports various extensions like tables, fenced code blocks, autolinks, smart punctuation, syntax highlighting, and MathJax. It requires data source methods for content and delegate methods for configuration. Rendering can be immediate or deferred, and HTML can be exported with full styling. ```objectivec // Initialize and configure renderer MPRenderer *renderer = [[MPRenderer alloc] init]; renderer.dataSource = self; // Provides Markdown content renderer.delegate = self; // Configures rendering options // Implement required data source methods - (NSString *)rendererMarkdown:(MPRenderer *)renderer { return @"# Hello World\n\nThis is **bold** text."; } - (NSString *)rendererHTMLTitle:(MPRenderer *)renderer { return @"My Document"; } - (BOOL)rendererLoading { return NO; // Return YES to prevent rendering during loading } // Implement delegate methods for configuration - (int)rendererExtensions:(MPRenderer *)renderer { return HOEDOWN_EXT_TABLES | HOEDOWN_EXT_FENCED_CODE | HOEDOWN_EXT_AUTOLINK; } - (BOOL)rendererHasSmartyPants:(MPRenderer *)renderer { return YES; // Enable smart quotes and dashes } - (BOOL)rendererHasSyntaxHighlighting:(MPRenderer *)renderer { return YES; } - (BOOL)rendererHasMathJax:(MPRenderer *)renderer { return YES; // Enable LaTeX math rendering } // Trigger rendering [renderer parseAndRenderNow]; // Immediate rendering // or [renderer parseAndRenderLater]; // Deferred rendering // Get the rendered HTML NSString *html = [renderer currentHtml]; // Export with full styling NSString *exportHTML = [renderer HTMLForExportWithStyles:YES highlighting:YES]; ``` -------------------------------- ### Mermaid Sequence Diagram Syntax Source: https://github.com/macdownapp/macdown/blob/master/assets/demo.md Creates a sequence diagram using Mermaid syntax, illustrating interactions between participants over time. Useful for visualizing message flows in a system. Requires a Mermaid renderer. ```mermaid sequenceDiagram participant Alice participant Bob Alice->>John: Hello John, how are you? loop Healthcheck John->>John: Fight against hypochondria end Note right of John: Rational thoughts
prevail... John-->>Alice: Great! John->>Bob: How about you? Bob-->>John: Jolly good! ``` -------------------------------- ### Mermaid Gantt Chart Syntax Source: https://github.com/macdownapp/macdown/blob/master/assets/demo.md Defines a Gantt chart using Mermaid syntax to visualize project schedules and task dependencies. It displays tasks over a timeline. Requires a Mermaid renderer. ```mermaid gantt title A Gantt Diagram section Section A task :a1, 2014-01-01, 30d Another task :after a1 , 20d section Another Task in sec :2014-01-12 , 12d anther task : 24d ``` -------------------------------- ### Configure MacDown Application Preferences Source: https://context7.com/macdownapp/macdown/llms.txt This snippet demonstrates how to initialize and configure MPPreferences for customizing Markdown extensions, editor behavior, HTML rendering, fonts, and styling within the MacDown application. It sets various boolean flags for features and specifies font and theme names. ```objectivec // Access shared preferences MPPreferences *prefs = [[MPPreferences alloc] init]; // Configure Markdown extensions prefs.extensionIntraEmphasis = YES; // Allow emphasis inside words prefs.extensionTables = YES; // Enable GitHub-style tables prefs.extensionFencedCode = YES; // Enable fenced code blocks prefs.extensionAutolink = YES; // Auto-link URLs prefs.extensionStrikethough = YES; // Enable ~~strikethrough~~ prefs.extensionUnderline = YES; // Enable _underline_ prefs.extensionSuperscript = YES; // Enable ^superscript^ prefs.extensionHighlight = YES; // Enable ==highlight== prefs.extensionFootnotes = YES; // Enable footnotes prefs.extensionSmartyPants = YES; // Smart quotes and dashes // Configure editor behavior prefs.editorAutoIncrementNumberedLists = YES; prefs.editorCompleteMatchingCharacters = YES; prefs.editorSyncScrolling = YES; prefs.editorShowWordCount = YES; prefs.editorScrollsPastEnd = YES; prefs.editorEnsuresNewlineAtEndOfFile = YES; // Configure HTML rendering prefs.htmlDetectFrontMatter = YES; // Parse YAML front matter prefs.htmlTaskList = YES; // Enable [ ] task lists prefs.htmlHardWrap = NO; // Preserve line breaks prefs.htmlMathJax = YES; // Enable LaTeX math prefs.htmlSyntaxHighlighting = YES; // Enable code highlighting prefs.htmlGraphviz = YES; // Enable Graphviz diagrams prefs.htmlMermaid = YES; // Enable Mermaid diagrams prefs.htmlRendersTOC = YES; // Render table of contents // Set editor font prefs.editorBaseFont = [NSFont fontWithName:@"Menlo" size:14.0]; // Set styling prefs.editorStyleName = @"Mou Fresh Air"; prefs.htmlStyleName = @"GitHub"; prefs.htmlHighlightingThemeName = @"tomorrow"; ``` -------------------------------- ### Creating Code Blocks with Indentation in MacDown Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Explains how to create code blocks by indenting text with at least four spaces or one tab. A preceding blank line is required. Nesting does not affect the literal display of the code. ```python print('This is a code block') print('The block must be preceded by a blank line') print('Then indent at least 4 spaces or 1 tab') print('Nesting does nothing. Your code is displayed Literally') ``` -------------------------------- ### Displaying Tables in Markdown (MacDown) Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Shows the syntax for creating tables in Markdown, including basic tables and tables with aligned cell content using colons within the separator line. ```markdown First Header | Second Header ------------- | ------------- Content Cell | Content Cell Content Cell | Content Cell | Left Aligned | Center Aligned | Right Aligned | |:------------- |:---------------:| -------------:| | col 3 is | some wordy text | $1600 | | col 2 is | centered | $12 | | zebra stripes | are neat | $1 | ``` -------------------------------- ### Objective-C Code Formatting: 80-Column Rule and Brace Style Source: https://github.com/macdownapp/macdown/blob/master/CONTRIBUTING.md This snippet demonstrates Objective-C coding style, focusing on the 80-column rule, brace placement (Allman style), and conditional statement formatting. It also touches on implicit boolean conversion and preferred logical operator placement for multi-line statements. ```c while (this_is_very_long || this_is_also_very_long) { // ... } ``` ```c if (this_is_very_long || this_is_also_very_long) foo++; ``` ```c if (this_is_very_long || this_is_very_very_truly_long) { foo++; bar--; } ``` -------------------------------- ### Markdown Reference Style Links Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Details the syntax for creating reference-style links in Markdown, which separates the link text from the URL for cleaner inline content. It covers arbitrary IDs and using link text as IDs. ```markdown [a link][arbitrary_id] [arbitrary_id]: https://macdown.uranusjr.com "Title" [like this][] [like this]: https://macdown.uranusjr.com ``` -------------------------------- ### Mermaid Flow Chart Syntax Source: https://github.com/macdownapp/macdown/blob/master/assets/demo.md Generates a flow chart diagram using Mermaid syntax. This is a visual representation of a process or workflow. No external dependencies are required beyond the Mermaid rendering engine. ```mermaid graph TD; A-->B; A-->C; B-->D; C-->D; ``` -------------------------------- ### MPRenderer - Markdown to HTML Conversion Source: https://context7.com/macdownapp/macdown/llms.txt The MPRenderer class handles Markdown parsing and HTML rendering, including support for extensions, syntax highlighting, and mathematical notation. ```APIDOC ## MPRenderer - Markdown to HTML Conversion ### Description Handles Markdown parsing and HTML rendering with support for extensions, syntax highlighting, and mathematical notation. ### Method Objective-C class methods and instance methods ### Endpoint N/A (Local class within the application) ### Parameters #### Instance Methods - **init** - Initializes a new MPRenderer instance. - **dataSource** (id) - Required - Sets the object that provides Markdown content. - **delegate** (id) - Required - Sets the object that configures rendering options. - **parseAndRenderNow** - Triggers immediate Markdown to HTML rendering. - **parseAndRenderLater** - Schedules deferred Markdown to HTML rendering. - **currentHtml** - Returns the currently rendered HTML string. - **HTMLForExportWithStyles:highlighting:** (BOOL, BOOL) - Returns HTML for export with specified styling and highlighting options. #### DataSource Methods (Implement in your delegate object) - **rendererMarkdown:** (MPRenderer *) - Returns the Markdown content string. - **rendererHTMLTitle:** (MPRenderer *) - Returns the title for the HTML document. - **rendererLoading** - Returns YES to prevent rendering during loading, NO otherwise. #### Delegate Methods (Implement in your delegate object) - **rendererExtensions:** (MPRenderer *) - Returns a bitmask of enabled Hoedown extensions (e.g., `HOEDOWN_EXT_TABLES`). - **rendererHasSmartyPants:** (MPRenderer *) - Returns YES to enable smart quotes and dashes. - **rendererHasSyntaxHighlighting:** (MPRenderer *) - Returns YES to enable syntax highlighting. - **rendererHasMathJax:** (MPRenderer *) - Returns YES to enable LaTeX math rendering. ### Request Example ```objectivec MPRenderer *renderer = [[MPRenderer alloc] init]; renderer.dataSource = self; renderer.delegate = self; [renderer parseAndRenderNow]; NSString *html = [renderer currentHtml]; ``` ### Response #### Success Response (Rendering Output) - **currentHtml** (NSString) - The rendered HTML string. - **HTMLForExportWithStyles:highlighting:** (NSString) - The HTML string formatted for export. #### Response Example ```html

Hello World

This is bold text.

``` ``` -------------------------------- ### Markdown Image Syntax Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Provides the Markdown syntax for including images, covering both inline images with a direct path/URL and reference-style images where the image URL is defined separately. ```markdown ![Alt Image Text](path/or/url/to.jpg "Optional Title") ![Alt Image Text][image-id] [image-id]: path/or/url/to.jpg "Optional Title" ``` -------------------------------- ### MacDown Utility Functions for File and Path Helpers Source: https://context7.com/macdownapp/macdown/llms.txt Provides global utility functions for managing application data directories, files, and content processing. These functions assist in obtaining paths to application directories, specific files, reading file contents, listing directory entries with filtering, character classification, and extracting data from JSON or JavaScript. ```objectivec // Get paths to application data directories NSString *stylesDir = MPDataDirectory(kMPStylesDirectoryName); NSString *themesDir = MPDataDirectory(kMPThemesDirectoryName); NSString *pluginsDir = MPDataDirectory(kMPPlugInsDirectoryName); // Get specific file paths NSString *stylePath = MPStylePathForName(@"GitHub"); NSString *themePath = MPThemePathForName(@"Mou Fresh Air"); NSURL *highlightURL = MPHighlightingThemeURLForName(@"tomorrow"); // Read file contents NSString *content = MPReadFileOfPath(@"/path/to/file.md"); // List directory entries with filtering NSArray *styleFiles = MPListEntriesForDirectory( kMPStylesDirectoryName, MPFileNameHasExtensionProcessor(kMPStyleFileExtension) ); // Returns: @[@"GitHub", @"Mou Fresh Air", @"Tomorrow", ...] // Character classification BOOL isSpace = MPCharacterIsWhitespace(' '); // YES BOOL isNewline = MPCharacterIsNewline('\n'); // YES BOOL isLineBreak = MPStringIsNewline(@"\n"); // YES // Get data map from JSON NSDictionary *dataMap = MPGetDataMap(@"languages"); // Loads and parses MacDown.app/Contents/Resources/languages.json // Extract JavaScript variable NSString *jsCode = @"var config = {theme: 'dark', size: 14};"; id configObj = MPGetObjectFromJavaScript(jsCode, @"config"); // Returns: @{@"theme": @"dark", @"size": @14} ``` -------------------------------- ### Displaying Inline Code in MacDown Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Demonstrates how to display inline code using single or double backticks. For code containing backticks, double backticks are used to escape them, with specific spacing requirements for nested backticks. ```markdown `Inline code` is indicated by surrounding it with backticks: `` `Inline code` `` If your ``code has `backticks` `` that need to be displayed, you can use double backticks: ```` ``Code with `backticks` `` ```` (mind the spaces preceding the final set of backticks) ``` -------------------------------- ### MacDown Command-Line Interface for Markdown Conversion Source: https://context7.com/macdownapp/macdown/llms.txt The command-line tool for MacDown allows for batch processing of Markdown files into HTML. It supports various options including specifying output files, applying styles, enabling syntax highlighting, MathJax, and multiple Markdown extensions. It can also process input from stdin and output to stdout. ```bash # Basic usage - convert Markdown to HTML macdown-cmd input.md -o output.html # Convert with specific style macdown-cmd document.md -o output.html --style GitHub # Enable syntax highlighting macdown-cmd code.md -o output.html --syntax-highlighting # Enable MathJax for math equations macdown-cmd math.md -o output.html --mathjax # Enable multiple extensions macdown-cmd doc.md -o output.html \ --tables \ --fenced-code \ --autolink \ --footnotes \ --smartypants # Process to stdout for piping cat README.md | macdown-cmd --stdin | less # Batch processing with shell loop for file in *.md; do macdown-cmd "$file" -o "${file%.md}.html" --style GitHub done ``` -------------------------------- ### Enable WebKit Developer Tools for MacDown Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md This command enables the OS X built-in WebKit developer tools for MacDown, allowing users to inspect the HTML of the preview pane. This is a system-level preference setting and requires terminal access. ```bash defaults write com.uranusjr.macdown WebKitDeveloperExtras -bool true ``` -------------------------------- ### Creating Fenced Code Blocks in MacDown Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Illustrates the use of fenced code blocks using triple backticks or tildes. An optional language identifier can be added to the first line for syntax highlighting, which is enabled via application preferences. ```python print('Hello world!') ``` ```python print('Hello world!') ``` -------------------------------- ### Inline Formatting Options in MacDown Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Lists various inline formatting options supported by MacDown, including intra-word emphasis, strikethrough, underline, quote, highlight, superscript, autolinks, and footnotes, along with their respective Markdown syntax and HTML results. ```markdown So A*maz*ing ~~Much wow~~ _So doge_ "Such editor" ==So good== hoge^(fuga) http://t.co [^4] and [^4]: ``` -------------------------------- ### Markdown Line Breaks Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Demonstrates how to create forced line breaks in Markdown by appending two spaces and a newline at the end of a line. This is a standard Markdown feature. ```markdown * This two-line bullet won't break * This two-line bullet will break ``` -------------------------------- ### Open File with 'open' Command (macOS) Source: https://github.com/macdownapp/macdown/wiki/Advanced-Usage This demonstrates using the macOS 'open' command with the bundle identifier to open a file in MacDown. Unlike the direct CLI utility, this method will not create a new file if the specified file does not exist. It requires the file to exist beforehand. ```bash open -b com.uranusjr.macdown file.md ``` -------------------------------- ### Perform Markdown String Operations with NSString+Lookup Source: https://context7.com/macdownapp/macdown/llms.txt This Objective-C snippet showcases various utility methods provided by the NSString+Lookup extension category for Markdown processing. It covers extracting front matter, document titles, finding newline and whitespace positions, pattern matching using regular expressions, and checking file extensions. ```objectivec NSString *markdown = @"---\ntitle: My Doc\n---\n\n# Heading\n\nParagraph text."; // Extract front matter (YAML metadata) NSUInteger contentOffset = 0; id frontMatter = [markdown frontMatter:&contentOffset]; // Returns: @{@"title": @"My Doc"} // contentOffset: 28 (position after front matter) // Extract document title NSString *title = [markdown titleString]; // Returns: @"Heading" (first heading found) // Find newline positions NSString *text = @"Line 1\nLine 2\nLine 3"; NSInteger prevNewline = [text locationOfFirstNewlineBefore:10]; NSUInteger nextNewline = [text locationOfFirstNewlineAfter:5]; // Find first non-whitespace in line NSUInteger firstChar = [text locationOfFirstNonWhitespaceCharacterInLineBefore:10]; // Pattern matching NSArray *matches = [markdown matchesForPattern:@"^#+\s+(.+)$"]; // Returns array of NSTextCheckingResult objects for all headings // File extension check BOOL isMarkdown = [@"document.md" hasExtension:@"md"]; // YES BOOL isHTML = [@"document.md" hasExtension:@"html"]; // NO ``` -------------------------------- ### Render Jekyll Front-Matter with Markdown Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md This feature allows MacDown to display Jekyll front-matter in a table format. The front-matter must be placed at the very beginning of the file and enclosed by '---' delimiters. This is a Markdown-specific feature. ```markdown --- title: "Macdown is my friend" date: 2014-06-06 20:00:00 --- ``` -------------------------------- ### Define MacDown CLI Function (Bash) Source: https://github.com/macdownapp/macdown/wiki/Advanced-Usage This Bash function, 'macdown', allows you to easily launch MacDown from your Terminal. It uses 'mdfind' to locate the application path based on its bundle identifier. Ensure MacDown has been launched at least once for 'mdfind' to recognize it. This function takes file paths as arguments to open them. ```bash macdown() { "$(mdfind kMDItemCFBundleIdentifier=com.uranusjr.macdown | head -n1)/Contents/SharedSupport/bin/macdown" $@ } ``` -------------------------------- ### Markdown Block Quote Syntax Source: https://github.com/macdownapp/macdown/blob/master/MacDown/Resources/help.md Explains the Markdown syntax for creating block quotes using the angle bracket (>) character. It covers basic usage, continuation across lines without empty paragraphs, nesting block quotes, and the compatibility of other Markdown syntaxes within block quotes. ```markdown > Angle brackets `>` are used for block quotes. Technically not every line needs to start with a `>` as long as there are no empty lines between paragraphs. > Looks kinda ugly though. > > Block quotes can be nested. > > > Multiple Levels > > Most markdown syntaxes work inside block quotes. > > * Lists > * [Links][arbitrary_id] > * Etc. ``` -------------------------------- ### MPDocument: Markdown Document Management and File Operations Source: https://context7.com/macdownapp/macdown/llms.txt The MPDocument class manages Markdown documents, including setting content, accessing rendered HTML, controlling preview visibility, and handling file operations like saving and reading. It also provides access to user preferences for document settings. ```objectivec // Create or open a document MPDocument *document = [[MPDocument alloc] init]; // Set Markdown content document.markdown = @"# My Document\n\nContent goes here.\n\n```python\nprint('Hello')\n```"; // Access rendered HTML (read-only) NSString *html = document.html; // Control preview visibility BOOL previewIsVisible = document.previewVisible; BOOL editorIsVisible = document.editorVisible; // Access document preferences MPPreferences *prefs = document.preferences; prefs.extensionTables = YES; prefs.extensionFencedCode = YES; prefs.htmlSyntaxHighlighting = YES; prefs.htmlMathJax = YES; // Save document NSError *error = nil; NSURL *fileURL = [NSURL fileURLWithPath:@"/path/to/document.md"]; [document saveToURL:fileURL ofType:@"net.daringfireball.markdown" forSaveOperation:NSSaveOperation error:&error]; if (error) { NSLog(@"Save failed: %@", error.localizedDescription); } // Read document [document readFromURL:fileURL ofType:@"net.daringfireball.markdown" error:&error]; ``` -------------------------------- ### MPDocument - Document Management Source: https://context7.com/macdownapp/macdown/llms.txt The MPDocument class manages individual Markdown documents, handling file input/output, content editing, and preview visibility. ```APIDOC ## MPDocument - Document Management ### Description Manages individual Markdown documents, including file operations, content editing, and preview settings. ### Method Objective-C class and instance methods ### Endpoint N/A (Local class within the application) ### Parameters #### Initializers - **init** - Initializes a new MPDocument instance. #### Properties - **markdown** (NSString) - Sets or gets the Markdown content of the document. - **html** (NSString, Read-only) - Returns the rendered HTML content of the document. - **previewVisible** (BOOL) - Controls the visibility of the preview pane. - **editorVisible** (BOOL) - Controls the visibility of the editor pane. - **preferences** (MPPreferences *) - Accesses and modifies document-specific preferences. #### File Operations - **saveToURL:ofType:forSaveOperation:error:** (NSURL *, NSString *, NSSaveOperationType, NSError **) - Saves the document to a specified URL. - **readFromURL:ofType:error:** (NSURL *, NSString *, NSError **) - Reads document content from a specified URL. #### MPPreferences (Accessed via `document.preferences`) - **extensionTables** (BOOL) - Enables table extensions. - **extensionFencedCode** (BOOL) - Enables fenced code block extensions. - **htmlSyntaxHighlighting** (BOOL) - Enables HTML syntax highlighting in the output. - **htmlMathJax** (BOOL) - Enables MathJax rendering for LaTeX formulas. ### Request Example ```objectivec MPDocument *document = [[MPDocument alloc] init]; document.markdown = "# My Document\n\nContent here."; NSError *error = nil; NSURL *fileURL = [NSURL fileURLWithPath:@"/path/to/document.md"]; [document saveToURL:fileURL ofType:@"net.daringfireball.markdown" forSaveOperation:NSSaveOperation error:&error]; ``` ### Response #### Success Response (File Operations) - **saveToURL:** - Returns YES on successful save, NO otherwise (error object populated). - **readFromURL:** - Returns YES on successful read, NO otherwise (error object populated). #### Response Example (No direct response body for property access; success indicated by lack of error for file operations.) ```json { "success": true } ``` ``` -------------------------------- ### NSColor+HTML Extension for HTML Color Conversion Source: https://context7.com/macdownapp/macdown/llms.txt An extension for the NSColor class that allows creating NSColor objects from various HTML color formats. It supports named colors, hexadecimal color codes, RGB values, and the 'transparent' keyword. This is useful for applying styles derived from HTML or CSS. ```objectivec // Create colors from HTML color names NSColor *red = [NSColor colorWithHTMLName:@"red"]; NSColor *blue = [NSColor colorWithHTMLName:@"#0000FF"]; NSColor *green = [NSColor colorWithHTMLName:@"rgb(0, 255, 0)"]; NSColor *transparent = [NSColor colorWithHTMLName:@"transparent"]; // Use in editor or preview styling NSDictionary *attributes = @{ NSForegroundColorAttributeName: [NSColor colorWithHTMLName:@"#333333"], NSBackgroundColorAttributeName: [NSColor colorWithHTMLName:@"white"] }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.