Sha256: ce455a04c67f1de52fa90594405ccddee15e3a91f9323120f34a15596d19f868

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 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_THEMATIC_BREAK;
cmark_node_type CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE;

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

15 entries across 15 versions & 1 rubygems

Version Path
commonmarker-0.17.5 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.17.4 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.17.2 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.17.1 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.17.0 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.8 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.7 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.6 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.5 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.4 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.1 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.2 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.3 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.16.0 ext/commonmarker/cmark/src/cmark.c
commonmarker-0.15.0 ext/commonmarker/cmark/src/cmark.c