/* markdown.c generated by valac 0.56.19, the Vala compiler
 * generated from markdown.vala, do not modify */

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>

#define DC_MARKDOWN_ALIGN_LEFT 0
#define DC_MARKDOWN_ALIGN_RIGHT 1
#define DC_MARKDOWN_ALIGN_CENTER 2
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

typedef enum  {
	DC_MARKDOWN_MODE_ENABLED = 0,
	DC_MARKDOWN_MODE_STRIPPED = 1,
	DC_MARKDOWN_MODE_DISABLED = 2
} DcMarkdownMode;

#define DC_TYPE_MARKDOWN_MODE (dc_markdown_mode_get_type ())

#define DC_TYPE_MARKDOWN (dc_markdown_get_type ())
#define DC_MARKDOWN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MARKDOWN, DcMarkdown))
#define DC_MARKDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MARKDOWN, DcMarkdownClass))
#define DC_IS_MARKDOWN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MARKDOWN))
#define DC_IS_MARKDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MARKDOWN))
#define DC_MARKDOWN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MARKDOWN, DcMarkdownClass))

typedef struct _DcMarkdown DcMarkdown;
typedef struct _DcMarkdownClass DcMarkdownClass;
typedef struct _DcMarkdownPrivate DcMarkdownPrivate;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef gchar* (*DcMarkdownMatchReplacement) (GMatchInfo* match, gpointer user_data);
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
typedef struct _Block18Data Block18Data;
typedef struct _Block19Data Block19Data;
typedef struct _Block20Data Block20Data;

#define DC_MARKDOWN_TYPE_TABLE_ROW (dc_markdown_table_row_get_type ())
#define DC_MARKDOWN_TABLE_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_MARKDOWN_TYPE_TABLE_ROW, DcMarkdownTableRow))
#define DC_MARKDOWN_TABLE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_MARKDOWN_TYPE_TABLE_ROW, DcMarkdownTableRowClass))
#define DC_MARKDOWN_IS_TABLE_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_MARKDOWN_TYPE_TABLE_ROW))
#define DC_MARKDOWN_IS_TABLE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_MARKDOWN_TYPE_TABLE_ROW))
#define DC_MARKDOWN_TABLE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_MARKDOWN_TYPE_TABLE_ROW, DcMarkdownTableRowClass))

typedef struct _DcMarkdownTableRow DcMarkdownTableRow;
typedef struct _DcMarkdownTableRowClass DcMarkdownTableRowClass;
typedef struct _DcMarkdownTableRowPrivate DcMarkdownTableRowPrivate;
#define _dc_markdown_table_row_unref0(var) ((var == NULL) ? NULL : (var = (dc_markdown_table_row_unref (var), NULL)))
typedef struct _DcMarkdownParamSpecTableRow DcMarkdownParamSpecTableRow;
typedef struct _DcParamSpecMarkdown DcParamSpecMarkdown;

struct _DcMarkdown {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DcMarkdownPrivate * priv;
};

struct _DcMarkdownClass {
	GTypeClass parent_class;
	void (*finalize) (DcMarkdown *self);
};

struct _Block18Data {
	int _ref_count_;
	GPtrArray* segments;
};

struct _Block19Data {
	int _ref_count_;
	GPtrArray* segments;
};

struct _Block20Data {
	int _ref_count_;
	GPtrArray* segments;
	gint group;
};

struct _DcMarkdownTableRow {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DcMarkdownTableRowPrivate * priv;
	gchar** cells;
	gint cells_length1;
	gint _cells_size_;
	gboolean separator;
};

struct _DcMarkdownTableRowClass {
	GTypeClass parent_class;
	void (*finalize) (DcMarkdownTableRow *self);
};

struct _DcMarkdownParamSpecTableRow {
	GParamSpec parent_instance;
};

struct _DcParamSpecMarkdown {
	GParamSpec parent_instance;
};

static gpointer dc_markdown_parent_class = NULL;
VALA_EXTERN DcMarkdownMode dc_markdown_mode;
DcMarkdownMode dc_markdown_mode = DC_MARKDOWN_MODE_ENABLED;
static GRegex* dc_markdown_cb_re;
static GRegex* dc_markdown_cb_re = NULL;
static GRegex* dc_markdown_ic_re;
static GRegex* dc_markdown_ic_re = NULL;
static GRegex* dc_markdown_bold_re;
static GRegex* dc_markdown_bold_re = NULL;
static GRegex* dc_markdown_italic_re;
static GRegex* dc_markdown_italic_re = NULL;
static GRegex* dc_markdown_italic2_re;
static GRegex* dc_markdown_italic2_re = NULL;
static GRegex* dc_markdown_strike_re;
static GRegex* dc_markdown_strike_re = NULL;
static GRegex* dc_markdown_heading_re;
static GRegex* dc_markdown_heading_re = NULL;
static GRegex* dc_markdown_link_re;
static GRegex* dc_markdown_link_re = NULL;
static GRegex* dc_markdown_strip_heading_re;
static GRegex* dc_markdown_strip_heading_re = NULL;
static GRegex* dc_markdown_strip_link_re;
static GRegex* dc_markdown_strip_link_re = NULL;
static GRegex* dc_markdown_strip_ref_link_re;
static GRegex* dc_markdown_strip_ref_link_re = NULL;
static GRegex* dc_markdown_strip_auto_link_re;
static GRegex* dc_markdown_strip_auto_link_re = NULL;
static GRegex* dc_markdown_strip_quote_re;
static GRegex* dc_markdown_strip_quote_re = NULL;
static GRegex* dc_markdown_strip_hr_re;
static GRegex* dc_markdown_strip_hr_re = NULL;
static GRegex* dc_markdown_strip_list_re;
static GRegex* dc_markdown_strip_list_re = NULL;
static GRegex* dc_markdown_strip_escape_re;
static GRegex* dc_markdown_strip_escape_re = NULL;
static gpointer dc_markdown_table_row_parent_class = NULL;

VALA_EXTERN GType dc_markdown_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer dc_markdown_ref (gpointer instance);
VALA_EXTERN void dc_markdown_unref (gpointer instance);
VALA_EXTERN GParamSpec* dc_param_spec_markdown (const gchar* name,
                                    const gchar* nick,
                                    const gchar* blurb,
                                    GType object_type,
                                    GParamFlags flags);
VALA_EXTERN void dc_value_set_markdown (GValue* value,
                            gpointer v_object);
VALA_EXTERN void dc_value_take_markdown (GValue* value,
                             gpointer v_object);
VALA_EXTERN gpointer dc_value_get_markdown (const GValue* value);
VALA_EXTERN GType dc_markdown_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMarkdown, dc_markdown_unref)
static void dc_markdown_ensure_regexes (GError** error);
static gchar* dc_markdown_replace_matches (GRegex* regex,
                                    const gchar* input,
                                    DcMarkdownMatchReplacement replacement,
                                    gpointer replacement_target,
                                    GError** error);
VALA_EXTERN gchar* dc_markdown_format (const gchar* input);
VALA_EXTERN gchar* dc_markdown_format_with_mode (const gchar* input,
                                     DcMarkdownMode render_mode);
VALA_EXTERN gchar* dc_markdown_strip (const gchar* input);
static gchar* dc_markdown_linkify (const gchar* escaped);
static gchar* dc_markdown_format_markdown (const gchar* escaped,
                                    GError** error);
static gchar* dc_markdown_strip_markdown (const gchar* input,
                                   GError** error);
VALA_EXTERN gchar* dc_markdown_preview (const gchar* input,
                            gint max_lines,
                            gint max_chars);
static gchar* dc_markdown_clamp_chars (const gchar* input,
                                gint max_chars);
VALA_EXTERN gchar* dc_markdown_single_line_preview (const gchar* input,
                                        gint max_chars);
static gchar* dc_markdown_collapse_lines (const gchar* input);
static void _g_free0_ (gpointer var);
static gchar* dc_markdown_extract_code_block (GRegex* re,
                                       const gchar* input,
                                       GPtrArray* segments,
                                       GError** error);
static gchar* dc_markdown_extract_code (GRegex* re,
                                 const gchar* input,
                                 GPtrArray* segments,
                                 GError** error);
static gchar* dc_markdown_format_task_checkboxes (const gchar* input);
static gchar* __lambda12_ (GMatchInfo* mi);
static gchar* ___lambda12__dc_markdown_match_replacement (GMatchInfo* match,
                                                   gpointer self);
static gchar* dc_markdown_format_tables (const gchar* input,
                                  GPtrArray* segments);
static gchar* dc_markdown_extract_plain_code (GRegex* re,
                                       const gchar* input,
                                       GPtrArray* segments,
                                       gint group,
                                       GError** error);
static gchar* dc_markdown_strip_task_checkboxes (const gchar* input);
VALA_EXTERN gboolean dc_markdown_parse_task_checkbox (const gchar* line,
                                          gboolean* checked,
                                          gint* marker_start,
                                          gint* content_start);
static gboolean dc_markdown_is_ascii_space (gchar c);
static Block18Data* block18_data_ref (Block18Data* _data18_);
static void block18_data_unref (void * _userdata_);
static gchar* __lambda11_ (Block18Data* _data18_,
                    GMatchInfo* mi);
static gchar* ___lambda11__dc_markdown_match_replacement (GMatchInfo* match,
                                                   gpointer self);
static Block19Data* block19_data_ref (Block19Data* _data19_);
static void block19_data_unref (void * _userdata_);
static gchar* __lambda10_ (Block19Data* _data19_,
                    GMatchInfo* mi);
static gchar* dc_markdown_unescape_markup (const gchar* escaped);
VALA_EXTERN gchar* dc_syntax_highlight_highlight (const gchar* code);
static gchar* ___lambda10__dc_markdown_match_replacement (GMatchInfo* match,
                                                   gpointer self);
static Block20Data* block20_data_ref (Block20Data* _data20_);
static void block20_data_unref (void * _userdata_);
static gchar* __lambda8_ (Block20Data* _data20_,
                   GMatchInfo* mi);
static gchar* ___lambda8__dc_markdown_match_replacement (GMatchInfo* match,
                                                  gpointer self);
static gchar* dc_markdown_try_format_table_at (gchar** lines,
                                        gint lines_length1,
                                        gint start,
                                        gint* end,
                                        GPtrArray* segments);
static gchar** dc_markdown_parse_table_row (const gchar* line,
                                     gint* result_length1);
static gboolean dc_markdown_is_separator_row (gchar** cells,
                                       gint cells_length1);
static gint dc_markdown_separator_align (const gchar* cell);
static gpointer dc_markdown_table_row_ref (gpointer instance);
static void dc_markdown_table_row_unref (gpointer instance);
static GParamSpec* dc_markdown_param_spec_table_row (const gchar* name,
                                              const gchar* nick,
                                              const gchar* blurb,
                                              GType object_type,
                                              GParamFlags flags) G_GNUC_UNUSED ;
static void dc_markdown_value_set_table_row (GValue* value,
                                      gpointer v_object) G_GNUC_UNUSED ;
static void dc_markdown_value_take_table_row (GValue* value,
                                       gpointer v_object) G_GNUC_UNUSED ;
static gpointer dc_markdown_value_get_table_row (const GValue* value) G_GNUC_UNUSED ;
static GType dc_markdown_table_row_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMarkdownTableRow, dc_markdown_table_row_unref)
static void _dc_markdown_table_row_unref0_ (gpointer var);
static DcMarkdownTableRow* dc_markdown_table_row_new (gchar** cells,
                                               gint cells_length1,
                                               gboolean separator);
static DcMarkdownTableRow* dc_markdown_table_row_construct (GType object_type,
                                                     gchar** cells,
                                                     gint cells_length1,
                                                     gboolean separator);
static void dc_markdown_update_widths (gint* widths,
                                gint widths_length1,
                                gchar** cells,
                                gint cells_length1,
                                GPtrArray* segments);
static gchar* dc_markdown_render_table (GPtrArray* rows,
                                 gint* widths,
                                 gint widths_length1,
                                 gint* aligns,
                                 gint aligns_length1,
                                 GPtrArray* segments);
static gint dc_markdown_visible_width (const gchar* markup,
                                GPtrArray* segments);
static void dc_markdown_append_separator (GString* sb,
                                   gint* widths,
                                   gint widths_length1);
static void dc_markdown_append_aligned_cell (GString* sb,
                                      const gchar* cell,
                                      gint width,
                                      gint align,
                                      GPtrArray* segments);
static void dc_markdown_append_repeated (GString* sb,
                                  gchar c,
                                  gint count);
static gint* dc_markdown_read_segment_index (const gchar* text,
                                      gint* index);
static gint* _int_dup (gint* self);
static gchar* ___lambda9_ (GMatchInfo* mi);
static gchar* ____lambda9__dc_markdown_match_replacement (GMatchInfo* match,
                                                   gpointer self);
VALA_EXTERN DcMarkdown* dc_markdown_new (void);
VALA_EXTERN DcMarkdown* dc_markdown_construct (GType object_type);
static gchar** _vala_array_dup6 (gchar** self,
                          gssize length);
static void dc_markdown_table_row_finalize (DcMarkdownTableRow * obj);
static GType dc_markdown_table_row_get_type_once (void);
static void dc_markdown_finalize (DcMarkdown * obj);
static GType dc_markdown_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
dc_markdown_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{DC_MARKDOWN_MODE_ENABLED, "DC_MARKDOWN_MODE_ENABLED", "enabled"}, {DC_MARKDOWN_MODE_STRIPPED, "DC_MARKDOWN_MODE_STRIPPED", "stripped"}, {DC_MARKDOWN_MODE_DISABLED, "DC_MARKDOWN_MODE_DISABLED", "disabled"}, {0, NULL, NULL}};
	GType dc_markdown_mode_type_id;
	dc_markdown_mode_type_id = g_enum_register_static ("DcMarkdownMode", values);
	return dc_markdown_mode_type_id;
}

GType
dc_markdown_mode_get_type (void)
{
	static volatile gsize dc_markdown_mode_type_id__once = 0;
	if (g_once_init_enter (&dc_markdown_mode_type_id__once)) {
		GType dc_markdown_mode_type_id;
		dc_markdown_mode_type_id = dc_markdown_mode_get_type_once ();
		g_once_init_leave (&dc_markdown_mode_type_id__once, dc_markdown_mode_type_id);
	}
	return dc_markdown_mode_type_id__once;
}

static void
dc_markdown_ensure_regexes (GError** error)
{
	GRegex* _tmp0_;
	GRegex* _tmp1_ = NULL;
	GRegex* _tmp2_;
	GRegex* _tmp3_;
	GRegex* _tmp4_ = NULL;
	GRegex* _tmp5_;
	GRegex* _tmp6_;
	GRegex* _tmp7_ = NULL;
	GRegex* _tmp8_;
	GRegex* _tmp9_;
	GRegex* _tmp10_ = NULL;
	GRegex* _tmp11_;
	GRegex* _tmp12_;
	GRegex* _tmp13_ = NULL;
	GRegex* _tmp14_;
	GRegex* _tmp15_;
	GRegex* _tmp16_ = NULL;
	GRegex* _tmp17_;
	GRegex* _tmp18_;
	GRegex* _tmp19_ = NULL;
	GRegex* _tmp20_;
	GRegex* _tmp21_;
	GRegex* _tmp22_ = NULL;
	GRegex* _tmp23_;
	GRegex* _tmp24_;
	GRegex* _tmp25_ = NULL;
	GRegex* _tmp26_;
	GRegex* _tmp27_;
	GRegex* _tmp28_ = NULL;
	GRegex* _tmp29_;
	GRegex* _tmp30_;
	GRegex* _tmp31_ = NULL;
	GRegex* _tmp32_;
	GRegex* _tmp33_;
	GRegex* _tmp34_ = NULL;
	GRegex* _tmp35_;
	GRegex* _tmp36_;
	GRegex* _tmp37_ = NULL;
	GRegex* _tmp38_;
	GRegex* _tmp39_;
	GRegex* _tmp40_ = NULL;
	GRegex* _tmp41_;
	GRegex* _tmp42_;
	GRegex* _tmp43_ = NULL;
	GRegex* _tmp44_;
	GRegex* _tmp45_;
	GRegex* _tmp46_ = NULL;
	GRegex* _tmp47_;
	GRegex* _tmp48_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = dc_markdown_cb_re;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp2_ = g_regex_new ("(```|~~~)(?:[a-zA-Z]*)\\n?([\\s\\S]*?)\\1", 0, 0, &_inner_error0_);
	_tmp1_ = _tmp2_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp3_ = _tmp1_;
	_tmp1_ = NULL;
	_g_regex_unref0 (dc_markdown_cb_re);
	dc_markdown_cb_re = _tmp3_;
	_tmp5_ = g_regex_new ("`([^`\\n]+)`", 0, 0, &_inner_error0_);
	_tmp4_ = _tmp5_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp6_ = _tmp4_;
	_tmp4_ = NULL;
	_g_regex_unref0 (dc_markdown_ic_re);
	dc_markdown_ic_re = _tmp6_;
	_tmp8_ = g_regex_new ("(\\*\\*|__)(.+?)\\1", 0, 0, &_inner_error0_);
	_tmp7_ = _tmp8_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp9_ = _tmp7_;
	_tmp7_ = NULL;
	_g_regex_unref0 (dc_markdown_bold_re);
	dc_markdown_bold_re = _tmp9_;
	_tmp11_ = g_regex_new ("\\*([^\\*\\n]+)\\*", 0, 0, &_inner_error0_);
	_tmp10_ = _tmp11_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp12_ = _tmp10_;
	_tmp10_ = NULL;
	_g_regex_unref0 (dc_markdown_italic_re);
	dc_markdown_italic_re = _tmp12_;
	_tmp14_ = g_regex_new ("(?<!\\w)_([^_\\n]+)_(?!\\w)", 0, 0, &_inner_error0_);
	_tmp13_ = _tmp14_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp15_ = _tmp13_;
	_tmp13_ = NULL;
	_g_regex_unref0 (dc_markdown_italic2_re);
	dc_markdown_italic2_re = _tmp15_;
	_tmp17_ = g_regex_new ("~~(.+?)~~", 0, 0, &_inner_error0_);
	_tmp16_ = _tmp17_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp18_ = _tmp16_;
	_tmp16_ = NULL;
	_g_regex_unref0 (dc_markdown_strike_re);
	dc_markdown_strike_re = _tmp18_;
	_tmp20_ = g_regex_new ("^(#{1,3}) +(.+)$", G_REGEX_MULTILINE, 0, &_inner_error0_);
	_tmp19_ = _tmp20_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp21_ = _tmp19_;
	_tmp19_ = NULL;
	_g_regex_unref0 (dc_markdown_heading_re);
	dc_markdown_heading_re = _tmp21_;
	_tmp23_ = g_regex_new ("(https?://[^\\s<>\"]+)", 0, 0, &_inner_error0_);
	_tmp22_ = _tmp23_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp24_ = _tmp22_;
	_tmp22_ = NULL;
	_g_regex_unref0 (dc_markdown_link_re);
	dc_markdown_link_re = _tmp24_;
	_tmp26_ = g_regex_new ("^(#{1,6})[ \\t]+(.+)$", G_REGEX_MULTILINE, 0, &_inner_error0_);
	_tmp25_ = _tmp26_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp27_ = _tmp25_;
	_tmp25_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_heading_re);
	dc_markdown_strip_heading_re = _tmp27_;
	_tmp29_ = g_regex_new ("!?\\[([^\\]\\n]*)\\]\\([^\\)\\n]*\\)", 0, 0, &_inner_error0_);
	_tmp28_ = _tmp29_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp30_ = _tmp28_;
	_tmp28_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_link_re);
	dc_markdown_strip_link_re = _tmp30_;
	_tmp32_ = g_regex_new ("\\[([^\\]\\n]*)\\]\\[[^\\]\\n]*\\]", 0, 0, &_inner_error0_);
	_tmp31_ = _tmp32_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp33_ = _tmp31_;
	_tmp31_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_ref_link_re);
	dc_markdown_strip_ref_link_re = _tmp33_;
	_tmp35_ = g_regex_new ("<((?:https?|mailto):[^>\\s]+)>", 0, 0, &_inner_error0_);
	_tmp34_ = _tmp35_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp36_ = _tmp34_;
	_tmp34_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_auto_link_re);
	dc_markdown_strip_auto_link_re = _tmp36_;
	_tmp38_ = g_regex_new ("^\\s*>\\s?", G_REGEX_MULTILINE, 0, &_inner_error0_);
	_tmp37_ = _tmp38_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp39_ = _tmp37_;
	_tmp37_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_quote_re);
	dc_markdown_strip_quote_re = _tmp39_;
	_tmp41_ = g_regex_new ("^\\s{0,3}(?:[-*_]\\s*){3,}$", G_REGEX_MULTILINE, 0, &_inner_error0_);
	_tmp40_ = _tmp41_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp37_);
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp37_);
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp42_ = _tmp40_;
	_tmp40_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_hr_re);
	dc_markdown_strip_hr_re = _tmp42_;
	_tmp44_ = g_regex_new ("^\\s{0,3}(?:[-+*]|\\d+[.)])\\s+", G_REGEX_MULTILINE, 0, &_inner_error0_);
	_tmp43_ = _tmp44_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp40_);
			_g_regex_unref0 (_tmp37_);
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp40_);
			_g_regex_unref0 (_tmp37_);
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp45_ = _tmp43_;
	_tmp43_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_list_re);
	dc_markdown_strip_list_re = _tmp45_;
	_tmp47_ = g_regex_new ("\\\\([\\\\`*_{}\\[\\]()#+\\-.!>])", 0, 0, &_inner_error0_);
	_tmp46_ = _tmp47_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_regex_unref0 (_tmp43_);
			_g_regex_unref0 (_tmp40_);
			_g_regex_unref0 (_tmp37_);
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			return;
		} else {
			_g_regex_unref0 (_tmp43_);
			_g_regex_unref0 (_tmp40_);
			_g_regex_unref0 (_tmp37_);
			_g_regex_unref0 (_tmp34_);
			_g_regex_unref0 (_tmp31_);
			_g_regex_unref0 (_tmp28_);
			_g_regex_unref0 (_tmp25_);
			_g_regex_unref0 (_tmp22_);
			_g_regex_unref0 (_tmp19_);
			_g_regex_unref0 (_tmp16_);
			_g_regex_unref0 (_tmp13_);
			_g_regex_unref0 (_tmp10_);
			_g_regex_unref0 (_tmp7_);
			_g_regex_unref0 (_tmp4_);
			_g_regex_unref0 (_tmp1_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp48_ = _tmp46_;
	_tmp46_ = NULL;
	_g_regex_unref0 (dc_markdown_strip_escape_re);
	dc_markdown_strip_escape_re = _tmp48_;
	_g_regex_unref0 (_tmp46_);
	_g_regex_unref0 (_tmp43_);
	_g_regex_unref0 (_tmp40_);
	_g_regex_unref0 (_tmp37_);
	_g_regex_unref0 (_tmp34_);
	_g_regex_unref0 (_tmp31_);
	_g_regex_unref0 (_tmp28_);
	_g_regex_unref0 (_tmp25_);
	_g_regex_unref0 (_tmp22_);
	_g_regex_unref0 (_tmp19_);
	_g_regex_unref0 (_tmp16_);
	_g_regex_unref0 (_tmp13_);
	_g_regex_unref0 (_tmp10_);
	_g_regex_unref0 (_tmp7_);
	_g_regex_unref0 (_tmp4_);
	_g_regex_unref0 (_tmp1_);
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
dc_markdown_replace_matches (GRegex* regex,
                             const gchar* input,
                             DcMarkdownMatchReplacement replacement,
                             gpointer replacement_target,
                             GError** error)
{
	GString* _result_ = NULL;
	GString* _tmp0_;
	gint offset = 0;
	GMatchInfo* match = NULL;
	GString* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GString* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (regex != NULL, NULL);
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = g_string_new ("");
	_result_ = _tmp0_;
	offset = 0;
	while (TRUE) {
		gboolean _tmp1_ = FALSE;
		GMatchInfo* _tmp2_ = NULL;
		gboolean _tmp3_;
		gint start = 0;
		gint end = 0;
		gboolean _tmp4_ = FALSE;
		GMatchInfo* _tmp5_;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		gboolean _tmp8_;
		GString* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		GString* _tmp13_;
		GMatchInfo* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp3_ = g_regex_match_full (regex, input, (gssize) -1, offset, 0, &_tmp2_, &_inner_error0_);
		_g_match_info_unref0 (match);
		match = _tmp2_;
		_tmp1_ = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				g_propagate_error (error, _inner_error0_);
				_g_match_info_unref0 (match);
				_g_string_free0 (_result_);
				return NULL;
			} else {
				_g_match_info_unref0 (match);
				_g_string_free0 (_result_);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
		}
		if (!_tmp1_) {
			break;
		}
		_tmp5_ = match;
		_tmp8_ = g_match_info_fetch_pos (_tmp5_, 0, &_tmp6_, &_tmp7_);
		start = _tmp6_;
		end = _tmp7_;
		if (!_tmp8_) {
			_tmp4_ = TRUE;
		} else {
			_tmp4_ = end <= offset;
		}
		if (_tmp4_) {
			GError* _tmp9_;
			_tmp9_ = g_error_new_literal (G_REGEX_ERROR, G_REGEX_ERROR_MATCH, "Invalid replacement match");
			_inner_error0_ = _tmp9_;
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				g_propagate_error (error, _inner_error0_);
				_g_match_info_unref0 (match);
				_g_string_free0 (_result_);
				return NULL;
			} else {
				_g_match_info_unref0 (match);
				_g_string_free0 (_result_);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
		}
		_tmp10_ = _result_;
		_tmp11_ = string_substring (input, (glong) offset, (glong) (start - offset));
		_tmp12_ = _tmp11_;
		g_string_append (_tmp10_, _tmp12_);
		_g_free0 (_tmp12_);
		_tmp13_ = _result_;
		_tmp14_ = match;
		_tmp15_ = replacement (_tmp14_, replacement_target);
		_tmp16_ = _tmp15_;
		g_string_append (_tmp13_, _tmp16_);
		_g_free0 (_tmp16_);
		offset = end;
	}
	_tmp17_ = _result_;
	_tmp18_ = string_substring (input, (glong) offset, (glong) -1);
	_tmp19_ = _tmp18_;
	g_string_append (_tmp17_, _tmp19_);
	_g_free0 (_tmp19_);
	_tmp20_ = _result_;
	_tmp21_ = _tmp20_->str;
	_tmp22_ = g_strdup (_tmp21_);
	result = _tmp22_;
	_g_match_info_unref0 (match);
	_g_string_free0 (_result_);
	return result;
}

/**
         * Format message text according to the selected markdown mode.
         * URLs are always linkified.
         */
gchar*
dc_markdown_format (const gchar* input)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = dc_markdown_format_with_mode (input, dc_markdown_mode);
	result = _tmp0_;
	return result;
}

/**
         * Format text using an explicit mode without changing the application
         * setting. This is useful for previews whose rendering can be toggled
         * locally, such as the full-message reader.
         */
gchar*
dc_markdown_format_with_mode (const gchar* input,
                              DcMarkdownMode render_mode)
{
	gchar* _tmp0_ = NULL;
	gchar* text = NULL;
	gchar* _tmp3_;
	gchar* escaped = NULL;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	if (render_mode == DC_MARKDOWN_MODE_STRIPPED) {
		gchar* _tmp1_;
		_tmp1_ = dc_markdown_strip (input);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp1_;
	} else {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (input);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp2_;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	text = _tmp3_;
	_tmp4_ = text;
	_tmp5_ = g_markup_escape_text (_tmp4_, (gssize) -1);
	escaped = _tmp5_;
	if (render_mode != DC_MARKDOWN_MODE_ENABLED) {
		const gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp6_ = escaped;
		_tmp7_ = dc_markdown_linkify (_tmp6_);
		result = _tmp7_;
		_g_free0 (escaped);
		_g_free0 (text);
		_g_free0 (_tmp0_);
		return result;
	}
	{
		gchar* _tmp8_ = NULL;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp9_ = escaped;
		_tmp10_ = dc_markdown_format_markdown (_tmp9_, &_inner_error0_);
		_tmp8_ = _tmp10_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_free0 (escaped);
			_g_free0 (text);
			_g_free0 (_tmp0_);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp11_ = _tmp8_;
		_tmp8_ = NULL;
		result = _tmp11_;
		_g_free0 (_tmp8_);
		_g_free0 (escaped);
		_g_free0 (text);
		_g_free0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		const gchar* _tmp12_;
		gchar* _tmp13_;
		g_clear_error (&_inner_error0_);
		_tmp12_ = escaped;
		_tmp13_ = dc_markdown_linkify (_tmp12_);
		result = _tmp13_;
		_g_free0 (escaped);
		_g_free0 (text);
		_g_free0 (_tmp0_);
		return result;
	}
	__finally0:
	_g_free0 (escaped);
	_g_free0 (text);
	_g_free0 (_tmp0_);
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

/**
         * Convert markdown to plain text for short previews.
         */
static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

gchar*
dc_markdown_strip (const gchar* input)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	{
		gchar* _tmp0_ = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = dc_markdown_strip_markdown (input, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		result = _tmp2_;
		_g_free0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		gchar* _tmp3_;
		g_clear_error (&_inner_error0_);
		_tmp3_ = string_strip (input);
		result = _tmp3_;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

/**
         * Convert markdown to preview text, stripping markdown before line
         * clamping so line-oriented syntax such as task checkboxes survives.
         */
gchar*
dc_markdown_preview (const gchar* input,
                     gint max_lines,
                     gint max_chars)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = dc_markdown_strip (input);
	_result_ = _tmp0_;
	if (max_lines > 0) {
		gchar** lines = NULL;
		const gchar* _tmp1_;
		gchar** _tmp2_;
		gchar** _tmp3_;
		gint lines_length1;
		gint _lines_size_;
		gint _tmp4_ = 0;
		gchar** _tmp5_;
		gint _tmp5__length1;
		gint n = 0;
		GString* sb = NULL;
		GString* _tmp7_;
		gchar** _tmp14_;
		gint _tmp14__length1;
		GString* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		_tmp1_ = _result_;
		_tmp3_ = _tmp2_ = g_strsplit (_tmp1_, "\n", 0);
		lines = _tmp3_;
		lines_length1 = _vala_array_length (_tmp2_);
		_lines_size_ = lines_length1;
		_tmp5_ = lines;
		_tmp5__length1 = lines_length1;
		if (_tmp5__length1 < max_lines) {
			gchar** _tmp6_;
			gint _tmp6__length1;
			_tmp6_ = lines;
			_tmp6__length1 = lines_length1;
			_tmp4_ = _tmp6__length1;
		} else {
			_tmp4_ = max_lines;
		}
		n = _tmp4_;
		_tmp7_ = g_string_new ("");
		sb = _tmp7_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp8_ = FALSE;
				_tmp8_ = TRUE;
				while (TRUE) {
					GString* _tmp11_;
					gchar** _tmp12_;
					gint _tmp12__length1;
					const gchar* _tmp13_;
					if (!_tmp8_) {
						gint _tmp9_;
						_tmp9_ = i;
						i = _tmp9_ + 1;
					}
					_tmp8_ = FALSE;
					if (!(i < n)) {
						break;
					}
					if (i > 0) {
						GString* _tmp10_;
						_tmp10_ = sb;
						g_string_append_c (_tmp10_, '\n');
					}
					_tmp11_ = sb;
					_tmp12_ = lines;
					_tmp12__length1 = lines_length1;
					_tmp13_ = _tmp12_[i];
					g_string_append (_tmp11_, _tmp13_);
				}
			}
		}
		_tmp14_ = lines;
		_tmp14__length1 = lines_length1;
		if (_tmp14__length1 > max_lines) {
			GString* _tmp15_;
			_tmp15_ = sb;
			g_string_append (_tmp15_, "…");
		}
		_tmp16_ = sb;
		_tmp17_ = _tmp16_->str;
		_tmp18_ = g_strdup (_tmp17_);
		_g_free0 (_result_);
		_result_ = _tmp18_;
		_g_string_free0 (sb);
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp19_ = _result_;
	_tmp20_ = dc_markdown_clamp_chars (_tmp19_, max_chars);
	result = _tmp20_;
	_g_free0 (_result_);
	return result;
}

/**
         * Convert markdown to a single-line preview, stripping markdown before
         * collapsing newlines so task checkboxes still start at line scope.
         */
gchar*
dc_markdown_single_line_preview (const gchar* input,
                                 gint max_chars)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = dc_markdown_strip (input);
	_tmp1_ = _tmp0_;
	_tmp2_ = dc_markdown_collapse_lines (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = dc_markdown_clamp_chars (_tmp3_, max_chars);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	result = _tmp5_;
	return result;
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static gchar*
__lambda12_ (GMatchInfo* mi)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* result;
	g_return_val_if_fail (mi != NULL, NULL);
	_tmp0_ = g_match_info_fetch (mi, 2);
	text = _tmp0_;
	_tmp1_ = g_match_info_fetch (mi, 1);
	_tmp2_ = _tmp1_;
	_tmp3_ = strlen (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp2_);
	switch (_tmp5_) {
		case 1:
		{
			const gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp6_ = text;
			_tmp7_ = g_strconcat ("<span size=\"x-large\"><b>", _tmp6_, NULL);
			_tmp8_ = _tmp7_;
			_tmp9_ = g_strconcat (_tmp8_, "</b></span>", NULL);
			_tmp10_ = _tmp9_;
			_g_free0 (_tmp8_);
			result = _tmp10_;
			_g_free0 (text);
			return result;
		}
		case 2:
		{
			const gchar* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			gchar* _tmp15_;
			_tmp11_ = text;
			_tmp12_ = g_strconcat ("<span size=\"large\"><b>", _tmp11_, NULL);
			_tmp13_ = _tmp12_;
			_tmp14_ = g_strconcat (_tmp13_, "</b></span>", NULL);
			_tmp15_ = _tmp14_;
			_g_free0 (_tmp13_);
			result = _tmp15_;
			_g_free0 (text);
			return result;
		}
		default:
		{
			const gchar* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			gchar* _tmp20_;
			_tmp16_ = text;
			_tmp17_ = g_strconcat ("<b>", _tmp16_, NULL);
			_tmp18_ = _tmp17_;
			_tmp19_ = g_strconcat (_tmp18_, "</b>", NULL);
			_tmp20_ = _tmp19_;
			_g_free0 (_tmp18_);
			result = _tmp20_;
			_g_free0 (text);
			return result;
		}
	}
}

static gchar*
___lambda12__dc_markdown_match_replacement (GMatchInfo* match,
                                            gpointer self)
{
	gchar* result;
	result = __lambda12_ (match);
	return result;
}

static gint
vala_g_ptr_array_get_length (GPtrArray* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = (gint) self->len;
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static gchar*
dc_markdown_format_markdown (const gchar* escaped,
                             GError** error)
{
	GPtrArray* segments = NULL;
	GPtrArray* _tmp0_;
	gchar* work = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	GRegex* _tmp3_;
	const gchar* _tmp4_;
	GPtrArray* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_ = NULL;
	GRegex* _tmp9_;
	const gchar* _tmp10_;
	GPtrArray* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_ = NULL;
	GRegex* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_ = NULL;
	GRegex* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_ = NULL;
	GRegex* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_ = NULL;
	GRegex* _tmp32_;
	const gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_ = NULL;
	GRegex* _tmp37_;
	const gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	const gchar* _tmp41_;
	GPtrArray* _tmp42_;
	gchar* _tmp43_;
	const gchar* _tmp44_;
	gchar* _tmp45_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (escaped != NULL, NULL);
	dc_markdown_ensure_regexes (&_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return NULL;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp0_ = g_ptr_array_new_full ((guint) 0, _g_free0_);
	segments = _tmp0_;
	_tmp1_ = g_strdup (escaped);
	work = _tmp1_;
	_tmp3_ = dc_markdown_cb_re;
	_tmp4_ = work;
	_tmp5_ = segments;
	_tmp6_ = dc_markdown_extract_code_block (_tmp3_, _tmp4_, _tmp5_, &_inner_error0_);
	_tmp2_ = _tmp6_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp7_ = _tmp2_;
	_tmp2_ = NULL;
	_g_free0 (work);
	work = _tmp7_;
	_tmp9_ = dc_markdown_ic_re;
	_tmp10_ = work;
	_tmp11_ = segments;
	_tmp12_ = dc_markdown_extract_code (_tmp9_, _tmp10_, _tmp11_, &_inner_error0_);
	_tmp8_ = _tmp12_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp13_ = _tmp8_;
	_tmp8_ = NULL;
	_g_free0 (work);
	work = _tmp13_;
	_tmp14_ = work;
	_tmp15_ = dc_markdown_format_task_checkboxes (_tmp14_);
	_g_free0 (work);
	work = _tmp15_;
	_tmp17_ = dc_markdown_bold_re;
	_tmp18_ = work;
	_tmp19_ = g_regex_replace (_tmp17_, _tmp18_, (gssize) -1, 0, "<b>\\2</b>", 0, &_inner_error0_);
	_tmp16_ = _tmp19_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp20_ = _tmp16_;
	_tmp16_ = NULL;
	_g_free0 (work);
	work = _tmp20_;
	_tmp22_ = dc_markdown_italic_re;
	_tmp23_ = work;
	_tmp24_ = g_regex_replace (_tmp22_, _tmp23_, (gssize) -1, 0, "<i>\\1</i>", 0, &_inner_error0_);
	_tmp21_ = _tmp24_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp25_ = _tmp21_;
	_tmp21_ = NULL;
	_g_free0 (work);
	work = _tmp25_;
	_tmp27_ = dc_markdown_italic2_re;
	_tmp28_ = work;
	_tmp29_ = g_regex_replace (_tmp27_, _tmp28_, (gssize) -1, 0, "<i>\\1</i>", 0, &_inner_error0_);
	_tmp26_ = _tmp29_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp30_ = _tmp26_;
	_tmp26_ = NULL;
	_g_free0 (work);
	work = _tmp30_;
	_tmp32_ = dc_markdown_strike_re;
	_tmp33_ = work;
	_tmp34_ = g_regex_replace (_tmp32_, _tmp33_, (gssize) -1, 0, "<s>\\1</s>", 0, &_inner_error0_);
	_tmp31_ = _tmp34_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp35_ = _tmp31_;
	_tmp31_ = NULL;
	_g_free0 (work);
	work = _tmp35_;
	_tmp37_ = dc_markdown_heading_re;
	_tmp38_ = work;
	_tmp39_ = dc_markdown_replace_matches (_tmp37_, _tmp38_, ___lambda12__dc_markdown_match_replacement, NULL, &_inner_error0_);
	_tmp36_ = _tmp39_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp40_ = _tmp36_;
	_tmp36_ = NULL;
	_g_free0 (work);
	work = _tmp40_;
	_tmp41_ = work;
	_tmp42_ = segments;
	_tmp43_ = dc_markdown_format_tables (_tmp41_, _tmp42_);
	_g_free0 (work);
	work = _tmp43_;
	_tmp44_ = work;
	_tmp45_ = dc_markdown_linkify (_tmp44_);
	_g_free0 (work);
	work = _tmp45_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp46_ = FALSE;
			_tmp46_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp48_;
				gint _tmp49_;
				gint _tmp50_;
				const gchar* _tmp51_;
				gchar* _tmp52_;
				gchar* _tmp53_;
				GPtrArray* _tmp54_;
				gconstpointer _tmp55_;
				gchar* _tmp56_;
				if (!_tmp46_) {
					gint _tmp47_;
					_tmp47_ = i;
					i = _tmp47_ + 1;
				}
				_tmp46_ = FALSE;
				_tmp48_ = segments;
				_tmp49_ = vala_g_ptr_array_get_length (_tmp48_);
				_tmp50_ = _tmp49_;
				if (!(i < _tmp50_)) {
					break;
				}
				_tmp51_ = work;
				_tmp52_ = g_strdup_printf ("\x01%d\x01", i);
				_tmp53_ = _tmp52_;
				_tmp54_ = segments;
				_tmp55_ = g_ptr_array_index (_tmp54_, (guint) i);
				_tmp56_ = string_replace (_tmp51_, _tmp53_, (const gchar*) _tmp55_);
				_g_free0 (work);
				work = _tmp56_;
				_g_free0 (_tmp53_);
			}
		}
	}
	result = work;
	_g_free0 (_tmp36_);
	_g_free0 (_tmp31_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp21_);
	_g_free0 (_tmp16_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp2_);
	_g_ptr_array_unref0 (segments);
	return result;
}

static gchar*
dc_markdown_strip_markdown (const gchar* input,
                            GError** error)
{
	GPtrArray* segments = NULL;
	GPtrArray* _tmp0_;
	gchar* work = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	GRegex* _tmp3_;
	const gchar* _tmp4_;
	GPtrArray* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_ = NULL;
	GRegex* _tmp9_;
	const gchar* _tmp10_;
	GPtrArray* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_ = NULL;
	GRegex* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_ = NULL;
	GRegex* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_ = NULL;
	GRegex* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_ = NULL;
	GRegex* _tmp32_;
	const gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_ = NULL;
	GRegex* _tmp37_;
	const gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_ = NULL;
	GRegex* _tmp42_;
	const gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_ = NULL;
	GRegex* _tmp47_;
	const gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_ = NULL;
	GRegex* _tmp52_;
	const gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_ = NULL;
	GRegex* _tmp57_;
	const gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	gchar* _tmp61_ = NULL;
	GRegex* _tmp62_;
	const gchar* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	gchar* _tmp66_ = NULL;
	GRegex* _tmp67_;
	const gchar* _tmp68_;
	gchar* _tmp69_;
	gchar* _tmp70_;
	gchar* _tmp71_ = NULL;
	GRegex* _tmp72_;
	const gchar* _tmp73_;
	gchar* _tmp74_;
	gchar* _tmp75_;
	const gchar* _tmp87_;
	gchar* _tmp88_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	dc_markdown_ensure_regexes (&_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return NULL;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp0_ = g_ptr_array_new_full ((guint) 0, _g_free0_);
	segments = _tmp0_;
	_tmp1_ = g_strdup (input);
	work = _tmp1_;
	_tmp3_ = dc_markdown_cb_re;
	_tmp4_ = work;
	_tmp5_ = segments;
	_tmp6_ = dc_markdown_extract_plain_code (_tmp3_, _tmp4_, _tmp5_, 2, &_inner_error0_);
	_tmp2_ = _tmp6_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp7_ = _tmp2_;
	_tmp2_ = NULL;
	_g_free0 (work);
	work = _tmp7_;
	_tmp9_ = dc_markdown_ic_re;
	_tmp10_ = work;
	_tmp11_ = segments;
	_tmp12_ = dc_markdown_extract_plain_code (_tmp9_, _tmp10_, _tmp11_, 1, &_inner_error0_);
	_tmp8_ = _tmp12_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp13_ = _tmp8_;
	_tmp8_ = NULL;
	_g_free0 (work);
	work = _tmp13_;
	_tmp14_ = work;
	_tmp15_ = dc_markdown_strip_task_checkboxes (_tmp14_);
	_g_free0 (work);
	work = _tmp15_;
	_tmp17_ = dc_markdown_strip_heading_re;
	_tmp18_ = work;
	_tmp19_ = g_regex_replace (_tmp17_, _tmp18_, (gssize) -1, 0, "\\2", 0, &_inner_error0_);
	_tmp16_ = _tmp19_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp20_ = _tmp16_;
	_tmp16_ = NULL;
	_g_free0 (work);
	work = _tmp20_;
	_tmp22_ = dc_markdown_strip_quote_re;
	_tmp23_ = work;
	_tmp24_ = g_regex_replace (_tmp22_, _tmp23_, (gssize) -1, 0, "", 0, &_inner_error0_);
	_tmp21_ = _tmp24_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp25_ = _tmp21_;
	_tmp21_ = NULL;
	_g_free0 (work);
	work = _tmp25_;
	_tmp27_ = dc_markdown_strip_hr_re;
	_tmp28_ = work;
	_tmp29_ = g_regex_replace (_tmp27_, _tmp28_, (gssize) -1, 0, "", 0, &_inner_error0_);
	_tmp26_ = _tmp29_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp30_ = _tmp26_;
	_tmp26_ = NULL;
	_g_free0 (work);
	work = _tmp30_;
	_tmp32_ = dc_markdown_strip_link_re;
	_tmp33_ = work;
	_tmp34_ = g_regex_replace (_tmp32_, _tmp33_, (gssize) -1, 0, "\\1", 0, &_inner_error0_);
	_tmp31_ = _tmp34_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp35_ = _tmp31_;
	_tmp31_ = NULL;
	_g_free0 (work);
	work = _tmp35_;
	_tmp37_ = dc_markdown_strip_ref_link_re;
	_tmp38_ = work;
	_tmp39_ = g_regex_replace (_tmp37_, _tmp38_, (gssize) -1, 0, "\\1", 0, &_inner_error0_);
	_tmp36_ = _tmp39_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp40_ = _tmp36_;
	_tmp36_ = NULL;
	_g_free0 (work);
	work = _tmp40_;
	_tmp42_ = dc_markdown_strip_auto_link_re;
	_tmp43_ = work;
	_tmp44_ = g_regex_replace (_tmp42_, _tmp43_, (gssize) -1, 0, "\\1", 0, &_inner_error0_);
	_tmp41_ = _tmp44_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp45_ = _tmp41_;
	_tmp41_ = NULL;
	_g_free0 (work);
	work = _tmp45_;
	_tmp47_ = dc_markdown_bold_re;
	_tmp48_ = work;
	_tmp49_ = g_regex_replace (_tmp47_, _tmp48_, (gssize) -1, 0, "\\2", 0, &_inner_error0_);
	_tmp46_ = _tmp49_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp50_ = _tmp46_;
	_tmp46_ = NULL;
	_g_free0 (work);
	work = _tmp50_;
	_tmp52_ = dc_markdown_italic_re;
	_tmp53_ = work;
	_tmp54_ = g_regex_replace (_tmp52_, _tmp53_, (gssize) -1, 0, "\\1", 0, &_inner_error0_);
	_tmp51_ = _tmp54_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp55_ = _tmp51_;
	_tmp51_ = NULL;
	_g_free0 (work);
	work = _tmp55_;
	_tmp57_ = dc_markdown_italic2_re;
	_tmp58_ = work;
	_tmp59_ = g_regex_replace (_tmp57_, _tmp58_, (gssize) -1, 0, "\\1", 0, &_inner_error0_);
	_tmp56_ = _tmp59_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp60_ = _tmp56_;
	_tmp56_ = NULL;
	_g_free0 (work);
	work = _tmp60_;
	_tmp62_ = dc_markdown_strike_re;
	_tmp63_ = work;
	_tmp64_ = g_regex_replace (_tmp62_, _tmp63_, (gssize) -1, 0, "\\1", 0, &_inner_error0_);
	_tmp61_ = _tmp64_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp56_);
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp56_);
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp65_ = _tmp61_;
	_tmp61_ = NULL;
	_g_free0 (work);
	work = _tmp65_;
	_tmp67_ = dc_markdown_strip_list_re;
	_tmp68_ = work;
	_tmp69_ = g_regex_replace (_tmp67_, _tmp68_, (gssize) -1, 0, "", 0, &_inner_error0_);
	_tmp66_ = _tmp69_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp61_);
			_g_free0 (_tmp56_);
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp61_);
			_g_free0 (_tmp56_);
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp70_ = _tmp66_;
	_tmp66_ = NULL;
	_g_free0 (work);
	work = _tmp70_;
	_tmp72_ = dc_markdown_strip_escape_re;
	_tmp73_ = work;
	_tmp74_ = g_regex_replace (_tmp72_, _tmp73_, (gssize) -1, 0, "\\1", 0, &_inner_error0_);
	_tmp71_ = _tmp74_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (_tmp66_);
			_g_free0 (_tmp61_);
			_g_free0 (_tmp56_);
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			return NULL;
		} else {
			_g_free0 (_tmp66_);
			_g_free0 (_tmp61_);
			_g_free0 (_tmp56_);
			_g_free0 (_tmp51_);
			_g_free0 (_tmp46_);
			_g_free0 (_tmp41_);
			_g_free0 (_tmp36_);
			_g_free0 (_tmp31_);
			_g_free0 (_tmp26_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp16_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp2_);
			_g_free0 (work);
			_g_ptr_array_unref0 (segments);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp75_ = _tmp71_;
	_tmp71_ = NULL;
	_g_free0 (work);
	work = _tmp75_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp76_ = FALSE;
			_tmp76_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp78_;
				gint _tmp79_;
				gint _tmp80_;
				const gchar* _tmp81_;
				gchar* _tmp82_;
				gchar* _tmp83_;
				GPtrArray* _tmp84_;
				gconstpointer _tmp85_;
				gchar* _tmp86_;
				if (!_tmp76_) {
					gint _tmp77_;
					_tmp77_ = i;
					i = _tmp77_ + 1;
				}
				_tmp76_ = FALSE;
				_tmp78_ = segments;
				_tmp79_ = vala_g_ptr_array_get_length (_tmp78_);
				_tmp80_ = _tmp79_;
				if (!(i < _tmp80_)) {
					break;
				}
				_tmp81_ = work;
				_tmp82_ = g_strdup_printf ("\x01%d\x01", i);
				_tmp83_ = _tmp82_;
				_tmp84_ = segments;
				_tmp85_ = g_ptr_array_index (_tmp84_, (guint) i);
				_tmp86_ = string_replace (_tmp81_, _tmp83_, (const gchar*) _tmp85_);
				_g_free0 (work);
				work = _tmp86_;
				_g_free0 (_tmp83_);
			}
		}
	}
	_tmp87_ = work;
	_tmp88_ = string_strip (_tmp87_);
	result = _tmp88_;
	_g_free0 (_tmp71_);
	_g_free0 (_tmp66_);
	_g_free0 (_tmp61_);
	_g_free0 (_tmp56_);
	_g_free0 (_tmp51_);
	_g_free0 (_tmp46_);
	_g_free0 (_tmp41_);
	_g_free0 (_tmp36_);
	_g_free0 (_tmp31_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp21_);
	_g_free0 (_tmp16_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp2_);
	_g_free0 (work);
	_g_ptr_array_unref0 (segments);
	return result;
}

static gchar*
dc_markdown_collapse_lines (const gchar* input)
{
	gchar* normalized = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** lines = NULL;
	const gchar* _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint lines_length1;
	gint _lines_size_;
	GString* sb = NULL;
	GString* _tmp7_;
	GString* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = string_replace (input, "\r\n", "\n");
	_tmp1_ = _tmp0_;
	_tmp2_ = string_replace (_tmp1_, "\r", "\n");
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	normalized = _tmp3_;
	_tmp4_ = normalized;
	_tmp6_ = _tmp5_ = g_strsplit (_tmp4_, "\n", 0);
	lines = _tmp6_;
	lines_length1 = _vala_array_length (_tmp5_);
	_lines_size_ = lines_length1;
	_tmp7_ = g_string_new ("");
	sb = _tmp7_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp8_ = FALSE;
			_tmp8_ = TRUE;
			while (TRUE) {
				gchar** _tmp10_;
				gint _tmp10__length1;
				gchar* line = NULL;
				gchar** _tmp11_;
				gint _tmp11__length1;
				const gchar* _tmp12_;
				gchar* _tmp13_;
				const gchar* _tmp14_;
				gint _tmp15_;
				gint _tmp16_;
				GString* _tmp17_;
				GString* _tmp19_;
				const gchar* _tmp20_;
				if (!_tmp8_) {
					gint _tmp9_;
					_tmp9_ = i;
					i = _tmp9_ + 1;
				}
				_tmp8_ = FALSE;
				_tmp10_ = lines;
				_tmp10__length1 = lines_length1;
				if (!(i < _tmp10__length1)) {
					break;
				}
				_tmp11_ = lines;
				_tmp11__length1 = lines_length1;
				_tmp12_ = _tmp11_[i];
				_tmp13_ = string_strip (_tmp12_);
				line = _tmp13_;
				_tmp14_ = line;
				_tmp15_ = strlen (_tmp14_);
				_tmp16_ = _tmp15_;
				if (_tmp16_ == 0) {
					_g_free0 (line);
					continue;
				}
				_tmp17_ = sb;
				if (_tmp17_->len > ((gssize) 0)) {
					GString* _tmp18_;
					_tmp18_ = sb;
					g_string_append_c (_tmp18_, ' ');
				}
				_tmp19_ = sb;
				_tmp20_ = line;
				g_string_append (_tmp19_, _tmp20_);
				_g_free0 (line);
			}
		}
	}
	_tmp21_ = sb;
	_tmp22_ = _tmp21_->str;
	_tmp23_ = g_strdup (_tmp22_);
	result = _tmp23_;
	_g_string_free0 (sb);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (normalized);
	return result;
}

static gint
string_index_of_nth_char (const gchar* self,
                          glong c)
{
	gchar* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_offset_to_pointer (self, c);
	result = (gint) (_tmp0_ - ((gchar*) self));
	return result;
}

static gchar*
dc_markdown_clamp_chars (const gchar* input,
                         gint max_chars)
{
	gboolean _tmp0_ = FALSE;
	gchar* _tmp5_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	if (max_chars > 0) {
		_tmp0_ = g_utf8_strlen (input, (gssize) -1) > max_chars;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint byte_pos = 0;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		byte_pos = string_index_of_nth_char (input, (glong) max_chars);
		_tmp1_ = string_substring (input, (glong) 0, (glong) byte_pos);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strconcat (_tmp2_, "…", NULL);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		result = _tmp4_;
		return result;
	}
	_tmp5_ = g_strdup (input);
	result = _tmp5_;
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static gchar*
dc_markdown_format_task_checkboxes (const gchar* input)
{
	gchar** lines = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint lines_length1;
	gint _lines_size_;
	GString* sb = NULL;
	GString* _tmp2_;
	GString* _tmp41_;
	const gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp1_ = _tmp0_ = g_strsplit (input, "\n", 0);
	lines = _tmp1_;
	lines_length1 = _vala_array_length (_tmp0_);
	_lines_size_ = lines_length1;
	_tmp2_ = g_string_new ("");
	sb = _tmp2_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				gchar** _tmp5_;
				gint _tmp5__length1;
				gint marker_start = 0;
				gint content_start = 0;
				gboolean checked = FALSE;
				gchar** _tmp7_;
				gint _tmp7__length1;
				const gchar* _tmp8_;
				gboolean _tmp9_ = FALSE;
				gint _tmp10_ = 0;
				gint _tmp11_ = 0;
				gboolean _tmp12_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = lines;
				_tmp5__length1 = lines_length1;
				if (!(i < _tmp5__length1)) {
					break;
				}
				if (i > 0) {
					GString* _tmp6_;
					_tmp6_ = sb;
					g_string_append_c (_tmp6_, '\n');
				}
				_tmp7_ = lines;
				_tmp7__length1 = lines_length1;
				_tmp8_ = _tmp7_[i];
				_tmp12_ = dc_markdown_parse_task_checkbox (_tmp8_, &_tmp9_, &_tmp10_, &_tmp11_);
				checked = _tmp9_;
				marker_start = _tmp10_;
				content_start = _tmp11_;
				if (_tmp12_) {
					gint prefix_end = 0;
					GString* _tmp21_;
					gchar** _tmp22_;
					gint _tmp22__length1;
					const gchar* _tmp23_;
					gchar* _tmp24_;
					gchar* _tmp25_;
					const gchar* _tmp26_ = NULL;
					GString* _tmp27_;
					gchar** _tmp28_;
					gint _tmp28__length1;
					const gchar* _tmp29_;
					gint _tmp30_;
					gint _tmp31_;
					prefix_end = 0;
					while (TRUE) {
						gboolean _tmp13_ = FALSE;
						gchar** _tmp14_;
						gint _tmp14__length1;
						const gchar* _tmp15_;
						gint _tmp16_;
						gint _tmp17_;
						gint _tmp20_;
						_tmp14_ = lines;
						_tmp14__length1 = lines_length1;
						_tmp15_ = _tmp14_[i];
						_tmp16_ = strlen (_tmp15_);
						_tmp17_ = _tmp16_;
						if (prefix_end < _tmp17_) {
							gchar** _tmp18_;
							gint _tmp18__length1;
							const gchar* _tmp19_;
							_tmp18_ = lines;
							_tmp18__length1 = lines_length1;
							_tmp19_ = _tmp18_[i];
							_tmp13_ = dc_markdown_is_ascii_space (string_get (_tmp19_, (glong) prefix_end));
						} else {
							_tmp13_ = FALSE;
						}
						if (!_tmp13_) {
							break;
						}
						_tmp20_ = prefix_end;
						prefix_end = _tmp20_ + 1;
					}
					_tmp21_ = sb;
					_tmp22_ = lines;
					_tmp22__length1 = lines_length1;
					_tmp23_ = _tmp22_[i];
					_tmp24_ = string_substring (_tmp23_, (glong) 0, (glong) prefix_end);
					_tmp25_ = _tmp24_;
					g_string_append (_tmp21_, _tmp25_);
					_g_free0 (_tmp25_);
					if (checked) {
						_tmp26_ = "✅";
					} else {
						_tmp26_ = "⬜";
					}
					_tmp27_ = sb;
					g_string_append (_tmp27_, _tmp26_);
					_tmp28_ = lines;
					_tmp28__length1 = lines_length1;
					_tmp29_ = _tmp28_[i];
					_tmp30_ = strlen (_tmp29_);
					_tmp31_ = _tmp30_;
					if (content_start < _tmp31_) {
						GString* _tmp32_;
						GString* _tmp33_;
						gchar** _tmp34_;
						gint _tmp34__length1;
						const gchar* _tmp35_;
						gchar* _tmp36_;
						gchar* _tmp37_;
						_tmp32_ = sb;
						g_string_append_c (_tmp32_, ' ');
						_tmp33_ = sb;
						_tmp34_ = lines;
						_tmp34__length1 = lines_length1;
						_tmp35_ = _tmp34_[i];
						_tmp36_ = string_substring (_tmp35_, (glong) content_start, (glong) -1);
						_tmp37_ = _tmp36_;
						g_string_append (_tmp33_, _tmp37_);
						_g_free0 (_tmp37_);
					}
				} else {
					GString* _tmp38_;
					gchar** _tmp39_;
					gint _tmp39__length1;
					const gchar* _tmp40_;
					_tmp38_ = sb;
					_tmp39_ = lines;
					_tmp39__length1 = lines_length1;
					_tmp40_ = _tmp39_[i];
					g_string_append (_tmp38_, _tmp40_);
				}
			}
		}
	}
	_tmp41_ = sb;
	_tmp42_ = _tmp41_->str;
	_tmp43_ = g_strdup (_tmp42_);
	result = _tmp43_;
	_g_string_free0 (sb);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

static gchar*
dc_markdown_strip_task_checkboxes (const gchar* input)
{
	gchar** lines = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint lines_length1;
	gint _lines_size_;
	GString* sb = NULL;
	GString* _tmp2_;
	GString* _tmp41_;
	const gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp1_ = _tmp0_ = g_strsplit (input, "\n", 0);
	lines = _tmp1_;
	lines_length1 = _vala_array_length (_tmp0_);
	_lines_size_ = lines_length1;
	_tmp2_ = g_string_new ("");
	sb = _tmp2_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				gchar** _tmp5_;
				gint _tmp5__length1;
				gint marker_start = 0;
				gint content_start = 0;
				gboolean checked = FALSE;
				gchar** _tmp7_;
				gint _tmp7__length1;
				const gchar* _tmp8_;
				gboolean _tmp9_ = FALSE;
				gint _tmp10_ = 0;
				gint _tmp11_ = 0;
				gboolean _tmp12_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = lines;
				_tmp5__length1 = lines_length1;
				if (!(i < _tmp5__length1)) {
					break;
				}
				if (i > 0) {
					GString* _tmp6_;
					_tmp6_ = sb;
					g_string_append_c (_tmp6_, '\n');
				}
				_tmp7_ = lines;
				_tmp7__length1 = lines_length1;
				_tmp8_ = _tmp7_[i];
				_tmp12_ = dc_markdown_parse_task_checkbox (_tmp8_, &_tmp9_, &_tmp10_, &_tmp11_);
				checked = _tmp9_;
				marker_start = _tmp10_;
				content_start = _tmp11_;
				if (_tmp12_) {
					gint prefix_end = 0;
					GString* _tmp21_;
					gchar** _tmp22_;
					gint _tmp22__length1;
					const gchar* _tmp23_;
					gchar* _tmp24_;
					gchar* _tmp25_;
					const gchar* _tmp26_ = NULL;
					GString* _tmp27_;
					gchar** _tmp28_;
					gint _tmp28__length1;
					const gchar* _tmp29_;
					gint _tmp30_;
					gint _tmp31_;
					prefix_end = 0;
					while (TRUE) {
						gboolean _tmp13_ = FALSE;
						gchar** _tmp14_;
						gint _tmp14__length1;
						const gchar* _tmp15_;
						gint _tmp16_;
						gint _tmp17_;
						gint _tmp20_;
						_tmp14_ = lines;
						_tmp14__length1 = lines_length1;
						_tmp15_ = _tmp14_[i];
						_tmp16_ = strlen (_tmp15_);
						_tmp17_ = _tmp16_;
						if (prefix_end < _tmp17_) {
							gchar** _tmp18_;
							gint _tmp18__length1;
							const gchar* _tmp19_;
							_tmp18_ = lines;
							_tmp18__length1 = lines_length1;
							_tmp19_ = _tmp18_[i];
							_tmp13_ = dc_markdown_is_ascii_space (string_get (_tmp19_, (glong) prefix_end));
						} else {
							_tmp13_ = FALSE;
						}
						if (!_tmp13_) {
							break;
						}
						_tmp20_ = prefix_end;
						prefix_end = _tmp20_ + 1;
					}
					_tmp21_ = sb;
					_tmp22_ = lines;
					_tmp22__length1 = lines_length1;
					_tmp23_ = _tmp22_[i];
					_tmp24_ = string_substring (_tmp23_, (glong) 0, (glong) prefix_end);
					_tmp25_ = _tmp24_;
					g_string_append (_tmp21_, _tmp25_);
					_g_free0 (_tmp25_);
					if (checked) {
						_tmp26_ = "✓";
					} else {
						_tmp26_ = "☐";
					}
					_tmp27_ = sb;
					g_string_append (_tmp27_, _tmp26_);
					_tmp28_ = lines;
					_tmp28__length1 = lines_length1;
					_tmp29_ = _tmp28_[i];
					_tmp30_ = strlen (_tmp29_);
					_tmp31_ = _tmp30_;
					if (content_start < _tmp31_) {
						GString* _tmp32_;
						GString* _tmp33_;
						gchar** _tmp34_;
						gint _tmp34__length1;
						const gchar* _tmp35_;
						gchar* _tmp36_;
						gchar* _tmp37_;
						_tmp32_ = sb;
						g_string_append_c (_tmp32_, ' ');
						_tmp33_ = sb;
						_tmp34_ = lines;
						_tmp34__length1 = lines_length1;
						_tmp35_ = _tmp34_[i];
						_tmp36_ = string_substring (_tmp35_, (glong) content_start, (glong) -1);
						_tmp37_ = _tmp36_;
						g_string_append (_tmp33_, _tmp37_);
						_g_free0 (_tmp37_);
					}
				} else {
					GString* _tmp38_;
					gchar** _tmp39_;
					gint _tmp39__length1;
					const gchar* _tmp40_;
					_tmp38_ = sb;
					_tmp39_ = lines;
					_tmp39__length1 = lines_length1;
					_tmp40_ = _tmp39_[i];
					g_string_append (_tmp38_, _tmp40_);
				}
			}
		}
	}
	_tmp41_ = sb;
	_tmp42_ = _tmp41_->str;
	_tmp43_ = g_strdup (_tmp42_);
	result = _tmp43_;
	_g_string_free0 (sb);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

gboolean
dc_markdown_parse_task_checkbox (const gchar* line,
                                 gboolean* checked,
                                 gint* marker_start,
                                 gint* content_start)
{
	gboolean _vala_checked = FALSE;
	gint _vala_marker_start = 0;
	gint _vala_content_start = 0;
	gint i = 0;
	gint _tmp4_;
	gint _tmp5_;
	gchar bullet = '\0';
	gint _tmp6_;
	gboolean _tmp7_ = FALSE;
	gint _tmp8_;
	gint _tmp9_;
	gint _tmp14_;
	gint _tmp15_;
	gboolean _tmp16_ = FALSE;
	gchar state = '\0';
	gboolean result;
	g_return_val_if_fail (line != NULL, FALSE);
	_vala_checked = FALSE;
	_vala_marker_start = 0;
	_vala_content_start = 0;
	i = 0;
	while (TRUE) {
		gboolean _tmp0_ = FALSE;
		gint _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		_tmp1_ = strlen (line);
		_tmp2_ = _tmp1_;
		if (i < _tmp2_) {
			_tmp0_ = dc_markdown_is_ascii_space (string_get (line, (glong) i));
		} else {
			_tmp0_ = FALSE;
		}
		if (!_tmp0_) {
			break;
		}
		_tmp3_ = i;
		i = _tmp3_ + 1;
	}
	_tmp4_ = strlen (line);
	_tmp5_ = _tmp4_;
	if (i >= _tmp5_) {
		result = FALSE;
		if (checked) {
			*checked = _vala_checked;
		}
		if (marker_start) {
			*marker_start = _vala_marker_start;
		}
		if (content_start) {
			*content_start = _vala_content_start;
		}
		return result;
	}
	bullet = string_get (line, (glong) i);
	if (bullet != '*') {
		result = FALSE;
		if (checked) {
			*checked = _vala_checked;
		}
		if (marker_start) {
			*marker_start = _vala_marker_start;
		}
		if (content_start) {
			*content_start = _vala_content_start;
		}
		return result;
	}
	_tmp6_ = i;
	i = _tmp6_ + 1;
	_tmp8_ = strlen (line);
	_tmp9_ = _tmp8_;
	if (i >= _tmp9_) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = !dc_markdown_is_ascii_space (string_get (line, (glong) i));
	}
	if (_tmp7_) {
		result = FALSE;
		if (checked) {
			*checked = _vala_checked;
		}
		if (marker_start) {
			*marker_start = _vala_marker_start;
		}
		if (content_start) {
			*content_start = _vala_content_start;
		}
		return result;
	}
	while (TRUE) {
		gboolean _tmp10_ = FALSE;
		gint _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		_tmp11_ = strlen (line);
		_tmp12_ = _tmp11_;
		if (i < _tmp12_) {
			_tmp10_ = dc_markdown_is_ascii_space (string_get (line, (glong) i));
		} else {
			_tmp10_ = FALSE;
		}
		if (!_tmp10_) {
			break;
		}
		_tmp13_ = i;
		i = _tmp13_ + 1;
	}
	_vala_marker_start = i;
	_tmp14_ = strlen (line);
	_tmp15_ = _tmp14_;
	if ((i + 2) >= _tmp15_) {
		result = FALSE;
		if (checked) {
			*checked = _vala_checked;
		}
		if (marker_start) {
			*marker_start = _vala_marker_start;
		}
		if (content_start) {
			*content_start = _vala_content_start;
		}
		return result;
	}
	if (string_get (line, (glong) i) != '[') {
		_tmp16_ = TRUE;
	} else {
		_tmp16_ = string_get (line, (glong) (i + 2)) != ']';
	}
	if (_tmp16_) {
		result = FALSE;
		if (checked) {
			*checked = _vala_checked;
		}
		if (marker_start) {
			*marker_start = _vala_marker_start;
		}
		if (content_start) {
			*content_start = _vala_content_start;
		}
		return result;
	}
	state = string_get (line, (glong) (i + 1));
	if (state == ' ') {
		_vala_checked = FALSE;
	} else {
		if (state == 'x') {
			_vala_checked = TRUE;
		} else {
			result = FALSE;
			if (checked) {
				*checked = _vala_checked;
			}
			if (marker_start) {
				*marker_start = _vala_marker_start;
			}
			if (content_start) {
				*content_start = _vala_content_start;
			}
			return result;
		}
	}
	i += 3;
	while (TRUE) {
		gboolean _tmp17_ = FALSE;
		gint _tmp18_;
		gint _tmp19_;
		gint _tmp20_;
		_tmp18_ = strlen (line);
		_tmp19_ = _tmp18_;
		if (i < _tmp19_) {
			_tmp17_ = dc_markdown_is_ascii_space (string_get (line, (glong) i));
		} else {
			_tmp17_ = FALSE;
		}
		if (!_tmp17_) {
			break;
		}
		_tmp20_ = i;
		i = _tmp20_ + 1;
	}
	_vala_content_start = i;
	result = TRUE;
	if (checked) {
		*checked = _vala_checked;
	}
	if (marker_start) {
		*marker_start = _vala_marker_start;
	}
	if (content_start) {
		*content_start = _vala_content_start;
	}
	return result;
}

static gboolean
dc_markdown_is_ascii_space (gchar c)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	if (c == ' ') {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = c == '\t';
	}
	result = _tmp0_;
	return result;
}

/**
         * Replace regex matches with numbered placeholders, storing the
         * matched content wrapped in <tt> tags for later restoration.
         */
static gpointer
_g_ptr_array_ref0 (gpointer self)
{
	return self ? g_ptr_array_ref (self) : NULL;
}

static Block18Data*
block18_data_ref (Block18Data* _data18_)
{
	g_atomic_int_inc (&_data18_->_ref_count_);
	return _data18_;
}

static void
block18_data_unref (void * _userdata_)
{
	Block18Data* _data18_;
	_data18_ = (Block18Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
		_g_ptr_array_unref0 (_data18_->segments);
		g_slice_free (Block18Data, _data18_);
	}
}

static gchar*
__lambda11_ (Block18Data* _data18_,
             GMatchInfo* mi)
{
	gint idx = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (mi != NULL, NULL);
	_tmp0_ = vala_g_ptr_array_get_length (_data18_->segments);
	_tmp1_ = _tmp0_;
	idx = (gint) _tmp1_;
	_tmp2_ = g_match_info_fetch (mi, 1);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat ("<tt>", _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, "</tt>", NULL);
	g_ptr_array_add (_data18_->segments, _tmp6_);
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	_tmp7_ = g_strdup_printf ("\x01%d\x01", idx);
	result = _tmp7_;
	return result;
}

static gchar*
___lambda11__dc_markdown_match_replacement (GMatchInfo* match,
                                            gpointer self)
{
	gchar* result;
	result = __lambda11_ (self, match);
	return result;
}

static gchar*
dc_markdown_extract_code (GRegex* re,
                          const gchar* input,
                          GPtrArray* segments,
                          GError** error)
{
	Block18Data* _data18_;
	GPtrArray* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (re != NULL, NULL);
	g_return_val_if_fail (input != NULL, NULL);
	g_return_val_if_fail (segments != NULL, NULL);
	_data18_ = g_slice_new0 (Block18Data);
	_data18_->_ref_count_ = 1;
	_tmp0_ = _g_ptr_array_ref0 (segments);
	_g_ptr_array_unref0 (_data18_->segments);
	_data18_->segments = _tmp0_;
	_tmp2_ = dc_markdown_replace_matches (re, input, ___lambda11__dc_markdown_match_replacement, _data18_, &_inner_error0_);
	_tmp1_ = _tmp2_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			block18_data_unref (_data18_);
			_data18_ = NULL;
			return NULL;
		} else {
			block18_data_unref (_data18_);
			_data18_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp3_ = _tmp1_;
	_tmp1_ = NULL;
	result = _tmp3_;
	_g_free0 (_tmp1_);
	block18_data_unref (_data18_);
	_data18_ = NULL;
	return result;
}

/**
         * Like extract_code, but runs fenced blocks through the generic
         * syntax highlighter. Group 1 is the fence delimiter, group 2 the
         * content. The captured content was markup-escaped with
         * the whole message, so unescape before tokenizing; the highlighter
         * re-escapes every chunk it emits.
         */
static Block19Data*
block19_data_ref (Block19Data* _data19_)
{
	g_atomic_int_inc (&_data19_->_ref_count_);
	return _data19_;
}

static void
block19_data_unref (void * _userdata_)
{
	Block19Data* _data19_;
	_data19_ = (Block19Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data19_->_ref_count_)) {
		_g_ptr_array_unref0 (_data19_->segments);
		g_slice_free (Block19Data, _data19_);
	}
}

static gchar*
__lambda10_ (Block19Data* _data19_,
             GMatchInfo* mi)
{
	gint idx = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* raw = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* result;
	g_return_val_if_fail (mi != NULL, NULL);
	_tmp0_ = vala_g_ptr_array_get_length (_data19_->segments);
	_tmp1_ = _tmp0_;
	idx = (gint) _tmp1_;
	_tmp2_ = g_match_info_fetch (mi, 2);
	_tmp3_ = _tmp2_;
	_tmp4_ = dc_markdown_unescape_markup (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	raw = _tmp5_;
	_tmp6_ = dc_syntax_highlight_highlight (raw);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat ("<tt>", _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat (_tmp9_, "</tt>", NULL);
	g_ptr_array_add (_data19_->segments, _tmp10_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_tmp11_ = g_strdup_printf ("\x01%d\x01", idx);
	result = _tmp11_;
	_g_free0 (raw);
	return result;
}

static gchar*
___lambda10__dc_markdown_match_replacement (GMatchInfo* match,
                                            gpointer self)
{
	gchar* result;
	result = __lambda10_ (self, match);
	return result;
}

static gchar*
dc_markdown_extract_code_block (GRegex* re,
                                const gchar* input,
                                GPtrArray* segments,
                                GError** error)
{
	Block19Data* _data19_;
	GPtrArray* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (re != NULL, NULL);
	g_return_val_if_fail (input != NULL, NULL);
	g_return_val_if_fail (segments != NULL, NULL);
	_data19_ = g_slice_new0 (Block19Data);
	_data19_->_ref_count_ = 1;
	_tmp0_ = _g_ptr_array_ref0 (segments);
	_g_ptr_array_unref0 (_data19_->segments);
	_data19_->segments = _tmp0_;
	_tmp2_ = dc_markdown_replace_matches (re, input, ___lambda10__dc_markdown_match_replacement, _data19_, &_inner_error0_);
	_tmp1_ = _tmp2_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			block19_data_unref (_data19_);
			_data19_ = NULL;
			return NULL;
		} else {
			block19_data_unref (_data19_);
			_data19_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp3_ = _tmp1_;
	_tmp1_ = NULL;
	result = _tmp3_;
	_g_free0 (_tmp1_);
	block19_data_unref (_data19_);
	_data19_ = NULL;
	return result;
}

static gchar*
dc_markdown_unescape_markup (const gchar* escaped)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* result;
	g_return_val_if_fail (escaped != NULL, NULL);
	_tmp0_ = string_replace (escaped, "&lt;", "<");
	_tmp1_ = _tmp0_;
	_tmp2_ = string_replace (_tmp1_, "&gt;", ">");
	_tmp3_ = _tmp2_;
	_tmp4_ = string_replace (_tmp3_, "&quot;", "\"");
	_tmp5_ = _tmp4_;
	_tmp6_ = string_replace (_tmp5_, "&apos;", "'");
	_tmp7_ = _tmp6_;
	_tmp8_ = string_replace (_tmp7_, "&amp;", "&");
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	result = _tmp9_;
	return result;
}

static Block20Data*
block20_data_ref (Block20Data* _data20_)
{
	g_atomic_int_inc (&_data20_->_ref_count_);
	return _data20_;
}

static void
block20_data_unref (void * _userdata_)
{
	Block20Data* _data20_;
	_data20_ = (Block20Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data20_->_ref_count_)) {
		_g_ptr_array_unref0 (_data20_->segments);
		g_slice_free (Block20Data, _data20_);
	}
}

static gchar*
__lambda8_ (Block20Data* _data20_,
            GMatchInfo* mi)
{
	gint idx = 0;
	gint _tmp0_;
	gint _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (mi != NULL, NULL);
	_tmp0_ = vala_g_ptr_array_get_length (_data20_->segments);
	_tmp1_ = _tmp0_;
	idx = (gint) _tmp1_;
	_tmp2_ = g_match_info_fetch (mi, _data20_->group);
	g_ptr_array_add (_data20_->segments, _tmp2_);
	_tmp3_ = g_strdup_printf ("\x01%d\x01", idx);
	result = _tmp3_;
	return result;
}

static gchar*
___lambda8__dc_markdown_match_replacement (GMatchInfo* match,
                                           gpointer self)
{
	gchar* result;
	result = __lambda8_ (self, match);
	return result;
}

static gchar*
dc_markdown_extract_plain_code (GRegex* re,
                                const gchar* input,
                                GPtrArray* segments,
                                gint group,
                                GError** error)
{
	Block20Data* _data20_;
	GPtrArray* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (re != NULL, NULL);
	g_return_val_if_fail (input != NULL, NULL);
	g_return_val_if_fail (segments != NULL, NULL);
	_data20_ = g_slice_new0 (Block20Data);
	_data20_->_ref_count_ = 1;
	_tmp0_ = _g_ptr_array_ref0 (segments);
	_g_ptr_array_unref0 (_data20_->segments);
	_data20_->segments = _tmp0_;
	_data20_->group = group;
	_tmp2_ = dc_markdown_replace_matches (re, input, ___lambda8__dc_markdown_match_replacement, _data20_, &_inner_error0_);
	_tmp1_ = _tmp2_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_REGEX_ERROR) {
			g_propagate_error (error, _inner_error0_);
			block20_data_unref (_data20_);
			_data20_ = NULL;
			return NULL;
		} else {
			block20_data_unref (_data20_);
			_data20_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp3_ = _tmp1_;
	_tmp1_ = NULL;
	result = _tmp3_;
	_g_free0 (_tmp1_);
	block20_data_unref (_data20_);
	_data20_ = NULL;
	return result;
}

static gchar*
dc_markdown_format_tables (const gchar* input,
                           GPtrArray* segments)
{
	gchar** lines = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint lines_length1;
	gint _lines_size_;
	GString* sb = NULL;
	GString* _tmp2_;
	gboolean first = FALSE;
	GString* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	g_return_val_if_fail (segments != NULL, NULL);
	_tmp1_ = _tmp0_ = g_strsplit (input, "\n", 0);
	lines = _tmp1_;
	lines_length1 = _vala_array_length (_tmp0_);
	_lines_size_ = lines_length1;
	_tmp2_ = g_string_new ("");
	sb = _tmp2_;
	first = TRUE;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				gchar** _tmp4_;
				gint _tmp4__length1;
				gint end = 0;
				gchar* table = NULL;
				gchar** _tmp5_;
				gint _tmp5__length1;
				gint _tmp6_ = 0;
				gchar* _tmp7_;
				const gchar* _tmp9_;
				if (!_tmp3_) {
				}
				_tmp3_ = FALSE;
				_tmp4_ = lines;
				_tmp4__length1 = lines_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				_tmp5_ = lines;
				_tmp5__length1 = lines_length1;
				_tmp7_ = dc_markdown_try_format_table_at (_tmp5_, (gint) _tmp5__length1, i, &_tmp6_, segments);
				end = _tmp6_;
				table = _tmp7_;
				if (!first) {
					GString* _tmp8_;
					_tmp8_ = sb;
					g_string_append_c (_tmp8_, '\n');
				}
				first = FALSE;
				_tmp9_ = table;
				if (_tmp9_ != NULL) {
					GString* _tmp10_;
					const gchar* _tmp11_;
					_tmp10_ = sb;
					_tmp11_ = table;
					g_string_append (_tmp10_, _tmp11_);
					i = end;
				} else {
					GString* _tmp12_;
					gchar** _tmp13_;
					gint _tmp13__length1;
					const gchar* _tmp14_;
					gint _tmp15_;
					_tmp12_ = sb;
					_tmp13_ = lines;
					_tmp13__length1 = lines_length1;
					_tmp14_ = _tmp13_[i];
					g_string_append (_tmp12_, _tmp14_);
					_tmp15_ = i;
					i = _tmp15_ + 1;
				}
				_g_free0 (table);
			}
		}
	}
	_tmp16_ = sb;
	_tmp17_ = _tmp16_->str;
	_tmp18_ = g_strdup (_tmp17_);
	result = _tmp18_;
	_g_string_free0 (sb);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

static void
_dc_markdown_table_row_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (dc_markdown_table_row_unref (var), NULL));
}

static gchar*
dc_markdown_try_format_table_at (gchar** lines,
                                 gint lines_length1,
                                 gint start,
                                 gint* end,
                                 GPtrArray* segments)
{
	gint _vala_end = 0;
	gchar** header = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gchar** _tmp2_;
	gint header_length1;
	gint _header_size_;
	gchar** separator = NULL;
	const gchar* _tmp3_;
	gint _tmp4_ = 0;
	gchar** _tmp5_;
	gint separator_length1;
	gint _separator_size_;
	gboolean _tmp6_ = FALSE;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gboolean _tmp9_ = FALSE;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gint cols = 0;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gint* widths = NULL;
	gint* _tmp15_;
	gint widths_length1;
	gint _widths_size_;
	gint* aligns = NULL;
	gint* _tmp16_;
	gint aligns_length1;
	gint _aligns_size_;
	GPtrArray* rows = NULL;
	GPtrArray* _tmp23_;
	GPtrArray* _tmp24_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	DcMarkdownTableRow* _tmp26_;
	GPtrArray* _tmp27_;
	gchar** _tmp28_;
	gint _tmp28__length1;
	DcMarkdownTableRow* _tmp29_;
	gint* _tmp30_;
	gint _tmp30__length1;
	gchar** _tmp31_;
	gint _tmp31__length1;
	GPtrArray* _tmp52_;
	gint* _tmp53_;
	gint _tmp53__length1;
	gint* _tmp54_;
	gint _tmp54__length1;
	gchar* _tmp55_;
	gchar* result;
	g_return_val_if_fail (segments != NULL, NULL);
	_vala_end = start;
	if ((start + 1) >= lines_length1) {
		result = NULL;
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp0_ = lines[start];
	_tmp2_ = dc_markdown_parse_table_row (_tmp0_, &_tmp1_);
	header = _tmp2_;
	header_length1 = _tmp1_;
	_header_size_ = header_length1;
	_tmp3_ = lines[start + 1];
	_tmp5_ = dc_markdown_parse_table_row (_tmp3_, &_tmp4_);
	separator = _tmp5_;
	separator_length1 = _tmp4_;
	_separator_size_ = separator_length1;
	_tmp7_ = header;
	_tmp7__length1 = header_length1;
	if (_tmp7_ == NULL) {
		_tmp6_ = TRUE;
	} else {
		gchar** _tmp8_;
		gint _tmp8__length1;
		_tmp8_ = separator;
		_tmp8__length1 = separator_length1;
		_tmp6_ = _tmp8_ == NULL;
	}
	if (_tmp6_) {
		result = NULL;
		separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
		header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp10_ = header;
	_tmp10__length1 = header_length1;
	if (_tmp10__length1 < 2) {
		_tmp9_ = TRUE;
	} else {
		gchar** _tmp11_;
		gint _tmp11__length1;
		gchar** _tmp12_;
		gint _tmp12__length1;
		_tmp11_ = header;
		_tmp11__length1 = header_length1;
		_tmp12_ = separator;
		_tmp12__length1 = separator_length1;
		_tmp9_ = _tmp11__length1 != _tmp12__length1;
	}
	if (_tmp9_) {
		result = NULL;
		separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
		header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp13_ = separator;
	_tmp13__length1 = separator_length1;
	if (!dc_markdown_is_separator_row (_tmp13_, (gint) _tmp13__length1)) {
		result = NULL;
		separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
		header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp14_ = header;
	_tmp14__length1 = header_length1;
	cols = _tmp14__length1;
	_tmp15_ = g_new0 (gint, cols);
	widths = _tmp15_;
	widths_length1 = cols;
	_widths_size_ = widths_length1;
	_tmp16_ = g_new0 (gint, cols);
	aligns = _tmp16_;
	aligns_length1 = cols;
	_aligns_size_ = aligns_length1;
	{
		gint c = 0;
		c = 0;
		{
			gboolean _tmp17_ = FALSE;
			_tmp17_ = TRUE;
			while (TRUE) {
				gint* _tmp19_;
				gint _tmp19__length1;
				gint* _tmp20_;
				gint _tmp20__length1;
				gchar** _tmp21_;
				gint _tmp21__length1;
				const gchar* _tmp22_;
				if (!_tmp17_) {
					gint _tmp18_;
					_tmp18_ = c;
					c = _tmp18_ + 1;
				}
				_tmp17_ = FALSE;
				if (!(c < cols)) {
					break;
				}
				_tmp19_ = widths;
				_tmp19__length1 = widths_length1;
				_tmp19_[c] = 3;
				_tmp20_ = aligns;
				_tmp20__length1 = aligns_length1;
				_tmp21_ = separator;
				_tmp21__length1 = separator_length1;
				_tmp22_ = _tmp21_[c];
				_tmp20_[c] = dc_markdown_separator_align (_tmp22_);
			}
		}
	}
	_tmp23_ = g_ptr_array_new_full ((guint) 0, _dc_markdown_table_row_unref0_);
	rows = _tmp23_;
	_tmp24_ = rows;
	_tmp25_ = header;
	_tmp25__length1 = header_length1;
	_tmp26_ = dc_markdown_table_row_new (_tmp25_, _tmp25__length1, FALSE);
	g_ptr_array_add (_tmp24_, _tmp26_);
	_tmp27_ = rows;
	_tmp28_ = separator;
	_tmp28__length1 = separator_length1;
	_tmp29_ = dc_markdown_table_row_new (_tmp28_, _tmp28__length1, TRUE);
	g_ptr_array_add (_tmp27_, _tmp29_);
	_tmp30_ = widths;
	_tmp30__length1 = widths_length1;
	_tmp31_ = header;
	_tmp31__length1 = header_length1;
	dc_markdown_update_widths (_tmp30_, (gint) _tmp30__length1, _tmp31_, (gint) _tmp31__length1, segments);
	_vala_end = start + 2;
	while (TRUE) {
		gchar* line = NULL;
		const gchar* _tmp32_;
		gchar* _tmp33_;
		const gchar* _tmp34_;
		gchar* _tmp35_;
		gchar* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		gboolean _tmp39_;
		gchar** cells = NULL;
		const gchar* _tmp40_;
		gint _tmp41_ = 0;
		gchar** _tmp42_;
		gint cells_length1;
		gint _cells_size_;
		gboolean _tmp43_ = FALSE;
		gchar** _tmp44_;
		gint _tmp44__length1;
		GPtrArray* _tmp46_;
		gchar** _tmp47_;
		gint _tmp47__length1;
		DcMarkdownTableRow* _tmp48_;
		gint* _tmp49_;
		gint _tmp49__length1;
		gchar** _tmp50_;
		gint _tmp50__length1;
		gint _tmp51_;
		if (!(_vala_end < lines_length1)) {
			break;
		}
		_tmp32_ = lines[_vala_end];
		_tmp33_ = g_strdup (_tmp32_);
		line = _tmp33_;
		_tmp34_ = line;
		_tmp35_ = string_strip (_tmp34_);
		_tmp36_ = _tmp35_;
		_tmp37_ = strlen (_tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = _tmp38_ == 0;
		_g_free0 (_tmp36_);
		if (_tmp39_) {
			_g_free0 (line);
			break;
		}
		_tmp40_ = line;
		_tmp42_ = dc_markdown_parse_table_row (_tmp40_, &_tmp41_);
		cells = _tmp42_;
		cells_length1 = _tmp41_;
		_cells_size_ = cells_length1;
		_tmp44_ = cells;
		_tmp44__length1 = cells_length1;
		if (_tmp44_ == NULL) {
			_tmp43_ = TRUE;
		} else {
			gchar** _tmp45_;
			gint _tmp45__length1;
			_tmp45_ = cells;
			_tmp45__length1 = cells_length1;
			_tmp43_ = _tmp45__length1 != cols;
		}
		if (_tmp43_) {
			cells = (_vala_array_free (cells, cells_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (line);
			break;
		}
		_tmp46_ = rows;
		_tmp47_ = cells;
		_tmp47__length1 = cells_length1;
		_tmp48_ = dc_markdown_table_row_new (_tmp47_, _tmp47__length1, FALSE);
		g_ptr_array_add (_tmp46_, _tmp48_);
		_tmp49_ = widths;
		_tmp49__length1 = widths_length1;
		_tmp50_ = cells;
		_tmp50__length1 = cells_length1;
		dc_markdown_update_widths (_tmp49_, (gint) _tmp49__length1, _tmp50_, (gint) _tmp50__length1, segments);
		_tmp51_ = _vala_end;
		_vala_end = _tmp51_ + 1;
		cells = (_vala_array_free (cells, cells_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (line);
	}
	_tmp52_ = rows;
	_tmp53_ = widths;
	_tmp53__length1 = widths_length1;
	_tmp54_ = aligns;
	_tmp54__length1 = aligns_length1;
	_tmp55_ = dc_markdown_render_table (_tmp52_, _tmp53_, (gint) _tmp53__length1, _tmp54_, (gint) _tmp54__length1, segments);
	result = _tmp55_;
	_g_ptr_array_unref0 (rows);
	aligns = (g_free (aligns), NULL);
	widths = (g_free (widths), NULL);
	separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
	header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
	if (end) {
		*end = _vala_end;
	}
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gchar**
dc_markdown_parse_table_row (const gchar* line,
                             gint* result_length1)
{
	gchar* trimmed = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* inner = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	gchar** raw = NULL;
	const gchar* _tmp18_;
	gchar** _tmp19_;
	gchar** _tmp20_;
	gint raw_length1;
	gint _raw_size_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	gchar** cells = NULL;
	gchar** _tmp23_;
	gint _tmp23__length1;
	gchar** _tmp24_;
	gint cells_length1;
	gint _cells_size_;
	gchar** _tmp32_;
	gint _tmp32__length1;
	gchar** result;
	g_return_val_if_fail (line != NULL, NULL);
	_tmp0_ = string_strip (line);
	trimmed = _tmp0_;
	_tmp1_ = trimmed;
	if (!string_contains (_tmp1_, "|")) {
		gchar** _tmp2_;
		gint _tmp2__length1;
		_tmp2_ = NULL;
		_tmp2__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp2__length1;
		}
		result = _tmp2_;
		_g_free0 (trimmed);
		return result;
	}
	_tmp3_ = trimmed;
	_tmp4_ = g_strdup (_tmp3_);
	inner = _tmp4_;
	_tmp5_ = inner;
	if (g_str_has_prefix (_tmp5_, "|")) {
		const gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp6_ = inner;
		_tmp7_ = string_substring (_tmp6_, (glong) 1, (glong) -1);
		_g_free0 (inner);
		inner = _tmp7_;
	}
	_tmp9_ = inner;
	if (g_str_has_suffix (_tmp9_, "|")) {
		const gchar* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp10_ = inner;
		_tmp11_ = strlen (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp8_ = _tmp12_ > 0;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		gchar* _tmp17_;
		_tmp13_ = inner;
		_tmp14_ = inner;
		_tmp15_ = strlen (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = string_substring (_tmp13_, (glong) 0, (glong) (_tmp16_ - 1));
		_g_free0 (inner);
		inner = _tmp17_;
	}
	_tmp18_ = inner;
	_tmp20_ = _tmp19_ = g_strsplit (_tmp18_, "|", 0);
	raw = _tmp20_;
	raw_length1 = _vala_array_length (_tmp19_);
	_raw_size_ = raw_length1;
	_tmp21_ = raw;
	_tmp21__length1 = raw_length1;
	if (_tmp21__length1 < 2) {
		gchar** _tmp22_;
		gint _tmp22__length1;
		_tmp22_ = NULL;
		_tmp22__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp22__length1;
		}
		result = _tmp22_;
		raw = (_vala_array_free (raw, raw_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (inner);
		_g_free0 (trimmed);
		return result;
	}
	_tmp23_ = raw;
	_tmp23__length1 = raw_length1;
	_tmp24_ = g_new0 (gchar*, _tmp23__length1 + 1);
	cells = _tmp24_;
	cells_length1 = _tmp23__length1;
	_cells_size_ = cells_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp25_ = FALSE;
			_tmp25_ = TRUE;
			while (TRUE) {
				gchar** _tmp27_;
				gint _tmp27__length1;
				gchar** _tmp28_;
				gint _tmp28__length1;
				gchar** _tmp29_;
				gint _tmp29__length1;
				const gchar* _tmp30_;
				gchar* _tmp31_;
				if (!_tmp25_) {
					gint _tmp26_;
					_tmp26_ = i;
					i = _tmp26_ + 1;
				}
				_tmp25_ = FALSE;
				_tmp27_ = raw;
				_tmp27__length1 = raw_length1;
				if (!(i < _tmp27__length1)) {
					break;
				}
				_tmp28_ = cells;
				_tmp28__length1 = cells_length1;
				_tmp29_ = raw;
				_tmp29__length1 = raw_length1;
				_tmp30_ = _tmp29_[i];
				_tmp31_ = string_strip (_tmp30_);
				_g_free0 (_tmp28_[i]);
				_tmp28_[i] = _tmp31_;
			}
		}
	}
	_tmp32_ = cells;
	_tmp32__length1 = cells_length1;
	if (result_length1) {
		*result_length1 = _tmp32__length1;
	}
	result = _tmp32_;
	raw = (_vala_array_free (raw, raw_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (inner);
	_g_free0 (trimmed);
	return result;
}

static gboolean
dc_markdown_is_separator_row (gchar** cells,
                              gint cells_length1)
{
	gboolean result;
	{
		gchar** cell_collection = NULL;
		gint cell_collection_length1 = 0;
		gint _cell_collection_size_ = 0;
		gint cell_it = 0;
		cell_collection = cells;
		cell_collection_length1 = cells_length1;
		for (cell_it = 0; cell_it < cell_collection_length1; cell_it = cell_it + 1) {
			gchar* _tmp0_;
			gchar* cell = NULL;
			_tmp0_ = g_strdup (cell_collection[cell_it]);
			cell = _tmp0_;
			{
				gchar* s = NULL;
				const gchar* _tmp1_;
				gchar* _tmp2_;
				gint _tmp3_ = 0;
				const gchar* _tmp4_;
				gint start = 0;
				gint _tmp5_ = 0;
				const gchar* _tmp6_;
				gint end = 0;
				_tmp1_ = cell;
				_tmp2_ = string_strip (_tmp1_);
				s = _tmp2_;
				_tmp4_ = s;
				if (g_str_has_prefix (_tmp4_, ":")) {
					_tmp3_ = 1;
				} else {
					_tmp3_ = 0;
				}
				start = _tmp3_;
				_tmp6_ = s;
				if (g_str_has_suffix (_tmp6_, ":")) {
					const gchar* _tmp7_;
					gint _tmp8_;
					gint _tmp9_;
					_tmp7_ = s;
					_tmp8_ = strlen (_tmp7_);
					_tmp9_ = _tmp8_;
					_tmp5_ = _tmp9_ - 1;
				} else {
					const gchar* _tmp10_;
					gint _tmp11_;
					gint _tmp12_;
					_tmp10_ = s;
					_tmp11_ = strlen (_tmp10_);
					_tmp12_ = _tmp11_;
					_tmp5_ = _tmp12_;
				}
				end = _tmp5_;
				if ((end - start) < 3) {
					result = FALSE;
					_g_free0 (s);
					_g_free0 (cell);
					return result;
				}
				{
					gint i = 0;
					i = start;
					{
						gboolean _tmp13_ = FALSE;
						_tmp13_ = TRUE;
						while (TRUE) {
							const gchar* _tmp15_;
							if (!_tmp13_) {
								gint _tmp14_;
								_tmp14_ = i;
								i = _tmp14_ + 1;
							}
							_tmp13_ = FALSE;
							if (!(i < end)) {
								break;
							}
							_tmp15_ = s;
							if (string_get (_tmp15_, (glong) i) != '-') {
								result = FALSE;
								_g_free0 (s);
								_g_free0 (cell);
								return result;
							}
						}
					}
				}
				_g_free0 (s);
				_g_free0 (cell);
			}
		}
	}
	result = TRUE;
	return result;
}

static gint
dc_markdown_separator_align (const gchar* cell)
{
	gchar* s = NULL;
	gchar* _tmp0_;
	gboolean left = FALSE;
	const gchar* _tmp1_;
	gboolean right = FALSE;
	const gchar* _tmp2_;
	gboolean _tmp3_ = FALSE;
	gint result;
	g_return_val_if_fail (cell != NULL, -1);
	_tmp0_ = string_strip (cell);
	s = _tmp0_;
	_tmp1_ = s;
	left = g_str_has_prefix (_tmp1_, ":");
	_tmp2_ = s;
	right = g_str_has_suffix (_tmp2_, ":");
	if (left) {
		_tmp3_ = right;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		result = DC_MARKDOWN_ALIGN_CENTER;
		_g_free0 (s);
		return result;
	}
	if (right) {
		result = DC_MARKDOWN_ALIGN_RIGHT;
		_g_free0 (s);
		return result;
	}
	result = DC_MARKDOWN_ALIGN_LEFT;
	_g_free0 (s);
	return result;
}

static void
dc_markdown_update_widths (gint* widths,
                           gint widths_length1,
                           gchar** cells,
                           gint cells_length1,
                           GPtrArray* segments)
{
	g_return_if_fail (segments != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint width = 0;
				const gchar* _tmp2_;
				gint _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < widths_length1)) {
					break;
				}
				_tmp2_ = cells[i];
				width = dc_markdown_visible_width (_tmp2_, segments);
				_tmp3_ = widths[i];
				if (width > _tmp3_) {
					widths[i] = width;
				}
			}
		}
	}
}

static gpointer
_dc_markdown_table_row_ref0 (gpointer self)
{
	return self ? dc_markdown_table_row_ref (self) : NULL;
}

static gchar*
dc_markdown_render_table (GPtrArray* rows,
                          gint* widths,
                          gint widths_length1,
                          gint* aligns,
                          gint aligns_length1,
                          GPtrArray* segments)
{
	GString* sb = NULL;
	GString* _tmp0_;
	GString* _tmp1_;
	GString* _tmp20_;
	GString* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* result;
	g_return_val_if_fail (rows != NULL, NULL);
	g_return_val_if_fail (segments != NULL, NULL);
	_tmp0_ = g_string_new ("");
	sb = _tmp0_;
	_tmp1_ = sb;
	g_string_append (_tmp1_, "<tt>");
	{
		gint r = 0;
		r = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gint _tmp4_;
				gint _tmp5_;
				DcMarkdownTableRow* row = NULL;
				gconstpointer _tmp7_;
				DcMarkdownTableRow* _tmp8_;
				DcMarkdownTableRow* _tmp9_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = r;
					r = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = vala_g_ptr_array_get_length (rows);
				_tmp5_ = _tmp4_;
				if (!(r < _tmp5_)) {
					break;
				}
				if (r > 0) {
					GString* _tmp6_;
					_tmp6_ = sb;
					g_string_append_c (_tmp6_, '\n');
				}
				_tmp7_ = g_ptr_array_index (rows, (guint) r);
				_tmp8_ = _dc_markdown_table_row_ref0 ((DcMarkdownTableRow*) _tmp7_);
				row = _tmp8_;
				_tmp9_ = row;
				if (_tmp9_->separator) {
					GString* _tmp10_;
					_tmp10_ = sb;
					dc_markdown_append_separator (_tmp10_, widths, (gint) widths_length1);
					_dc_markdown_table_row_unref0 (row);
					continue;
				}
				{
					gint c = 0;
					c = 0;
					{
						gboolean _tmp11_ = FALSE;
						_tmp11_ = TRUE;
						while (TRUE) {
							GString* _tmp14_;
							DcMarkdownTableRow* _tmp15_;
							gchar** _tmp16_;
							gint _tmp16__length1;
							const gchar* _tmp17_;
							gint _tmp18_;
							gint _tmp19_;
							if (!_tmp11_) {
								gint _tmp12_;
								_tmp12_ = c;
								c = _tmp12_ + 1;
							}
							_tmp11_ = FALSE;
							if (!(c < widths_length1)) {
								break;
							}
							if (c > 0) {
								GString* _tmp13_;
								_tmp13_ = sb;
								g_string_append (_tmp13_, " | ");
							}
							_tmp14_ = sb;
							_tmp15_ = row;
							_tmp16_ = _tmp15_->cells;
							_tmp16__length1 = _tmp15_->cells_length1;
							_tmp17_ = _tmp16_[c];
							_tmp18_ = widths[c];
							_tmp19_ = aligns[c];
							dc_markdown_append_aligned_cell (_tmp14_, _tmp17_, _tmp18_, _tmp19_, segments);
						}
					}
				}
				_dc_markdown_table_row_unref0 (row);
			}
		}
	}
	_tmp20_ = sb;
	g_string_append (_tmp20_, "</tt>");
	_tmp21_ = sb;
	_tmp22_ = _tmp21_->str;
	_tmp23_ = g_strdup (_tmp22_);
	result = _tmp23_;
	_g_string_free0 (sb);
	return result;
}

static void
dc_markdown_append_separator (GString* sb,
                              gint* widths,
                              gint widths_length1)
{
	g_return_if_fail (sb != NULL);
	{
		gint c = 0;
		c = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = c;
					c = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(c < widths_length1)) {
					break;
				}
				if (c > 0) {
					g_string_append (sb, "-+-");
				}
				_tmp2_ = widths[c];
				dc_markdown_append_repeated (sb, '-', _tmp2_);
			}
		}
	}
}

static void
dc_markdown_append_aligned_cell (GString* sb,
                                 const gchar* cell,
                                 gint width,
                                 gint align,
                                 GPtrArray* segments)
{
	gint pad = 0;
	g_return_if_fail (sb != NULL);
	g_return_if_fail (cell != NULL);
	g_return_if_fail (segments != NULL);
	pad = width - dc_markdown_visible_width (cell, segments);
	if (pad < 0) {
		pad = 0;
	}
	if (align == DC_MARKDOWN_ALIGN_RIGHT) {
		dc_markdown_append_repeated (sb, ' ', pad);
		g_string_append (sb, cell);
	} else {
		if (align == DC_MARKDOWN_ALIGN_CENTER) {
			gint left = 0;
			left = pad / 2;
			dc_markdown_append_repeated (sb, ' ', left);
			g_string_append (sb, cell);
			dc_markdown_append_repeated (sb, ' ', pad - left);
		} else {
			g_string_append (sb, cell);
			dc_markdown_append_repeated (sb, ' ', pad);
		}
	}
}

static void
dc_markdown_append_repeated (GString* sb,
                             gchar c,
                             gint count)
{
	g_return_if_fail (sb != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < count)) {
					break;
				}
				g_string_append_c (sb, c);
			}
		}
	}
}

static gboolean
string_get_next_char (const gchar* self,
                      gint* index,
                      gunichar* c)
{
	gunichar _vala_c = 0U;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_vala_c = g_utf8_get_char (((gchar*) self) + (*index));
	if (_vala_c != ((gunichar) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_utf8_next_char (((gchar*) self) + (*index));
		*index = (gint) (_tmp0_ - ((gchar*) self));
		result = TRUE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	} else {
		result = FALSE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	}
}

static gint
string_index_of_char (const gchar* self,
                      gunichar c,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_strchr (((gchar*) self) + start_index, (gssize) -1, c);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gint
dc_markdown_visible_width (const gchar* markup,
                           GPtrArray* segments)
{
	gint width = 0;
	gboolean in_tag = FALSE;
	gint result;
	g_return_val_if_fail (markup != NULL, -1);
	width = 0;
	in_tag = FALSE;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp1_;
				gint _tmp2_;
				gunichar c = 0U;
				gunichar _tmp3_ = 0U;
				gboolean _tmp4_;
				gboolean _tmp7_ = FALSE;
				gint _tmp18_;
				if (!_tmp0_) {
				}
				_tmp0_ = FALSE;
				_tmp1_ = strlen (markup);
				_tmp2_ = _tmp1_;
				if (!(i < _tmp2_)) {
					break;
				}
				_tmp4_ = string_get_next_char (markup, &i, &_tmp3_);
				c = _tmp3_;
				if (!_tmp4_) {
					break;
				}
				if (in_tag) {
					if (c == ((gunichar) '>')) {
						in_tag = FALSE;
					}
					continue;
				}
				if (c == ((gunichar) '<')) {
					in_tag = TRUE;
					continue;
				}
				if (c == ((gunichar) '&')) {
					gint semi = 0;
					gboolean _tmp5_ = FALSE;
					semi = string_index_of_char (markup, (gunichar) ';', i);
					if (semi >= i) {
						_tmp5_ = (semi - i) <= 16;
					} else {
						_tmp5_ = FALSE;
					}
					if (_tmp5_) {
						gint _tmp6_;
						_tmp6_ = width;
						width = _tmp6_ + 1;
						i = semi + 1;
						continue;
					}
				}
				if (c == ((gunichar) 0x01)) {
					_tmp7_ = segments != NULL;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					gint* idx = NULL;
					gint* _tmp8_;
					gboolean _tmp9_ = FALSE;
					gboolean _tmp10_ = FALSE;
					gint* _tmp11_;
					_tmp8_ = dc_markdown_read_segment_index (markup, &i);
					idx = _tmp8_;
					_tmp11_ = idx;
					if (_tmp11_ != NULL) {
						gint* _tmp12_;
						_tmp12_ = idx;
						_tmp10_ = (*_tmp12_) >= 0;
					} else {
						_tmp10_ = FALSE;
					}
					if (_tmp10_) {
						gint* _tmp13_;
						gint _tmp14_;
						gint _tmp15_;
						_tmp13_ = idx;
						_tmp14_ = vala_g_ptr_array_get_length (segments);
						_tmp15_ = _tmp14_;
						_tmp9_ = (*_tmp13_) < _tmp15_;
					} else {
						_tmp9_ = FALSE;
					}
					if (_tmp9_) {
						gint* _tmp16_;
						gconstpointer _tmp17_;
						_tmp16_ = idx;
						_tmp17_ = g_ptr_array_index (segments, *_tmp16_);
						width += dc_markdown_visible_width ((const gchar*) _tmp17_, NULL);
						_g_free0 (idx);
						continue;
					}
					_g_free0 (idx);
				}
				_tmp18_ = width;
				width = _tmp18_ + 1;
			}
		}
	}
	result = width;
	return result;
}

static gint*
_int_dup (gint* self)
{
	gint* dup;
	dup = g_new0 (gint, 1);
	memcpy (dup, self, sizeof (gint));
	return dup;
}

static gpointer
__int_dup0 (gpointer self)
{
	return self ? _int_dup (self) : NULL;
}

static gint*
dc_markdown_read_segment_index (const gchar* text,
                                gint* index)
{
	gint idx = 0;
	gboolean have_digit = FALSE;
	gint* result;
	g_return_val_if_fail (text != NULL, NULL);
	idx = 0;
	have_digit = FALSE;
	while (TRUE) {
		gint _tmp0_;
		gint _tmp1_;
		gchar c = '\0';
		gboolean _tmp4_ = FALSE;
		gint _tmp5_;
		_tmp0_ = strlen (text);
		_tmp1_ = _tmp0_;
		if (!((*index) < _tmp1_)) {
			break;
		}
		c = string_get (text, (glong) (*index));
		if (c == '\x01') {
			gint _tmp2_;
			_tmp2_ = *index;
			*index = _tmp2_ + 1;
			if (have_digit) {
				gint* _tmp3_;
				_tmp3_ = __int_dup0 (&idx);
				result = _tmp3_;
				return result;
			}
			result = NULL;
			return result;
		}
		if (c < '0') {
			_tmp4_ = TRUE;
		} else {
			_tmp4_ = c > '9';
		}
		if (_tmp4_) {
			result = NULL;
			return result;
		}
		idx = (idx * 10) + (c - '0');
		have_digit = TRUE;
		_tmp5_ = *index;
		*index = _tmp5_ + 1;
	}
	result = NULL;
	return result;
}

static gchar*
___lambda9_ (GMatchInfo* mi)
{
	gchar* url = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (mi != NULL, NULL);
	_tmp0_ = g_match_info_fetch (mi, 0);
	url = _tmp0_;
	_tmp1_ = g_strconcat ("<a href=\"", url, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "\"><span underline=\"single\">", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strconcat (_tmp4_, url, NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_strconcat (_tmp6_, "</span></a>", NULL);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	result = _tmp8_;
	_g_free0 (url);
	return result;
}

static gchar*
____lambda9__dc_markdown_match_replacement (GMatchInfo* match,
                                            gpointer self)
{
	gchar* result;
	result = ___lambda9_ (match);
	return result;
}

static gchar*
dc_markdown_linkify (const gchar* escaped)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (escaped != NULL, NULL);
	{
		gchar* _tmp0_ = NULL;
		GRegex* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		dc_markdown_ensure_regexes (&_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp1_ = dc_markdown_link_re;
		_tmp2_ = dc_markdown_replace_matches (_tmp1_, escaped, ____lambda9__dc_markdown_match_replacement, NULL, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		result = _tmp3_;
		_g_free0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		gchar* _tmp4_;
		g_clear_error (&_inner_error0_);
		_tmp4_ = g_strdup (escaped);
		result = _tmp4_;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

DcMarkdown*
dc_markdown_construct (GType object_type)
{
	DcMarkdown* self = NULL;
	self = (DcMarkdown*) g_type_create_instance (object_type);
	return self;
}

DcMarkdown*
dc_markdown_new (void)
{
	return dc_markdown_construct (DC_TYPE_MARKDOWN);
}

static gchar**
_vala_array_dup6 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static DcMarkdownTableRow*
dc_markdown_table_row_construct (GType object_type,
                                 gchar** cells,
                                 gint cells_length1,
                                 gboolean separator)
{
	DcMarkdownTableRow* self = NULL;
	gchar** _tmp0_;
	gint _tmp0__length1;
	self = (DcMarkdownTableRow*) g_type_create_instance (object_type);
	_tmp0_ = (cells != NULL) ? _vala_array_dup6 (cells, cells_length1) : cells;
	_tmp0__length1 = cells_length1;
	self->cells = (_vala_array_free (self->cells, self->cells_length1, (GDestroyNotify) g_free), NULL);
	self->cells = _tmp0_;
	self->cells_length1 = _tmp0__length1;
	self->_cells_size_ = self->cells_length1;
	self->separator = separator;
	return self;
}

static DcMarkdownTableRow*
dc_markdown_table_row_new (gchar** cells,
                           gint cells_length1,
                           gboolean separator)
{
	return dc_markdown_table_row_construct (DC_MARKDOWN_TYPE_TABLE_ROW, cells, cells_length1, separator);
}

static void
dc_markdown_value_table_row_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dc_markdown_value_table_row_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dc_markdown_table_row_unref (value->data[0].v_pointer);
	}
}

static void
dc_markdown_value_table_row_copy_value (const GValue* src_value,
                                        GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dc_markdown_table_row_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dc_markdown_value_table_row_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dc_markdown_value_table_row_collect_value (GValue* value,
                                           guint n_collect_values,
                                           GTypeCValue* collect_values,
                                           guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DcMarkdownTableRow * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dc_markdown_table_row_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dc_markdown_value_table_row_lcopy_value (const GValue* value,
                                         guint n_collect_values,
                                         GTypeCValue* collect_values,
                                         guint collect_flags)
{
	DcMarkdownTableRow ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dc_markdown_table_row_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
dc_markdown_param_spec_table_row (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags)
{
	DcMarkdownParamSpecTableRow* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DC_MARKDOWN_TYPE_TABLE_ROW), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
dc_markdown_value_get_table_row (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MARKDOWN_TYPE_TABLE_ROW), NULL);
	return value->data[0].v_pointer;
}

static void
dc_markdown_value_set_table_row (GValue* value,
                                 gpointer v_object)
{
	DcMarkdownTableRow * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MARKDOWN_TYPE_TABLE_ROW));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_MARKDOWN_TYPE_TABLE_ROW));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dc_markdown_table_row_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_markdown_table_row_unref (old);
	}
}

static void
dc_markdown_value_take_table_row (GValue* value,
                                  gpointer v_object)
{
	DcMarkdownTableRow * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MARKDOWN_TYPE_TABLE_ROW));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_MARKDOWN_TYPE_TABLE_ROW));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_markdown_table_row_unref (old);
	}
}

static void
dc_markdown_table_row_class_init (DcMarkdownTableRowClass * klass,
                                  gpointer klass_data)
{
	dc_markdown_table_row_parent_class = g_type_class_peek_parent (klass);
	((DcMarkdownTableRowClass *) klass)->finalize = dc_markdown_table_row_finalize;
}

static void
dc_markdown_table_row_instance_init (DcMarkdownTableRow * self,
                                     gpointer klass)
{
	self->ref_count = 1;
}

static void
dc_markdown_table_row_finalize (DcMarkdownTableRow * obj)
{
	DcMarkdownTableRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_MARKDOWN_TYPE_TABLE_ROW, DcMarkdownTableRow);
	g_signal_handlers_destroy (self);
	self->cells = (_vala_array_free (self->cells, self->cells_length1, (GDestroyNotify) g_free), NULL);
}

static GType
dc_markdown_table_row_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dc_markdown_value_table_row_init, dc_markdown_value_table_row_free_value, dc_markdown_value_table_row_copy_value, dc_markdown_value_table_row_peek_pointer, "p", dc_markdown_value_table_row_collect_value, "p", dc_markdown_value_table_row_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DcMarkdownTableRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_markdown_table_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcMarkdownTableRow), 0, (GInstanceInitFunc) dc_markdown_table_row_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dc_markdown_table_row_type_id;
	dc_markdown_table_row_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DcMarkdownTableRow", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dc_markdown_table_row_type_id;
}

static GType
dc_markdown_table_row_get_type (void)
{
	static volatile gsize dc_markdown_table_row_type_id__once = 0;
	if (g_once_init_enter (&dc_markdown_table_row_type_id__once)) {
		GType dc_markdown_table_row_type_id;
		dc_markdown_table_row_type_id = dc_markdown_table_row_get_type_once ();
		g_once_init_leave (&dc_markdown_table_row_type_id__once, dc_markdown_table_row_type_id);
	}
	return dc_markdown_table_row_type_id__once;
}

static gpointer
dc_markdown_table_row_ref (gpointer instance)
{
	DcMarkdownTableRow * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
dc_markdown_table_row_unref (gpointer instance)
{
	DcMarkdownTableRow * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DC_MARKDOWN_TABLE_ROW_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
dc_value_markdown_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dc_value_markdown_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dc_markdown_unref (value->data[0].v_pointer);
	}
}

static void
dc_value_markdown_copy_value (const GValue* src_value,
                              GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dc_markdown_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dc_value_markdown_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dc_value_markdown_collect_value (GValue* value,
                                 guint n_collect_values,
                                 GTypeCValue* collect_values,
                                 guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DcMarkdown * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dc_markdown_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dc_value_markdown_lcopy_value (const GValue* value,
                               guint n_collect_values,
                               GTypeCValue* collect_values,
                               guint collect_flags)
{
	DcMarkdown ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dc_markdown_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
dc_param_spec_markdown (const gchar* name,
                        const gchar* nick,
                        const gchar* blurb,
                        GType object_type,
                        GParamFlags flags)
{
	DcParamSpecMarkdown* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DC_TYPE_MARKDOWN), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
dc_value_get_markdown (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_TYPE_MARKDOWN), NULL);
	return value->data[0].v_pointer;
}

void
dc_value_set_markdown (GValue* value,
                       gpointer v_object)
{
	DcMarkdown * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_TYPE_MARKDOWN));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_TYPE_MARKDOWN));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dc_markdown_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_markdown_unref (old);
	}
}

void
dc_value_take_markdown (GValue* value,
                        gpointer v_object)
{
	DcMarkdown * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_TYPE_MARKDOWN));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_TYPE_MARKDOWN));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_markdown_unref (old);
	}
}

static void
dc_markdown_class_init (DcMarkdownClass * klass,
                        gpointer klass_data)
{
	dc_markdown_parent_class = g_type_class_peek_parent (klass);
	((DcMarkdownClass *) klass)->finalize = dc_markdown_finalize;
}

static void
dc_markdown_instance_init (DcMarkdown * self,
                           gpointer klass)
{
	self->ref_count = 1;
}

static void
dc_markdown_finalize (DcMarkdown * obj)
{
	DcMarkdown * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_MARKDOWN, DcMarkdown);
	g_signal_handlers_destroy (self);
}

/**
     * Converts markdown-formatted text to Pango markup for GTK labels.
     * Supports: bold, italic, strikethrough, inline code, code blocks,
     * headings, task-list checkboxes, tables, and URL linkification.
     * Also strips markdown down to plain text for compact previews.
     */
static GType
dc_markdown_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dc_value_markdown_init, dc_value_markdown_free_value, dc_value_markdown_copy_value, dc_value_markdown_peek_pointer, "p", dc_value_markdown_collect_value, "p", dc_value_markdown_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DcMarkdownClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_markdown_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcMarkdown), 0, (GInstanceInitFunc) dc_markdown_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dc_markdown_type_id;
	dc_markdown_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DcMarkdown", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dc_markdown_type_id;
}

GType
dc_markdown_get_type (void)
{
	static volatile gsize dc_markdown_type_id__once = 0;
	if (g_once_init_enter (&dc_markdown_type_id__once)) {
		GType dc_markdown_type_id;
		dc_markdown_type_id = dc_markdown_get_type_once ();
		g_once_init_leave (&dc_markdown_type_id__once, dc_markdown_type_id);
	}
	return dc_markdown_type_id__once;
}

gpointer
dc_markdown_ref (gpointer instance)
{
	DcMarkdown * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
dc_markdown_unref (gpointer instance)
{
	DcMarkdown * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DC_MARKDOWN_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

