Marked - Documentation

Introduction

What is Marked?

Marked is a markdown editor for macOS and Windows. It allows you to write in simple, plain-text Markdown format and instantly see the rendered HTML output in a preview pane. This allows for a distraction-free writing experience while simultaneously providing a real-time view of your formatted document. Marked supports a wide range of Markdown extensions, offering flexibility and customization for your writing needs. It’s designed to be lightweight, fast, and easy to use, prioritizing both simplicity and powerful features.

Why use Marked?

Marked offers several advantages over other markdown editors:

Setting up Marked.

Setting up Marked is straightforward:

  1. Download: Download the appropriate installer for your operating system (macOS or Windows) from the official Marked website.
  2. Installation: Run the installer and follow the on-screen instructions. The process is typically simple and requires minimal user interaction.
  3. Configuration (Optional): While Marked offers a streamlined default experience, you can customize various aspects of its functionality. This includes choosing your preferred Markdown extensions, configuring CSS for custom styling, and adjusting other settings within the application’s preferences. Explore the preferences menu to discover these options.
  4. Start Writing: After installation, you can immediately begin writing and rendering your markdown documents. Simply open a new file, start typing, and see your formatted content in the preview pane.

Basic Usage

Markdown Basics

Marked supports a wide range of Markdown syntax. Here’s a quick overview of the basics:

* **Blockquotes:** Use `>` at the beginning of a line to create blockquotes (e.g., `> This is a blockquote.`).
* **Horizontal Rules:** Use three or more hyphens (`---`), asterisks (`***`), or underscores (`___`) on a line by themselves to create a horizontal rule.


### Rendering Markdown

Marked automatically renders your Markdown as you type. The preview pane displays the HTML output in real-time.  Any changes you make to the Markdown source will immediately update the preview.  The rendering engine used is based on a robust and highly compatible parser. If you encounter unexpected behavior, ensure that your Markdown syntax is correct and check the Marked application's settings to verify that the correct Markdown extensions are enabled.

### Options and Configuration

Marked provides a comprehensive set of options and configurations to customize your experience.  Access these settings through the application's preferences menu.  Key configurable aspects include:

* **Markdown Extensions:** Select which Markdown extensions to enable.  This allows you to control support for features like tables, footnotes, and other extensions.  Refer to the documentation for a complete list of supported extensions and their functionalities.
* **Custom CSS:** Apply custom CSS to style the rendered HTML output. This allows for complete control over the visual appearance of your documents, enabling you to create a unique look and feel.
* **Fonts:** Select the fonts used in both the editor and the preview pane.
* **Export Options:** Configure settings for exporting your documents in different formats (HTML, PDF, etc.), including specifying metadata, page margins, and other relevant export parameters.
* **Themes:** Choose from available themes (or create your own) to change the visual style of the application's interface.
* **General Settings:** Adjust various aspects of the application behavior, including line wrapping, auto-saving, and more.


By exploring the options available in the preferences menu, you can tailor Marked to perfectly fit your workflow and preferences. Remember to consult the application's help documentation for detailed descriptions of each setting and its impact.


## Advanced Usage

### Customizing Renderers

While Marked provides a robust default rendering engine, advanced users can customize the rendering process.  This typically involves creating custom CSS stylesheets to modify the visual appearance of the rendered HTML.  To achieve this:

1. **Create a CSS file:** Create a new CSS file containing your custom styles.  This file should contain CSS rules targeting specific HTML elements generated by Marked's rendering engine.  You might want to inspect the rendered HTML (using your browser's developer tools) to identify the appropriate selectors for your customizations.

2. **Apply the CSS:** In Marked's preferences, navigate to the section allowing you to specify custom CSS.  Provide the path to your newly created CSS file. Marked will then incorporate your custom styles into the rendered output.

3. **Testing:** Thoroughly test your custom CSS to ensure it functions as intended and doesn't introduce any unintended styling conflicts.

Note:  Direct modification of Marked's internal rendering engine is generally not supported and may break functionality.  Custom CSS offers a safe and effective way to customize the visual presentation.


### Extending Marked with Plugins

Marked does not natively support plugins.  Its functionality is primarily defined within the application itself.  Any extensions to its core features would require modification of the application's source code, which is not publicly available.


### Handling Errors and Exceptions

If errors occur during the Markdown rendering process (e.g., due to invalid Markdown syntax), Marked will typically display an error message indicating the nature of the problem. This usually involves highlighting the problematic section of your Markdown source code in the editor.  Refer to the error message for detailed information to help correct the issue.  Common errors include:

* **Syntax Errors:** Incorrect use of Markdown syntax will lead to rendering errors. Carefully review the Markdown specification and ensure your syntax is correct.
* **File Errors:** Issues related to accessing or reading files, particularly those referenced within your Markdown (e.g., images), can result in errors. Check that the referenced files exist and are accessible to Marked.


### Performance Optimization

For optimal performance, consider these points:

* **Document Size:** Extremely large Markdown documents might impact rendering speed.  For very large documents, consider breaking them down into smaller, more manageable files.
* **Complex Markdown:** Highly complex Markdown with numerous embedded elements, nested structures, and extensive use of extensions can increase rendering time.  Strive for a balanced approach, avoiding unnecessary complexity where possible.
* **Custom CSS:** Overly complex or inefficient custom CSS can negatively impact rendering performance.  Optimize your CSS to ensure it's concise and efficiently targets the elements it's intended to style.
* **System Resources:**  Ensure your system has sufficient resources (RAM, CPU) to handle the rendering process.  Closing unnecessary applications might free up resources for Marked.

If you consistently experience performance issues, consider contacting Marked support for assistance in troubleshooting potential problems.


## Markdown Syntax

Marked supports a comprehensive range of Markdown syntax elements.  The following details the supported syntax and how it's rendered.  Note that the exact rendering may vary slightly depending on enabled Markdown extensions.

### Headers

Headers are created using `#` symbols at the beginning of a line. The number of `#` symbols determines the header level (e.g., `#` is level 1, `##` is level 2, and so on, up to level 6).

```markdown
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6

Emphasis

Use * or _ for italics and ** or __ for bold text. You can combine them for bold italics.

*This is italics.*
_This is also italics._
**This is bold.**
__This is also bold.__
***This is bold italics.***
___This is also bold italics.___

Lists

Unordered lists are created using *, -, or + at the beginning of each list item. Ordered lists use numbers followed by a period.

* Item 1
* Item 2
- Item 3
+ Item 4

1. Item 1
2. Item 2
3. Item 3

Links are created using square brackets [] for the link text and parentheses () for the URL.

[Marked Website](https://marked.app)

Images

Images are similar to links, but begin with an exclamation mark !.

![Marked Logo](marked-logo.png)

Code Blocks

Inline code is enclosed in backticks `. Code blocks are enclosed in triple backticks . You can specify the language after the opening triple backticks for syntax highlighting (e.g., ```javascript).

This is inline code: `` `var x = 10;` ``

This is a code block:
```javascript
function myFunction() {
  console.log("Hello, world!");
}

### Blockquotes

Blockquotes are created using `>` at the beginning of each line.

```markdown
> This is a blockquote.
> It can span multiple lines.

Horizontal Rules

Horizontal rules are created using three or more hyphens (---), asterisks (***), or underscores (___) on a line by themselves.

---
***
___

Tables

Tables are created using pipes | to separate columns and hyphens - to define the header row.

| Header 1 | Header 2 |
|---|---|
| Row 1, Cell 1 | Row 1, Cell 2 |
| Row 2, Cell 1 | Row 2, Cell 2 |

HTML

Marked allows embedding raw HTML. Note that this is dependent on the enabled renderer and may not support all HTML elements.

<p>This is a paragraph using raw HTML.</p>

Footnotes

Footnotes are created using [^footnote-ref]. The footnote definition is placed at the end of the document using [^footnote-ref]: footnote text.

This is a sentence with a footnote.[^1]

[^1]: This is the footnote text.

Definitions

Definitions lists are created using terms followed by colons and definitions.

Term 1
: Definition 1

Term 2
: Definition 2

API Reference

Note: This API reference describes the hypothetical API of a Marked-like Markdown renderer. The actual Marked application’s internal API is not publicly documented and may differ significantly. This section provides a conceptual overview of how such an API might be structured.

marked()

The primary function for rendering Markdown. It takes a Markdown string as input and returns the rendered HTML string.

const html = marked('This is *Markdown*!'); // html will contain "<p>This is <em>Markdown</em>!</p>"

Parameters:

Returns:

marked.setOptions()

Sets global options for the Markdown renderer. These options will affect all subsequent calls to marked().

marked.setOptions({
  gfm: true, // Enable GitHub Flavored Markdown
  breaks: true, // Enable line breaks
  smartypants: true // Enable smart quotes
});

Parameters:

marked.Lexer()

Creates a new lexer instance. The lexer is responsible for breaking down the Markdown input into tokens.

const lexer = new marked.Lexer();
const tokens = lexer.lex('This is a #header.');
console.log(tokens); // Array of tokens representing the Markdown structure.

Parameters:

Methods:

marked.Parser()

Creates a new parser instance. The parser takes the tokens generated by the lexer and constructs the HTML output.

const parser = new marked.Parser();
const html = parser.parse(tokens); // tokens from marked.Lexer().lex()
console.log(html); // Rendered HTML

Parameters:

Methods:

marked.Renderer()

Creates a new renderer instance. The renderer is responsible for converting tokens into HTML. This allows for customization of the HTML output.

const renderer = new marked.Renderer();
renderer.heading = function (text, level) {
  return `<h${level} id="${text.toLowerCase().replace(/\s+/g, '-')}">${text}</h${level}>`;
};

const html = marked('This is a #header.', { renderer: renderer }); // Custom header rendering

Parameters:

Methods:

Troubleshooting

Common Issues

This section addresses frequently encountered issues when using Marked.

Debugging Tips

If you encounter more complex issues, these debugging tips can assist you:

Community Support

For assistance beyond this manual, consider these avenues:

Contributing

This section outlines how to contribute to the development of Marked (assuming it’s an open-source project). If Marked is not open-source, this section would be irrelevant and should be omitted.

Contributing Guidelines

We welcome contributions from the community! To contribute to Marked, please follow these guidelines:

  1. Fork the Repository: Create a fork of the main Marked repository on the platform where it’s hosted (e.g., GitHub, GitLab).

  2. Create a Branch: Create a new branch for your contribution. Use descriptive branch names that clearly indicate the purpose of your changes (e.g., fix-bug-123, feature-new-theme).

  3. Make Your Changes: Implement your changes, following the code style guidelines detailed below. Ensure your changes are well-documented and thoroughly tested.

  4. Write Tests: Add or update tests to cover your changes. Thorough testing is crucial to ensuring the quality and stability of the project.

  5. Commit Your Changes: Commit your changes with clear and concise commit messages. Follow a consistent commit message style (e.g., using imperative mood).

  6. Push Your Branch: Push your branch to your forked repository.

  7. Create a Pull Request: Create a pull request to merge your branch into the main repository. Clearly describe the changes you’ve made and address any potential concerns or questions in your pull request description.

  8. Respond to Feedback: Respond to any feedback provided by the maintainers or other contributors. Be prepared to make necessary revisions and address any outstanding concerns.

Code Style

Maintain consistency in code style to improve readability and maintainability. Follow these guidelines:

Testing

Testing is a crucial part of the development process. Contribute to the existing test suite or add new tests to cover your changes. The project should specify its testing framework and practices. Follow these general guidelines: