Sha256: d17cb2734ddf21825fdc110e5042ce8ac1498d32e1f670619356ba227b6070cf

Contents?: true

Size: 1.56 KB

Versions: 57

Compression:

Stored size: 1.56 KB

Contents

#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "config.h"
#include "cmark-gfm.h"
#include "syntax_extension.h"
#include "registry.h"
#include "plugin.h"

extern cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR;

static cmark_llist *syntax_extensions = NULL;

void cmark_register_plugin(cmark_plugin_init_func reg_fn) {
  cmark_plugin *plugin = cmark_plugin_new();

  if (!reg_fn(plugin)) {
    cmark_plugin_free(plugin);
    return;
  }

  cmark_llist *syntax_extensions_list = cmark_plugin_steal_syntax_extensions(plugin),
              *it;

  for (it = syntax_extensions_list; it; it = it->next) {
    syntax_extensions = cmark_llist_append(&CMARK_DEFAULT_MEM_ALLOCATOR, syntax_extensions, it->data);
  }

  cmark_llist_free(&CMARK_DEFAULT_MEM_ALLOCATOR, syntax_extensions_list);
  cmark_plugin_free(plugin);
}

void cmark_release_plugins(void) {
  if (syntax_extensions) {
    cmark_llist_free_full(
        &CMARK_DEFAULT_MEM_ALLOCATOR,
        syntax_extensions,
        (cmark_free_func) cmark_syntax_extension_free);
    syntax_extensions = NULL;
  }
}

cmark_llist *cmark_list_syntax_extensions(cmark_mem *mem) {
  cmark_llist *it;
  cmark_llist *res = NULL;

  for (it = syntax_extensions; it; it = it->next) {
    res = cmark_llist_append(mem, res, it->data);
  }
  return res;
}

cmark_syntax_extension *cmark_find_syntax_extension(const char *name) {
  cmark_llist *tmp;

  for (tmp = syntax_extensions; tmp; tmp = tmp->next) {
    cmark_syntax_extension *ext = (cmark_syntax_extension *) tmp->data;
    if (!strcmp(ext->name, name))
      return ext;
  }
  return NULL;
}

Version data entries

57 entries across 57 versions & 5 rubygems

Version Path
commonmarker-0.23.11 ext/commonmarker/registry.c
markly-0.12.1 ext/markly/registry.c
markly-0.12.0 ext/markly/registry.c
markly-0.11.0 ext/markly/registry.c
markly-0.10.0 ext/markly/registry.c
markly-0.9.1 ext/markly/registry.c
commonmarker-0.23.10 ext/commonmarker/registry.c
markly-0.9.0 ext/markly/registry.c
markly-0.8.1 ext/markly/registry.c
markly-0.8.0 ext/markly/registry.c
qiita_marker-0.23.9.0 ext/qiita_marker/registry.c
commonmarker-0.23.9 ext/commonmarker/registry.c
commonmarker-0.23.8 ext/commonmarker/registry.c
commonmarker-0.23.7 ext/commonmarker/registry.c
qiita_marker-0.23.6.2 ext/qiita_marker/registry.c
commonmarker-0.23.7.pre1 ext/commonmarker/registry.c
qiita_marker-0.23.6.1 ext/qiita_marker/registry.c
qiita_marker-0.23.6.0 ext/qiita_marker/registry.c
commonmarker-0.23.6 ext/commonmarker/registry.c
qiita_marker-0.23.5.1 ext/qiita_marker/registry.c