## SnapdMarkdownParser SnapdMarkdownParser — Snap markdown text parser |

## Functions

SnapdMarkdownParser * | snapd_markdown_parser_new ()
gboolean | snapd_markdown_parser_get_preserve_whitespace ()
void | snapd_markdown_parser_set_preserve_whitespace ()
GPtrArray * | snapd_markdown_parser_parse ()

## Types and Values

| SnapdMarkdownParser
enum | SnapdMarkdownVersion

## Object Hierarchy

        GEnum
        ╰── SnapdMarkdownVersion
        GObject
        ╰── SnapdMarkdownParser

## Includes

    #include <snapd-glib/snapd-glib.h>

## Description

A SnapdMarkdownParser parses text formatted in markdown; for example the text returned by `snapd_snap_get_description()`.

Snap supports the following subset of CommonMark (https://commonmark.org):

- Indented Code Blocks

- Paragraphs

- Blank Lines

- Unordered Lists

- Backslash escapes

- Code spans

In addition text that contains URLs are converted into links.

Use `snapd_markdown_parser_parse()` to convert text into a tree of SnapdMarkdownNode that you can then process to display in your client.

## Functions

### snapd_markdown_parser_new ()

    SnapdMarkdownParser *
    snapd_markdown_parser_new (SnapdMarkdownVersion version);

Create an object to parse markdown text.

#### Parameters

version | version supported by the client. |

#### Returns

a new SnapdMarkdownParser

Since: 1.48

### snapd_markdown_parser_get_preserve_whitespace ()

    gboolean
    snapd_markdown_parser_get_preserve_whitespace
                                   (SnapdMarkdownParser *parser);

Check if paragraph whitespace will be kept intact.

#### Parameters

parser | a SnapdMarkdownParser. |

#### Returns

`TRUE` if paragraph whitespace is preserved.

Since: 1.48

### snapd_markdown_parser_set_preserve_whitespace ()

    void
    snapd_markdown_parser_set_preserve_whitespace
                                   (SnapdMarkdownParser *parser,
                                    gboolean preserve_whitespace);

Consecutive paragraph whitespace (space, tabs, newlines) is automatically combined into a single space character. This renders the paragraphs in the form that HTML uses. If you need the original whitespace that the markdown author wrote then set this to `FALSE`.

#### Parameters

parser | a SnapdMarkdownParser. |
preserve_whitespace | `TRUE` if the parse should keep paragraph whitespace intact. |

Since: 1.48

### snapd_markdown_parser_parse ()

    GPtrArray *
    snapd_markdown_parser_parse (SnapdMarkdownParser *parser,
                                 const gchar *text);

Convert text in snapd markdown format to markup.

#### Parameters

parser | a SnapdMarkdownParser. |
text | text to parse. |

#### Returns

Text split into blocks.

[transfer container][element-type SnapdMarkdownNode]

Since: 1.48

## Types and Values

### SnapdMarkdownParser

    typedef struct _SnapdMarkdownParser SnapdMarkdownParser;

SnapdMarkdownParser is an opaque data structure and can only be accessed using the provided functions.

Since: 1.48

### enum SnapdMarkdownVersion

Version of markdown to parse. Picking a version will ensure only nodes of the expected type are decoded.

#### Members

SNAPD_MARKDOWN_VERSION_0 | the initial version of Snap markdown. |

Since: 1.48