Sha256: 2d3ea8798842f825f6a939ad62f1a5a85aac99b6af2b935950a0cca172cfb318

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "registry.h"
#include "node.h"
#include "houdini.h"
#include "cmark.h"
#include "buffer.h"

cmark_node_type CMARK_NODE_LAST_BLOCK = CMARK_NODE_FOOTNOTE_DEFINITION;
cmark_node_type CMARK_NODE_LAST_INLINE = CMARK_NODE_FOOTNOTE_REFERENCE;

int cmark_version() { return CMARK_VERSION; }

const char *cmark_version_string() { return CMARK_VERSION_STRING; }

static void *xcalloc(size_t nmem, size_t size) {
  void *ptr = calloc(nmem, size);
  if (!ptr) {
    fprintf(stderr, "[cmark] calloc returned null pointer, aborting\n");
    abort();
  }
  return ptr;
}

static void *xrealloc(void *ptr, size_t size) {
  void *new_ptr = realloc(ptr, size);
  if (!new_ptr) {
    fprintf(stderr, "[cmark] realloc returned null pointer, aborting\n");
    abort();
  }
  return new_ptr;
}

static void xfree(void *ptr) {
  free(ptr);
}

cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR = {xcalloc, xrealloc, xfree};

cmark_mem *cmark_get_default_mem_allocator() {
  return &CMARK_DEFAULT_MEM_ALLOCATOR;
}

char *cmark_markdown_to_html(const char *text, size_t len, int options) {
  cmark_node *doc;
  char *result;

  doc = cmark_parse_document(text, len, options);

  result = cmark_render_html(doc, options, NULL);
  cmark_node_free(doc);

  return result;
}

Version data entries

9 entries across 8 versions & 2 rubygems

Version Path
commonmarker-0.17.11 ext/commonmarker/cmark.c
commonmarker-0.17.10 ext/commonmarker/cmark.c
tdiary-5.0.8 vendor/bundle/gems/commonmarker-0.17.9/ext/commonmarker/cmark.c
commonmarker-0.17.9 ext/commonmarker/cmark.c
commonmarker-0.17.8 ext/commonmarker/cmark.c
commonmarker-0.17.7.1 ext/commonmarker/cmark.c
commonmarker-0.17.7 ext/commonmarker/cmark-upstream/src/cmark.c
commonmarker-0.17.7 ext/commonmarker/cmark.c
commonmarker-0.17.6 ext/commonmarker/cmark/src/cmark.c