mirror of
https://github.com/swiftlang/swift-cmark.git
synced 2026-01-18 17:31:20 +01:00
Normalise header and define names (#109)
* cmark -> cmark-gfm in most places * normalize filenames, exports * ensure some more #defines don't conflict
This commit is contained in:
@@ -6,7 +6,7 @@ if(CMAKE_MAJOR_VERSION GREATER 2)
|
||||
cmake_policy(SET CMP0048 OLD)
|
||||
endif()
|
||||
|
||||
project(cmark)
|
||||
project(cmark-gfm)
|
||||
|
||||
include("FindAsan.cmake")
|
||||
|
||||
@@ -14,7 +14,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
message(FATAL_ERROR "Do not build in-source.\nPlease remove CMakeCache.txt and the CMakeFiles/ directory.\nThen: mkdir build ; cd build ; cmake .. ; make")
|
||||
endif()
|
||||
|
||||
set(PROJECT_NAME "cmark")
|
||||
set(PROJECT_NAME "cmark-gfm")
|
||||
|
||||
set(PROJECT_VERSION_MAJOR 0)
|
||||
set(PROJECT_VERSION_MINOR 28)
|
||||
@@ -22,7 +22,7 @@ set(PROJECT_VERSION_PATCH 3)
|
||||
set(PROJECT_VERSION_GFM 14)
|
||||
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM} )
|
||||
|
||||
option(CMARK_TESTS "Build cmark tests and enable testing" ON)
|
||||
option(CMARK_TESTS "Build cmark-gfm tests and enable testing" ON)
|
||||
option(CMARK_STATIC "Build static libcmark-gfm library" ON)
|
||||
option(CMARK_SHARED "Build shared libcmark-gfm library" ON)
|
||||
option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF)
|
||||
|
||||
6
Makefile
6
Makefile
@@ -101,7 +101,7 @@ mingw:
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$(MINGW_INSTALLDIR) ;\
|
||||
$(MAKE) && $(MAKE) install
|
||||
|
||||
man/man3/cmark-gfm.3: src/cmark.h | $(CMARK)
|
||||
man/man3/cmark-gfm.3: src/cmark-gfm.h | $(CMARK)
|
||||
python man/make_man_page.py $< > $@ \
|
||||
|
||||
archive:
|
||||
@@ -222,5 +222,5 @@ distclean: clean
|
||||
-rm -rf $(BENCHFILE) $(ALLTESTS) progit
|
||||
|
||||
docker:
|
||||
docker build -t cmark $(CURDIR)/tools
|
||||
docker run --privileged -t -i -v $(CURDIR):/src/cmark -w /src/cmark cmark /bin/bash
|
||||
docker build -t cmark-gfm $(CURDIR)/tools
|
||||
docker run --privileged -t -i -v $(CURDIR):/src/cmark-gfm -w /src/cmark-gfm cmark-gfm /bin/bash
|
||||
|
||||
@@ -3,7 +3,7 @@ DATADIR=data
|
||||
BUILDDIR=build
|
||||
INSTALLDIR=windows
|
||||
SPEC=test/spec.txt
|
||||
PROG=$(BUILDDIR)\src\cmark.exe
|
||||
PROG=$(BUILDDIR)\src\cmark-gfm.exe
|
||||
GENERATOR=NMake Makefiles
|
||||
|
||||
all: $(BUILDDIR)/CMakeFiles
|
||||
|
||||
@@ -10,9 +10,9 @@ include_directories(
|
||||
${PROJECT_BINARY_DIR}/extensions
|
||||
)
|
||||
if(CMARK_SHARED)
|
||||
target_link_libraries(api_test libcmark-gfmextensions libcmark-gfm)
|
||||
target_link_libraries(api_test libcmark-gfm-extensions libcmark-gfm)
|
||||
else()
|
||||
target_link_libraries(api_test libcmark-gfmextensions_static libcmark-gfm_static)
|
||||
target_link_libraries(api_test libcmark-gfm-extensions_static libcmark-gfm_static)
|
||||
endif()
|
||||
|
||||
# Compiler flags
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "cplusplus.h"
|
||||
#include "harness.h"
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#define CMARK_NO_SHORT_NAMES
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "node.h"
|
||||
#include "../extensions/core-extensions.h"
|
||||
#include "../extensions/cmark-gfm-core-extensions.h"
|
||||
|
||||
#include "harness.h"
|
||||
#include "cplusplus.h"
|
||||
@@ -36,8 +36,8 @@ static void test_incomplete_char(test_batch_runner *runner, const char *utf8,
|
||||
static void test_continuation_byte(test_batch_runner *runner, const char *utf8);
|
||||
|
||||
static void version(test_batch_runner *runner) {
|
||||
INT_EQ(runner, cmark_version(), CMARK_VERSION, "cmark_version");
|
||||
STR_EQ(runner, cmark_version_string(), CMARK_VERSION_STRING,
|
||||
INT_EQ(runner, cmark_version(), CMARK_GFM_VERSION, "cmark_version");
|
||||
STR_EQ(runner, cmark_version_string(), CMARK_GFM_VERSION_STRING,
|
||||
"cmark_version_string");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
set(LIBRARY "libcmark-gfmextensions")
|
||||
set(STATICLIBRARY "libcmark-gfmextensions_static")
|
||||
set(LIBRARY "libcmark-gfm-extensions")
|
||||
set(STATICLIBRARY "libcmark-gfm-extensions_static")
|
||||
set(LIBRARY_SOURCES
|
||||
core-extensions.c
|
||||
table.c
|
||||
@@ -29,7 +29,7 @@ if (CMARK_SHARED)
|
||||
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
|
||||
|
||||
set_target_properties(${LIBRARY} PROPERTIES
|
||||
OUTPUT_NAME "cmark-gfmextensions"
|
||||
OUTPUT_NAME "cmark-gfm-extensions"
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
|
||||
VERSION ${PROJECT_VERSION})
|
||||
|
||||
@@ -37,10 +37,10 @@ if (CMARK_SHARED)
|
||||
APPEND PROPERTY MACOSX_RPATH true)
|
||||
|
||||
# Avoid name clash between PROGRAM and LIBRARY pdb files.
|
||||
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfmextensions_dll)
|
||||
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm-extensions_dll)
|
||||
|
||||
generate_export_header(${LIBRARY}
|
||||
BASE_NAME cmarkextensions)
|
||||
BASE_NAME cmark-gfm-extensions)
|
||||
|
||||
list(APPEND CMARK_INSTALL ${LIBRARY})
|
||||
target_link_libraries(${LIBRARY} libcmark-gfm)
|
||||
@@ -56,17 +56,17 @@ if (CMARK_STATIC)
|
||||
|
||||
if (MSVC)
|
||||
set_target_properties(${STATICLIBRARY} PROPERTIES
|
||||
OUTPUT_NAME "cmark-gfmextensions_static"
|
||||
OUTPUT_NAME "cmark-gfm-extensions_static"
|
||||
VERSION ${PROJECT_VERSION})
|
||||
else()
|
||||
set_target_properties(${STATICLIBRARY} PROPERTIES
|
||||
OUTPUT_NAME "cmark-gfmextensions"
|
||||
OUTPUT_NAME "cmark-gfm-extensions"
|
||||
VERSION ${PROJECT_VERSION})
|
||||
endif(MSVC)
|
||||
|
||||
if (NOT CMARK_SHARED)
|
||||
generate_export_header(${STATICLIBRARY}
|
||||
BASE_NAME cmarkextensions)
|
||||
BASE_NAME cmark-gfm-extensions)
|
||||
endif()
|
||||
|
||||
list(APPEND CMARK_INSTALL ${STATICLIBRARY})
|
||||
@@ -76,7 +76,7 @@ set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
||||
|
||||
include (InstallRequiredSystemLibraries)
|
||||
install(TARGETS ${CMARK_INSTALL}
|
||||
EXPORT cmark-gfmextensions
|
||||
EXPORT cmark-gfm-extensions
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX}
|
||||
@@ -84,12 +84,12 @@ install(TARGETS ${CMARK_INSTALL}
|
||||
|
||||
if (CMARK_SHARED OR CMARK_STATIC)
|
||||
install(FILES
|
||||
core-extensions.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmarkextensions_export.h
|
||||
cmark-gfm-core-extensions.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm-extensions_export.h
|
||||
DESTINATION include
|
||||
)
|
||||
|
||||
install(EXPORT cmark-gfmextensions DESTINATION lib${LIB_SUFFIX}/cmake-gfmextensions)
|
||||
install(EXPORT cmark-gfm-extensions DESTINATION lib${LIB_SUFFIX}/cmake-gfm-extensions)
|
||||
endif()
|
||||
|
||||
# Feature tests
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef AUTOLINK_H
|
||||
#define AUTOLINK_H
|
||||
#ifndef CMARK_GFM_AUTOLINK_H
|
||||
#define CMARK_GFM_AUTOLINK_H
|
||||
|
||||
#include "core-extensions.h"
|
||||
#include "cmark-gfm-core-extensions.h"
|
||||
|
||||
cmark_syntax_extension *create_autolink_extension(void);
|
||||
|
||||
|
||||
25
extensions/cmark-gfm-core-extensions.h
Normal file
25
extensions/cmark-gfm-core-extensions.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef CMARK_GFM_CORE_EXTENSIONS_H
|
||||
#define CMARK_GFM_CORE_EXTENSIONS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmark-gfm-extension_api.h"
|
||||
#include "cmark-gfm-extensions_export.h"
|
||||
#include <stdint.h>
|
||||
|
||||
CMARK_GFM_EXTENSIONS_EXPORT
|
||||
void cmark_gfm_core_extensions_ensure_registered(void);
|
||||
|
||||
CMARK_GFM_EXTENSIONS_EXPORT
|
||||
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node);
|
||||
|
||||
CMARK_GFM_EXTENSIONS_EXPORT
|
||||
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "core-extensions.h"
|
||||
#include "cmark-gfm-core-extensions.h"
|
||||
#include "autolink.h"
|
||||
#include "strikethrough.h"
|
||||
#include "table.h"
|
||||
@@ -15,7 +15,7 @@ static int core_extensions_registration(cmark_plugin *plugin) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void core_extensions_ensure_registered(void) {
|
||||
void cmark_gfm_core_extensions_ensure_registered(void) {
|
||||
static int registered = 0;
|
||||
|
||||
if (!registered) {
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef CORE_EXTENSIONS_H
|
||||
#define CORE_EXTENSIONS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmark_extension_api.h"
|
||||
#include "cmarkextensions_export.h"
|
||||
#include <stdint.h>
|
||||
|
||||
CMARKEXTENSIONS_EXPORT
|
||||
void core_extensions_ensure_registered(void);
|
||||
|
||||
CMARKEXTENSIONS_EXPORT
|
||||
uint16_t cmarkextensions_get_table_columns(cmark_node *node);
|
||||
|
||||
CMARKEXTENSIONS_EXPORT
|
||||
uint8_t *cmarkextensions_get_table_alignments(cmark_node *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "chunk.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef STRIKETHROUGH_H
|
||||
#define STRIKETHROUGH_H
|
||||
#ifndef CMARK_GFM_STRIKETHROUGH_H
|
||||
#define CMARK_GFM_STRIKETHROUGH_H
|
||||
|
||||
#include "core-extensions.h"
|
||||
#include "cmark-gfm-core-extensions.h"
|
||||
|
||||
extern cmark_node_type CMARK_NODE_STRIKETHROUGH;
|
||||
cmark_syntax_extension *create_strikethrough_extension(void);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <cmark_extension_api.h>
|
||||
#include <cmark-gfm-extension_api.h>
|
||||
#include <html.h>
|
||||
#include <inlines.h>
|
||||
#include <parser.h>
|
||||
@@ -685,14 +685,14 @@ cmark_syntax_extension *create_table_extension(void) {
|
||||
return self;
|
||||
}
|
||||
|
||||
uint16_t cmarkextensions_get_table_columns(cmark_node *node) {
|
||||
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node) {
|
||||
if (node->type != CMARK_NODE_TABLE)
|
||||
return 0;
|
||||
|
||||
return ((node_table *)node->as.opaque)->n_columns;
|
||||
}
|
||||
|
||||
uint8_t *cmarkextensions_get_table_alignments(cmark_node *node) {
|
||||
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node) {
|
||||
if (node->type != CMARK_NODE_TABLE)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TABLE_H
|
||||
#define TABLE_H
|
||||
#ifndef CMARK_GFM_TABLE_H
|
||||
#define CMARK_GFM_TABLE_H
|
||||
|
||||
#include "core-extensions.h"
|
||||
#include "cmark-gfm-core-extensions.h"
|
||||
|
||||
|
||||
extern cmark_node_type CMARK_NODE_TABLE, CMARK_NODE_TABLE_ROW,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TAGFILTER_H
|
||||
#define TAGFILTER_H
|
||||
#ifndef CMARK_GFM_TAGFILTER_H
|
||||
#define CMARK_GFM_TAGFILTER_H
|
||||
|
||||
#include "core-extensions.h"
|
||||
#include "cmark-gfm-core-extensions.h"
|
||||
|
||||
cmark_syntax_extension *create_tagfilter_extension(void);
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ def md2man(text):
|
||||
comment_start_re = re.compile('^\/\*\* ?')
|
||||
comment_delim_re = re.compile('^[/ ]\** ?')
|
||||
comment_end_re = re.compile('^ \**\/')
|
||||
function_re = re.compile('^ *(?:CMARK_EXPORT\s+)?(?P<type>(?:const\s+)?\w+(?:\s*[*])?)\s*(?P<name>\w+)\s*\((?P<args>[^)]*)\)')
|
||||
function_re = re.compile('^ *(?:CMARK_GFM_EXPORT\s+)?(?P<type>(?:const\s+)?\w+(?:\s*[*])?)\s*(?P<name>\w+)\s*\((?P<args>[^)]*)\)')
|
||||
blank_re = re.compile('^\s*$')
|
||||
macro_re = re.compile('CMARK_EXPORT *')
|
||||
macro_re = re.compile('CMARK_GFM_EXPORT *')
|
||||
typedef_start_re = re.compile('typedef.*{$')
|
||||
typedef_end_re = re.compile('}')
|
||||
single_quote_re = re.compile("(?<!\w)'([^']+)'(?!\w)")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH cmark-gfm 3 "August 08, 2018" "LOCAL" "Library Functions Manual"
|
||||
.TH cmark-gfm 3 "August 21, 2018" "LOCAL" "Library Functions Manual"
|
||||
.SH
|
||||
NAME
|
||||
.PP
|
||||
|
||||
@@ -7,8 +7,8 @@ include(GNUInstallDirs)
|
||||
set(LIBRARY "libcmark-gfm")
|
||||
set(STATICLIBRARY "libcmark-gfm_static")
|
||||
set(HEADERS
|
||||
cmark.h
|
||||
cmark_extension_api.h
|
||||
cmark-gfm.h
|
||||
cmark-gfm-extension_api.h
|
||||
parser.h
|
||||
buffer.h
|
||||
node.h
|
||||
@@ -69,8 +69,8 @@ include_directories(
|
||||
${PROJECT_BINARY_DIR}/extensions
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark_version.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-gfm_version.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_version.h)
|
||||
|
||||
include (GenerateExportHeader)
|
||||
|
||||
@@ -78,9 +78,9 @@ add_executable(${PROGRAM} ${PROGRAM_SOURCES})
|
||||
add_compiler_export_flags()
|
||||
|
||||
if(CMARK_SHARED)
|
||||
target_link_libraries(${PROGRAM} libcmark-gfmextensions libcmark-gfm)
|
||||
target_link_libraries(${PROGRAM} libcmark-gfm-extensions libcmark-gfm)
|
||||
elseif(CMARK_STATIC)
|
||||
target_link_libraries(${PROGRAM} libcmark-gfmextensions_static libcmark-gfm_static)
|
||||
target_link_libraries(${PROGRAM} libcmark-gfm-extensions_static libcmark-gfm_static)
|
||||
endif()
|
||||
|
||||
# Disable the PUBLIC declarations when compiling the executable:
|
||||
@@ -171,10 +171,10 @@ if(CMARK_SHARED OR CMARK_STATIC)
|
||||
DESTINATION ${libdir}/pkgconfig)
|
||||
|
||||
install(FILES
|
||||
cmark.h
|
||||
cmark_extension_api.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h
|
||||
cmark-gfm.h
|
||||
cmark-gfm-extension_api.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_export.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm_version.h
|
||||
DESTINATION include
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "cmark.h"
|
||||
#include "cmark_extension_api.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "cmark-gfm-extension_api.h"
|
||||
|
||||
static struct arena_chunk {
|
||||
size_t sz, used;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "syntax_extension.h"
|
||||
#include "config.h"
|
||||
#include "parser.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "node.h"
|
||||
#include "references.h"
|
||||
#include "utf8.h"
|
||||
|
||||
46
src/buffer.h
46
src/buffer.h
@@ -7,7 +7,7 @@
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -30,32 +30,32 @@ extern unsigned char cmark_strbuf__initbuf[];
|
||||
* For the cases where CMARK_BUF_INIT cannot be used to do static
|
||||
* initialization.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_init(cmark_mem *mem, cmark_strbuf *buf,
|
||||
bufsize_t initial_size);
|
||||
|
||||
/**
|
||||
* Grow the buffer to hold at least `target_size` bytes.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_free(cmark_strbuf *buf);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
bufsize_t cmark_strbuf_len(const cmark_strbuf *buf);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_copy_cstr(char *data, bufsize_t datasize,
|
||||
const cmark_strbuf *buf);
|
||||
|
||||
@@ -65,48 +65,48 @@ static CMARK_INLINE const char *cmark_strbuf_cstr(const cmark_strbuf *buf) {
|
||||
|
||||
#define cmark_strbuf_at(buf, n) ((buf)->ptr[n])
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data,
|
||||
bufsize_t len);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_sets(cmark_strbuf *buf, const char *string);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_putc(cmark_strbuf *buf, int c);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data,
|
||||
bufsize_t len);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_clear(cmark_strbuf *buf);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
bufsize_t cmark_strbuf_strchr(const cmark_strbuf *buf, int c, bufsize_t pos);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
bufsize_t cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, bufsize_t pos);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_drop(cmark_strbuf *buf, bufsize_t n);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_truncate(cmark_strbuf *buf, bufsize_t len);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_rtrim(cmark_strbuf *buf);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_trim(cmark_strbuf *buf);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_normalize_whitespace(cmark_strbuf *s);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_strbuf_unescape(cmark_strbuf *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "buffer.h"
|
||||
#include "memory.h"
|
||||
#include "cmark_ctype.h"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef CMARK_CMARK_EXTENSION_API_H
|
||||
#define CMARK_CMARK_EXTENSION_API_H
|
||||
#ifndef CMARK_GFM_EXTENSION_API_H
|
||||
#define CMARK_GFM_EXTENSION_API_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
|
||||
struct cmark_renderer;
|
||||
struct cmark_html_renderer;
|
||||
@@ -170,7 +170,7 @@ typedef int (*cmark_plugin_init_func)(cmark_plugin *plugin);
|
||||
* This takes ownership of 'extension', one should not call
|
||||
* 'cmark_syntax_extension_free' on a registered extension.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_plugin_register_syntax_extension(cmark_plugin *plugin,
|
||||
cmark_syntax_extension *extension);
|
||||
|
||||
@@ -180,7 +180,7 @@ int cmark_plugin_register_syntax_extension(cmark_plugin *plugin,
|
||||
* It can then be attached to a cmark_parser
|
||||
* with the cmark_parser_attach_syntax_extension method.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_syntax_extension *cmark_find_syntax_extension(const char *name);
|
||||
|
||||
/** Should create and add a new open block to 'parent_container' if
|
||||
@@ -260,143 +260,143 @@ typedef void (*cmark_opaque_free_func) (cmark_syntax_extension *extension,
|
||||
|
||||
/** Free a cmark_syntax_extension.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_free (cmark_mem *mem, cmark_syntax_extension *extension);
|
||||
|
||||
/** Return a newly-constructed cmark_syntax_extension, named 'name'.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_syntax_extension *cmark_syntax_extension_new (const char *name);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_node_type cmark_syntax_extension_add_node(int is_inline);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension, int emphasis);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_open_block_func(cmark_syntax_extension *extension,
|
||||
cmark_open_block_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_match_block_func(cmark_syntax_extension *extension,
|
||||
cmark_match_block_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_match_inline_func(cmark_syntax_extension *extension,
|
||||
cmark_match_inline_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_inline_from_delim_func(cmark_syntax_extension *extension,
|
||||
cmark_inline_from_delim_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *extension,
|
||||
cmark_llist *special_chars);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_get_type_string_func(cmark_syntax_extension *extension,
|
||||
cmark_get_type_string_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_can_contain_func(cmark_syntax_extension *extension,
|
||||
cmark_can_contain_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_contains_inlines_func(cmark_syntax_extension *extension,
|
||||
cmark_contains_inlines_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_commonmark_render_func(cmark_syntax_extension *extension,
|
||||
cmark_common_render_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_plaintext_render_func(cmark_syntax_extension *extension,
|
||||
cmark_common_render_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_latex_render_func(cmark_syntax_extension *extension,
|
||||
cmark_common_render_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_man_render_func(cmark_syntax_extension *extension,
|
||||
cmark_common_render_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_html_render_func(cmark_syntax_extension *extension,
|
||||
cmark_html_render_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_html_filter_func(cmark_syntax_extension *extension,
|
||||
cmark_html_filter_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_commonmark_escape_func(cmark_syntax_extension *extension,
|
||||
cmark_commonmark_escape_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_private(cmark_syntax_extension *extension,
|
||||
void *priv,
|
||||
cmark_free_func free_func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void *cmark_syntax_extension_get_private(cmark_syntax_extension *extension);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_postprocess_func(cmark_syntax_extension *extension,
|
||||
cmark_postprocess_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
|
||||
cmark_opaque_free_func func);
|
||||
|
||||
/** See the documentation for 'cmark_syntax_extension'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_parser_set_backslash_ispunct_func(cmark_parser *parser,
|
||||
cmark_ispunct_func func);
|
||||
|
||||
/** Return the index of the line currently being parsed, starting with 1.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_get_line_number(cmark_parser *parser);
|
||||
|
||||
/** Return the offset in bytes in the line being processed.
|
||||
@@ -407,7 +407,7 @@ int cmark_parser_get_line_number(cmark_parser *parser);
|
||||
*
|
||||
* Here, offset will first be 0, then 5 (the index of the 'f' character).
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_get_offset(cmark_parser *parser);
|
||||
|
||||
/**
|
||||
@@ -441,7 +441,7 @@ int cmark_parser_get_offset(cmark_parser *parser);
|
||||
* cmark_parser_has_partially_consumed_tab() will now return
|
||||
* 'true'.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_get_column(cmark_parser *parser);
|
||||
|
||||
/** Return the absolute index in bytes of the first nonspace
|
||||
@@ -456,7 +456,7 @@ int cmark_parser_get_column(cmark_parser *parser);
|
||||
* 0 offset (16) first_nonspace (28)
|
||||
* ```
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_get_first_nonspace(cmark_parser *parser);
|
||||
|
||||
/** Return the absolute index of the first nonspace column coming after 'offset'
|
||||
@@ -466,7 +466,7 @@ int cmark_parser_get_first_nonspace(cmark_parser *parser);
|
||||
* See the documentation for cmark_parser_get_first_nonspace() and
|
||||
* cmark_parser_get_column() for more information.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_get_first_nonspace_column(cmark_parser *parser);
|
||||
|
||||
/** Return the difference between the values returned by
|
||||
@@ -476,7 +476,7 @@ int cmark_parser_get_first_nonspace_column(cmark_parser *parser);
|
||||
* This is not a byte offset, as it can count one tab as multiple
|
||||
* characters.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_get_indent(cmark_parser *parser);
|
||||
|
||||
/** Return 'true' if the line currently being processed has been entirely
|
||||
@@ -507,7 +507,7 @@ int cmark_parser_get_indent(cmark_parser *parser);
|
||||
*
|
||||
* At this point, this function will now return 'true'.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_is_blank(cmark_parser *parser);
|
||||
|
||||
/** Return 'true' if the value returned by cmark_parser_get_offset()
|
||||
@@ -516,13 +516,13 @@ int cmark_parser_is_blank(cmark_parser *parser);
|
||||
* See the documentation for cmark_parser_get_column() for more
|
||||
* information.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_has_partially_consumed_tab(cmark_parser *parser);
|
||||
|
||||
/** Return the length in bytes of the previously processed line, excluding potential
|
||||
* newline (\n) and carriage return (\r) trailing characters.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_get_last_line_length(cmark_parser *parser);
|
||||
|
||||
/** Add a child to 'parent' during the parsing process.
|
||||
@@ -531,7 +531,7 @@ int cmark_parser_get_last_line_length(cmark_parser *parser);
|
||||
* this function will back up till it hits a node that can, closing
|
||||
* blocks as appropriate.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_node*cmark_parser_add_child(cmark_parser *parser,
|
||||
cmark_node *parent,
|
||||
cmark_node_type block_type,
|
||||
@@ -542,14 +542,14 @@ cmark_node*cmark_parser_add_child(cmark_parser *parser,
|
||||
* See the documentation of cmark_parser_get_offset() and
|
||||
* cmark_parser_get_column() for more information.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_parser_advance_offset(cmark_parser *parser,
|
||||
const char *input,
|
||||
int count,
|
||||
int columns);
|
||||
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_parser_feed_reentrant(cmark_parser *parser, const char *buffer, size_t len);
|
||||
|
||||
/** Attach the syntax 'extension' to the 'parser', to provide extra syntax
|
||||
@@ -559,33 +559,33 @@ void cmark_parser_feed_reentrant(cmark_parser *parser, const char *buffer, size_
|
||||
* Returns 'true' if the 'extension' was successfully attached,
|
||||
* 'false' otherwise.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_parser_attach_syntax_extension(cmark_parser *parser, cmark_syntax_extension *extension);
|
||||
|
||||
/** Change the type of 'node'.
|
||||
*
|
||||
* Return 0 if the type could be changed, 1 otherwise.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_type(cmark_node *node, cmark_node_type type);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_type(cmark_node *node, cmark_node_type type);
|
||||
|
||||
/** Return the string content for all types of 'node'.
|
||||
* The pointer stays valid as long as 'node' isn't freed.
|
||||
*/
|
||||
CMARK_EXPORT const char *cmark_node_get_string_content(cmark_node *node);
|
||||
CMARK_GFM_EXPORT const char *cmark_node_get_string_content(cmark_node *node);
|
||||
|
||||
/** Set the string 'content' for all types of 'node'.
|
||||
* Copies 'content'.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_string_content(cmark_node *node, const char *content);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_string_content(cmark_node *node, const char *content);
|
||||
|
||||
/** Get the syntax extension responsible for the creation of 'node'.
|
||||
* Return NULL if 'node' was created because it matched standard syntax rules.
|
||||
*/
|
||||
CMARK_EXPORT cmark_syntax_extension *cmark_node_get_syntax_extension(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_syntax_extension *cmark_node_get_syntax_extension(cmark_node *node);
|
||||
|
||||
/** Set the syntax extension responsible for creating 'node'.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_syntax_extension(cmark_node *node,
|
||||
CMARK_GFM_EXPORT int cmark_node_set_syntax_extension(cmark_node *node,
|
||||
cmark_syntax_extension *extension);
|
||||
|
||||
/**
|
||||
@@ -600,63 +600,63 @@ CMARK_EXPORT int cmark_node_set_syntax_extension(cmark_node *node,
|
||||
typedef int (*cmark_inline_predicate)(int c);
|
||||
|
||||
/** Advance the current inline parsing offset */
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_inline_parser_advance_offset(cmark_inline_parser *parser);
|
||||
|
||||
/** Get the current inline parsing offset */
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_inline_parser_get_offset(cmark_inline_parser *parser);
|
||||
|
||||
/** Set the offset in bytes in the chunk being processed by the given inline parser.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_inline_parser_set_offset(cmark_inline_parser *parser, int offset);
|
||||
|
||||
/** Gets the cmark_chunk being operated on by the given inline parser.
|
||||
* Use cmark_inline_parser_get_offset to get our current position in the chunk.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
struct cmark_chunk *cmark_inline_parser_get_chunk(cmark_inline_parser *parser);
|
||||
|
||||
/** Returns 1 if the inline parser is currently in a bracket; pass 1 for 'image'
|
||||
* if you want to know about an image-type bracket, 0 for link-type. */
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_inline_parser_in_bracket(cmark_inline_parser *parser, int image);
|
||||
|
||||
/** Remove the last n characters from the last child of the given node.
|
||||
* This only works where all n characters are in the single last child, and the last
|
||||
* child is CMARK_NODE_TEXT.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_node_unput(cmark_node *node, int n);
|
||||
|
||||
|
||||
/** Get the character located at the current inline parsing offset
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
unsigned char cmark_inline_parser_peek_char(cmark_inline_parser *parser);
|
||||
|
||||
/** Get the character located 'pos' bytes in the current line.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
unsigned char cmark_inline_parser_peek_at(cmark_inline_parser *parser, int pos);
|
||||
|
||||
/** Whether the inline parser has reached the end of the current line
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_inline_parser_is_eof(cmark_inline_parser *parser);
|
||||
|
||||
/** Get the characters located after the current inline parsing offset
|
||||
* while 'pred' matches. Free after usage.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_inline_parser_take_while(cmark_inline_parser *parser, cmark_inline_predicate pred);
|
||||
|
||||
/** Push a delimiter on the delimiter stack.
|
||||
* See <<http://spec.commonmark.org/0.24/#phase-2-inline-structure> for
|
||||
* more information on the parameters
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_inline_parser_push_delimiter(cmark_inline_parser *parser,
|
||||
unsigned char c,
|
||||
int can_open,
|
||||
@@ -665,16 +665,16 @@ void cmark_inline_parser_push_delimiter(cmark_inline_parser *parser,
|
||||
|
||||
/** Remove 'delim' from the delimiter stack
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_inline_parser_remove_delimiter(cmark_inline_parser *parser, delimiter *delim);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
delimiter *cmark_inline_parser_get_last_delimiter(cmark_inline_parser *parser);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_inline_parser_get_line(cmark_inline_parser *parser);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_inline_parser_get_column(cmark_inline_parser *parser);
|
||||
|
||||
/** Convenience function to scan a given delimiter.
|
||||
@@ -691,7 +691,7 @@ int cmark_inline_parser_get_column(cmark_inline_parser *parser);
|
||||
* Returns the number of delimiters encountered, in the limit
|
||||
* of 'max_delims', and advances the inline parsing offset.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_inline_parser_scan_delimiters(cmark_inline_parser *parser,
|
||||
int max_delims,
|
||||
unsigned char c,
|
||||
@@ -700,16 +700,16 @@ int cmark_inline_parser_scan_delimiters(cmark_inline_parser *parser,
|
||||
int *punct_before,
|
||||
int *punct_after);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_manage_extensions_special_characters(cmark_parser *parser, int add);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_llist *cmark_parser_get_syntax_extensions(cmark_parser *parser);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_arena_push(void);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_arena_pop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef CMARK_CMARK_H
|
||||
#define CMARK_CMARK_H
|
||||
#ifndef CMARK_GFM_H
|
||||
#define CMARK_GFM_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "cmark_export.h"
|
||||
#include "cmark_version.h"
|
||||
#include "cmark-gfm_export.h"
|
||||
#include "cmark-gfm_version.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
* UTF-8-encoded string. It is the caller's responsibility
|
||||
* to free the returned buffer.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_markdown_to_html(const char *text, size_t len, int options);
|
||||
|
||||
/** ## Node Structure
|
||||
@@ -109,19 +109,19 @@ typedef struct cmark_mem {
|
||||
/** The default memory allocator; uses the system's calloc,
|
||||
* realloc and free.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_mem *cmark_get_default_mem_allocator();
|
||||
|
||||
/** An arena allocator; uses system calloc to allocate large
|
||||
* slabs of memory. Memory in these slabs is not reused at all.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_mem *cmark_get_arena_mem_allocator();
|
||||
|
||||
/** Resets the arena allocator, quickly returning all used memory
|
||||
* to the operating system.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_arena_reset(void);
|
||||
|
||||
/** Callback for freeing user data with a 'cmark_mem' context.
|
||||
@@ -151,7 +151,7 @@ typedef struct _cmark_llist
|
||||
/** Append an element to the linked list, return the possibly modified
|
||||
* head of the list.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_llist * cmark_llist_append (cmark_mem * mem,
|
||||
cmark_llist * head,
|
||||
void * data);
|
||||
@@ -159,14 +159,14 @@ cmark_llist * cmark_llist_append (cmark_mem * mem,
|
||||
/** Free the list starting with 'head', calling 'free_func' with the
|
||||
* data pointer of each of its elements
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_llist_free_full (cmark_mem * mem,
|
||||
cmark_llist * head,
|
||||
cmark_free_func free_func);
|
||||
|
||||
/** Free the list starting with 'head'
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_llist_free (cmark_mem * mem,
|
||||
cmark_llist * head);
|
||||
|
||||
@@ -178,18 +178,18 @@ void cmark_llist_free (cmark_mem * mem,
|
||||
* other required properties, which it is the caller's responsibility
|
||||
* to assign.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node *cmark_node_new(cmark_node_type type);
|
||||
CMARK_GFM_EXPORT cmark_node *cmark_node_new(cmark_node_type type);
|
||||
|
||||
/** Same as `cmark_node_new`, but explicitly listing the memory
|
||||
* allocator used to allocate the node. Note: be sure to use the same
|
||||
* allocator for every node in a tree, or bad things can happen.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node *cmark_node_new_with_mem(cmark_node_type type,
|
||||
CMARK_GFM_EXPORT cmark_node *cmark_node_new_with_mem(cmark_node_type type,
|
||||
cmark_mem *mem);
|
||||
|
||||
/** Frees the memory allocated for a node and any children.
|
||||
*/
|
||||
CMARK_EXPORT void cmark_node_free(cmark_node *node);
|
||||
CMARK_GFM_EXPORT void cmark_node_free(cmark_node *node);
|
||||
|
||||
/**
|
||||
* ## Tree Traversal
|
||||
@@ -198,24 +198,24 @@ CMARK_EXPORT void cmark_node_free(cmark_node *node);
|
||||
/** Returns the next node in the sequence after 'node', or NULL if
|
||||
* there is none.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node *cmark_node_next(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_node *cmark_node_next(cmark_node *node);
|
||||
|
||||
/** Returns the previous node in the sequence after 'node', or NULL if
|
||||
* there is none.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node *cmark_node_previous(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_node *cmark_node_previous(cmark_node *node);
|
||||
|
||||
/** Returns the parent of 'node', or NULL if there is none.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node *cmark_node_parent(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_node *cmark_node_parent(cmark_node *node);
|
||||
|
||||
/** Returns the first child of 'node', or NULL if 'node' has no children.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node *cmark_node_first_child(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_node *cmark_node_first_child(cmark_node *node);
|
||||
|
||||
/** Returns the last child of 'node', or NULL if 'node' has no children.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
|
||||
|
||||
/**
|
||||
* ## Iterator
|
||||
@@ -274,40 +274,40 @@ typedef enum {
|
||||
* The memory allocated for the iterator should be released using
|
||||
* 'cmark_iter_free' when it is no longer needed.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_iter *cmark_iter_new(cmark_node *root);
|
||||
|
||||
/** Frees the memory allocated for an iterator.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_iter_free(cmark_iter *iter);
|
||||
|
||||
/** Advances to the next node and returns the event type (`CMARK_EVENT_ENTER`,
|
||||
* `CMARK_EVENT_EXIT` or `CMARK_EVENT_DONE`).
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_event_type cmark_iter_next(cmark_iter *iter);
|
||||
|
||||
/** Returns the current node.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_node *cmark_iter_get_node(cmark_iter *iter);
|
||||
|
||||
/** Returns the current event type.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_event_type cmark_iter_get_event_type(cmark_iter *iter);
|
||||
|
||||
/** Returns the root node.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_node *cmark_iter_get_root(cmark_iter *iter);
|
||||
|
||||
/** Resets the iterator so that the current node is 'current' and
|
||||
* the event type is 'event_type'. The new current node must be a
|
||||
* descendant of the root node or the root node itself.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_iter_reset(cmark_iter *iter, cmark_node *current,
|
||||
cmark_event_type event_type);
|
||||
|
||||
@@ -317,42 +317,42 @@ void cmark_iter_reset(cmark_iter *iter, cmark_node *current,
|
||||
|
||||
/** Returns the user data of 'node'.
|
||||
*/
|
||||
CMARK_EXPORT void *cmark_node_get_user_data(cmark_node *node);
|
||||
CMARK_GFM_EXPORT void *cmark_node_get_user_data(cmark_node *node);
|
||||
|
||||
/** Sets arbitrary user data for 'node'. Returns 1 on success,
|
||||
* 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_user_data(cmark_node *node, void *user_data);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_user_data(cmark_node *node, void *user_data);
|
||||
|
||||
/** Set free function for user data */
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_node_set_user_data_free_func(cmark_node *node,
|
||||
cmark_free_func free_func);
|
||||
|
||||
/** Returns the type of 'node', or `CMARK_NODE_NONE` on error.
|
||||
*/
|
||||
CMARK_EXPORT cmark_node_type cmark_node_get_type(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_node_type cmark_node_get_type(cmark_node *node);
|
||||
|
||||
/** Like 'cmark_node_get_type', but returns a string representation
|
||||
of the type, or `"<unknown>"`.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
const char *cmark_node_get_type_string(cmark_node *node);
|
||||
|
||||
/** Returns the string contents of 'node', or an empty
|
||||
string if none is set. Returns NULL if called on a
|
||||
node that does not have string content.
|
||||
*/
|
||||
CMARK_EXPORT const char *cmark_node_get_literal(cmark_node *node);
|
||||
CMARK_GFM_EXPORT const char *cmark_node_get_literal(cmark_node *node);
|
||||
|
||||
/** Sets the string contents of 'node'. Returns 1 on success,
|
||||
* 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_literal(cmark_node *node, const char *content);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_literal(cmark_node *node, const char *content);
|
||||
|
||||
/** Returns the heading level of 'node', or 0 if 'node' is not a heading.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_heading_level(cmark_node *node);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_heading_level(cmark_node *node);
|
||||
|
||||
/* For backwards compatibility */
|
||||
#define cmark_node_get_header_level cmark_node_get_heading_level
|
||||
@@ -360,126 +360,126 @@ CMARK_EXPORT int cmark_node_get_heading_level(cmark_node *node);
|
||||
|
||||
/** Sets the heading level of 'node', returning 1 on success and 0 on error.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_heading_level(cmark_node *node, int level);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_heading_level(cmark_node *node, int level);
|
||||
|
||||
/** Returns the list type of 'node', or `CMARK_NO_LIST` if 'node'
|
||||
* is not a list.
|
||||
*/
|
||||
CMARK_EXPORT cmark_list_type cmark_node_get_list_type(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_list_type cmark_node_get_list_type(cmark_node *node);
|
||||
|
||||
/** Sets the list type of 'node', returning 1 on success and 0 on error.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_list_type(cmark_node *node,
|
||||
CMARK_GFM_EXPORT int cmark_node_set_list_type(cmark_node *node,
|
||||
cmark_list_type type);
|
||||
|
||||
/** Returns the list delimiter type of 'node', or `CMARK_NO_DELIM` if 'node'
|
||||
* is not a list.
|
||||
*/
|
||||
CMARK_EXPORT cmark_delim_type cmark_node_get_list_delim(cmark_node *node);
|
||||
CMARK_GFM_EXPORT cmark_delim_type cmark_node_get_list_delim(cmark_node *node);
|
||||
|
||||
/** Sets the list delimiter type of 'node', returning 1 on success and 0
|
||||
* on error.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_list_delim(cmark_node *node,
|
||||
CMARK_GFM_EXPORT int cmark_node_set_list_delim(cmark_node *node,
|
||||
cmark_delim_type delim);
|
||||
|
||||
/** Returns starting number of 'node', if it is an ordered list, otherwise 0.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_list_start(cmark_node *node);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_list_start(cmark_node *node);
|
||||
|
||||
/** Sets starting number of 'node', if it is an ordered list. Returns 1
|
||||
* on success, 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_list_start(cmark_node *node, int start);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_list_start(cmark_node *node, int start);
|
||||
|
||||
/** Returns 1 if 'node' is a tight list, 0 otherwise.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_list_tight(cmark_node *node);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_list_tight(cmark_node *node);
|
||||
|
||||
/** Sets the "tightness" of a list. Returns 1 on success, 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_list_tight(cmark_node *node, int tight);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_list_tight(cmark_node *node, int tight);
|
||||
|
||||
/** Returns the info string from a fenced code block.
|
||||
*/
|
||||
CMARK_EXPORT const char *cmark_node_get_fence_info(cmark_node *node);
|
||||
CMARK_GFM_EXPORT const char *cmark_node_get_fence_info(cmark_node *node);
|
||||
|
||||
/** Sets the info string in a fenced code block, returning 1 on
|
||||
* success and 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_fence_info(cmark_node *node, const char *info);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_fence_info(cmark_node *node, const char *info);
|
||||
|
||||
/** Sets code blocks fencing details
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_fenced(cmark_node * node, int fenced,
|
||||
CMARK_GFM_EXPORT int cmark_node_set_fenced(cmark_node * node, int fenced,
|
||||
int length, int offset, char character);
|
||||
|
||||
/** Returns code blocks fencing details
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_fenced(cmark_node *node, int *length, int *offset, char *character);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_fenced(cmark_node *node, int *length, int *offset, char *character);
|
||||
|
||||
/** Returns the URL of a link or image 'node', or an empty string
|
||||
if no URL is set. Returns NULL if called on a node that is
|
||||
not a link or image.
|
||||
*/
|
||||
CMARK_EXPORT const char *cmark_node_get_url(cmark_node *node);
|
||||
CMARK_GFM_EXPORT const char *cmark_node_get_url(cmark_node *node);
|
||||
|
||||
/** Sets the URL of a link or image 'node'. Returns 1 on success,
|
||||
* 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_url(cmark_node *node, const char *url);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_url(cmark_node *node, const char *url);
|
||||
|
||||
/** Returns the title of a link or image 'node', or an empty
|
||||
string if no title is set. Returns NULL if called on a node
|
||||
that is not a link or image.
|
||||
*/
|
||||
CMARK_EXPORT const char *cmark_node_get_title(cmark_node *node);
|
||||
CMARK_GFM_EXPORT const char *cmark_node_get_title(cmark_node *node);
|
||||
|
||||
/** Sets the title of a link or image 'node'. Returns 1 on success,
|
||||
* 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_title(cmark_node *node, const char *title);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_title(cmark_node *node, const char *title);
|
||||
|
||||
/** Returns the literal "on enter" text for a custom 'node', or
|
||||
an empty string if no on_enter is set. Returns NULL if called
|
||||
on a non-custom node.
|
||||
*/
|
||||
CMARK_EXPORT const char *cmark_node_get_on_enter(cmark_node *node);
|
||||
CMARK_GFM_EXPORT const char *cmark_node_get_on_enter(cmark_node *node);
|
||||
|
||||
/** Sets the literal text to render "on enter" for a custom 'node'.
|
||||
Any children of the node will be rendered after this text.
|
||||
Returns 1 on success 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_on_enter(cmark_node *node,
|
||||
CMARK_GFM_EXPORT int cmark_node_set_on_enter(cmark_node *node,
|
||||
const char *on_enter);
|
||||
|
||||
/** Returns the literal "on exit" text for a custom 'node', or
|
||||
an empty string if no on_exit is set. Returns NULL if
|
||||
called on a non-custom node.
|
||||
*/
|
||||
CMARK_EXPORT const char *cmark_node_get_on_exit(cmark_node *node);
|
||||
CMARK_GFM_EXPORT const char *cmark_node_get_on_exit(cmark_node *node);
|
||||
|
||||
/** Sets the literal text to render "on exit" for a custom 'node'.
|
||||
Any children of the node will be rendered before this text.
|
||||
Returns 1 on success 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_set_on_exit(cmark_node *node, const char *on_exit);
|
||||
CMARK_GFM_EXPORT int cmark_node_set_on_exit(cmark_node *node, const char *on_exit);
|
||||
|
||||
/** Returns the line on which 'node' begins.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_start_line(cmark_node *node);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_start_line(cmark_node *node);
|
||||
|
||||
/** Returns the column at which 'node' begins.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_start_column(cmark_node *node);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_start_column(cmark_node *node);
|
||||
|
||||
/** Returns the line on which 'node' ends.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_end_line(cmark_node *node);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_end_line(cmark_node *node);
|
||||
|
||||
/** Returns the column at which 'node' ends.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_get_end_column(cmark_node *node);
|
||||
CMARK_GFM_EXPORT int cmark_node_get_end_column(cmark_node *node);
|
||||
|
||||
/**
|
||||
* ## Tree Manipulation
|
||||
@@ -488,40 +488,40 @@ CMARK_EXPORT int cmark_node_get_end_column(cmark_node *node);
|
||||
/** Unlinks a 'node', removing it from the tree, but not freeing its
|
||||
* memory. (Use 'cmark_node_free' for that.)
|
||||
*/
|
||||
CMARK_EXPORT void cmark_node_unlink(cmark_node *node);
|
||||
CMARK_GFM_EXPORT void cmark_node_unlink(cmark_node *node);
|
||||
|
||||
/** Inserts 'sibling' before 'node'. Returns 1 on success, 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_insert_before(cmark_node *node,
|
||||
CMARK_GFM_EXPORT int cmark_node_insert_before(cmark_node *node,
|
||||
cmark_node *sibling);
|
||||
|
||||
/** Inserts 'sibling' after 'node'. Returns 1 on success, 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
|
||||
CMARK_GFM_EXPORT int cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
|
||||
|
||||
/** Replaces 'oldnode' with 'newnode' and unlinks 'oldnode' (but does
|
||||
* not free its memory).
|
||||
* Returns 1 on success, 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_replace(cmark_node *oldnode, cmark_node *newnode);
|
||||
CMARK_GFM_EXPORT int cmark_node_replace(cmark_node *oldnode, cmark_node *newnode);
|
||||
|
||||
/** Adds 'child' to the beginning of the children of 'node'.
|
||||
* Returns 1 on success, 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_prepend_child(cmark_node *node, cmark_node *child);
|
||||
CMARK_GFM_EXPORT int cmark_node_prepend_child(cmark_node *node, cmark_node *child);
|
||||
|
||||
/** Adds 'child' to the end of the children of 'node'.
|
||||
* Returns 1 on success, 0 on failure.
|
||||
*/
|
||||
CMARK_EXPORT int cmark_node_append_child(cmark_node *node, cmark_node *child);
|
||||
CMARK_GFM_EXPORT int cmark_node_append_child(cmark_node *node, cmark_node *child);
|
||||
|
||||
/** Consolidates adjacent text nodes.
|
||||
*/
|
||||
CMARK_EXPORT void cmark_consolidate_text_nodes(cmark_node *root);
|
||||
CMARK_GFM_EXPORT void cmark_consolidate_text_nodes(cmark_node *root);
|
||||
|
||||
/** Ensures a node and all its children own their own chunk memory.
|
||||
*/
|
||||
CMARK_EXPORT void cmark_node_own(cmark_node *root);
|
||||
CMARK_GFM_EXPORT void cmark_node_own(cmark_node *root);
|
||||
|
||||
/**
|
||||
* ## Parsing
|
||||
@@ -547,27 +547,27 @@ CMARK_EXPORT void cmark_node_own(cmark_node *root);
|
||||
|
||||
/** Creates a new parser object.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_parser *cmark_parser_new(int options);
|
||||
|
||||
/** Creates a new parser object with the given memory allocator
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_parser *cmark_parser_new_with_mem(int options, cmark_mem *mem);
|
||||
|
||||
/** Frees memory allocated for a parser object.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_parser_free(cmark_parser *parser);
|
||||
|
||||
/** Feeds a string of length 'len' to 'parser'.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_parser_feed(cmark_parser *parser, const char *buffer, size_t len);
|
||||
|
||||
/** Finish parsing and return a pointer to a tree of nodes.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_node *cmark_parser_finish(cmark_parser *parser);
|
||||
|
||||
/** Parse a CommonMark document in 'buffer' of length 'len'.
|
||||
@@ -575,14 +575,14 @@ cmark_node *cmark_parser_finish(cmark_parser *parser);
|
||||
* the node tree should be released using 'cmark_node_free'
|
||||
* when it is no longer needed.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_node *cmark_parse_document(const char *buffer, size_t len, int options);
|
||||
|
||||
/** Parse a CommonMark document in file 'f', returning a pointer to
|
||||
* a tree of nodes. The memory allocated for the node tree should be
|
||||
* released using 'cmark_node_free' when it is no longer needed.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_node *cmark_parse_file(FILE *f, int options);
|
||||
|
||||
/**
|
||||
@@ -592,74 +592,74 @@ cmark_node *cmark_parse_file(FILE *f, int options);
|
||||
/** Render a 'node' tree as XML. It is the caller's responsibility
|
||||
* to free the returned buffer.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_xml(cmark_node *root, int options);
|
||||
|
||||
/** As for 'cmark_render_xml', but specifying the allocator to use for
|
||||
* the resulting string.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_xml_with_mem(cmark_node *root, int options, cmark_mem *mem);
|
||||
|
||||
/** Render a 'node' tree as an HTML fragment. It is up to the user
|
||||
* to add an appropriate header and footer. It is the caller's
|
||||
* responsibility to free the returned buffer.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_html(cmark_node *root, int options, cmark_llist *extensions);
|
||||
|
||||
/** As for 'cmark_render_html', but specifying the allocator to use for
|
||||
* the resulting string.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_html_with_mem(cmark_node *root, int options, cmark_llist *extensions, cmark_mem *mem);
|
||||
|
||||
/** Render a 'node' tree as a groff man page, without the header.
|
||||
* It is the caller's responsibility to free the returned buffer.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_man(cmark_node *root, int options, int width);
|
||||
|
||||
/** As for 'cmark_render_man', but specifying the allocator to use for
|
||||
* the resulting string.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_man_with_mem(cmark_node *root, int options, int width, cmark_mem *mem);
|
||||
|
||||
/** Render a 'node' tree as a commonmark document.
|
||||
* It is the caller's responsibility to free the returned buffer.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_commonmark(cmark_node *root, int options, int width);
|
||||
|
||||
/** As for 'cmark_render_commonmark', but specifying the allocator to use for
|
||||
* the resulting string.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_commonmark_with_mem(cmark_node *root, int options, int width, cmark_mem *mem);
|
||||
|
||||
/** Render a 'node' tree as a plain text document.
|
||||
* It is the caller's responsibility to free the returned buffer.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_plaintext(cmark_node *root, int options, int width);
|
||||
|
||||
/** As for 'cmark_render_plaintext', but specifying the allocator to use for
|
||||
* the resulting string.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_plaintext_with_mem(cmark_node *root, int options, int width, cmark_mem *mem);
|
||||
|
||||
/** Render a 'node' tree as a LaTeX document.
|
||||
* It is the caller's responsibility to free the returned buffer.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_latex(cmark_node *root, int options, int width);
|
||||
|
||||
/** As for 'cmark_render_latex', but specifying the allocator to use for
|
||||
* the resulting string.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
char *cmark_render_latex_with_mem(cmark_node *root, int options, int width, cmark_mem *mem);
|
||||
|
||||
/**
|
||||
@@ -751,13 +751,13 @@ char *cmark_render_latex_with_mem(cmark_node *root, int options, int width, cmar
|
||||
*
|
||||
* In hexadecimal format, the number 0x010203 represents version 1.2.3.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_version(void);
|
||||
|
||||
/** The library version string for runtime checks. Also available as
|
||||
* macro CMARK_VERSION_STRING for compile time checks.
|
||||
*/
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
const char *cmark_version_string(void);
|
||||
|
||||
/** # AUTHORS
|
||||
7
src/cmark-gfm_version.h.in
Normal file
7
src/cmark-gfm_version.h.in
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef CMARK_GFM_VERSION_H
|
||||
#define CMARK_GFM_VERSION_H
|
||||
|
||||
#define CMARK_GFM_VERSION ((@PROJECT_VERSION_MAJOR@ << 24) | (@PROJECT_VERSION_MINOR@ << 16) | (@PROJECT_VERSION_PATCH@ << 8) | @PROJECT_VERSION_GFM@)
|
||||
#define CMARK_GFM_VERSION_STRING "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.gfm.@PROJECT_VERSION_GFM@"
|
||||
|
||||
#endif
|
||||
@@ -4,15 +4,15 @@
|
||||
#include "registry.h"
|
||||
#include "node.h"
|
||||
#include "houdini.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.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; }
|
||||
int cmark_version() { return CMARK_GFM_VERSION; }
|
||||
|
||||
const char *cmark_version_string() { return CMARK_VERSION_STRING; }
|
||||
const char *cmark_version_string() { return CMARK_GFM_VERSION_STRING; }
|
||||
|
||||
static void *xcalloc(size_t nmem, size_t size) {
|
||||
void *ptr = calloc(nmem, size);
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmark_export.h"
|
||||
#include "cmark-gfm_export.h"
|
||||
|
||||
/** Locale-independent versions of functions from ctype.h.
|
||||
* We want cmark to behave the same no matter what the system locale.
|
||||
*/
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_isspace(char c);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_ispunct(char c);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_isalnum(char c);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_isdigit(char c);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_isalpha(char c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef CMARK_VERSION_H
|
||||
#define CMARK_VERSION_H
|
||||
|
||||
#define CMARK_VERSION ((@PROJECT_VERSION_MAJOR@ << 24) | (@PROJECT_VERSION_MINOR@ << 16) | (@PROJECT_VERSION_PATCH@ << 8) | @PROJECT_VERSION_GFM@)
|
||||
#define CMARK_VERSION_STRING "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.gfm.@PROJECT_VERSION_GFM@"
|
||||
#define CMARK_GFM_VERSION @PROJECT_VERSION_GFM@
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "node.h"
|
||||
#include "buffer.h"
|
||||
#include "utf8.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "parser.h"
|
||||
#include "footnotes.h"
|
||||
#include "inlines.h"
|
||||
|
||||
@@ -31,22 +31,22 @@ extern "C" {
|
||||
#define HOUDINI_ESCAPED_SIZE(x) (((x)*12) / 10)
|
||||
#define HOUDINI_UNESCAPED_SIZE(x) (x)
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
bufsize_t houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src,
|
||||
bufsize_t size);
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int houdini_escape_html(cmark_strbuf *ob, const uint8_t *src,
|
||||
bufsize_t size);
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int houdini_escape_html0(cmark_strbuf *ob, const uint8_t *src,
|
||||
bufsize_t size, int secure);
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int houdini_unescape_html(cmark_strbuf *ob, const uint8_t *src,
|
||||
bufsize_t size);
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void houdini_unescape_html_f(cmark_strbuf *ob, const uint8_t *src,
|
||||
bufsize_t size);
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int houdini_escape_href(cmark_strbuf *ob, const uint8_t *src,
|
||||
bufsize_t size);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <assert.h>
|
||||
#include "cmark_ctype.h"
|
||||
#include "config.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "houdini.h"
|
||||
#include "scanners.h"
|
||||
#include "syntax_extension.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "node.h"
|
||||
#include "parser.h"
|
||||
#include "references.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "houdini.h"
|
||||
#include "utf8.h"
|
||||
#include "scanners.h"
|
||||
|
||||
@@ -10,7 +10,7 @@ extern "C" {
|
||||
cmark_chunk cmark_clean_url(cmark_mem *mem, cmark_chunk *url);
|
||||
cmark_chunk cmark_clean_title(cmark_mem *mem, cmark_chunk *title);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_parse_inlines(cmark_parser *parser,
|
||||
cmark_node *parent,
|
||||
cmark_map *refmap,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "node.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "iterator.h"
|
||||
|
||||
cmark_iter *cmark_iter_new(cmark_node *root) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "memory.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "node.h"
|
||||
#include "buffer.h"
|
||||
#include "utf8.h"
|
||||
|
||||
@@ -6,5 +6,5 @@ includedir=@CMAKE_INSTALL_PREFIX@/include
|
||||
Name: libcmark-gfm
|
||||
Description: CommonMark parsing, rendering, and manipulation with GitHub Flavored Markdown extensions
|
||||
Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} -lcmark-gfm -lcmark-gfmextensions
|
||||
Libs: -L${libdir} -lcmark-gfm -lcmark-gfm-extensions
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
|
||||
cmark_llist *cmark_llist_append(cmark_mem *mem, cmark_llist *head, void *data) {
|
||||
cmark_llist *tmp;
|
||||
|
||||
12
src/main.c
12
src/main.c
@@ -4,14 +4,14 @@
|
||||
#include <errno.h>
|
||||
#include "config.h"
|
||||
#include "memory.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "node.h"
|
||||
#include "cmark_extension_api.h"
|
||||
#include "cmark-gfm-extension_api.h"
|
||||
#include "syntax_extension.h"
|
||||
#include "parser.h"
|
||||
#include "registry.h"
|
||||
|
||||
#include "../extensions/core-extensions.h"
|
||||
#include "../extensions/cmark-gfm-core-extensions.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include <io.h>
|
||||
@@ -118,7 +118,7 @@ int main(int argc, char *argv[]) {
|
||||
int options = CMARK_OPT_DEFAULT;
|
||||
int res = 1;
|
||||
|
||||
core_extensions_ensure_registered();
|
||||
cmark_gfm_core_extensions_ensure_registered();
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
_setmode(_fileno(stdin), _O_BINARY);
|
||||
@@ -129,8 +129,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "--version") == 0) {
|
||||
printf("cmark %s", CMARK_VERSION_STRING);
|
||||
printf(" - CommonMark converter\n(C) 2014-2016 John MacFarlane\n");
|
||||
printf("cmark-gfm %s", CMARK_GFM_VERSION_STRING);
|
||||
printf(" - CommonMark with GitHub Flavored Markdown converter\n(C) 2014-2016 John MacFarlane\n");
|
||||
goto success;
|
||||
} else if (strcmp(argv[i], "--list-extensions") == 0) {
|
||||
print_extensions();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "node.h"
|
||||
#include "buffer.h"
|
||||
#include "utf8.h"
|
||||
|
||||
@@ -8,8 +8,8 @@ extern "C" {
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark_extension_api.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "cmark-gfm-extension_api.h"
|
||||
#include "buffer.h"
|
||||
#include "chunk.h"
|
||||
|
||||
@@ -89,7 +89,7 @@ struct cmark_node {
|
||||
static CMARK_INLINE cmark_mem *cmark_node_mem(cmark_node *node) {
|
||||
return node->content.mem;
|
||||
}
|
||||
CMARK_EXPORT int cmark_node_check(cmark_node *node, FILE *out);
|
||||
CMARK_GFM_EXPORT int cmark_node_check(cmark_node *node, FILE *out);
|
||||
|
||||
static CMARK_INLINE bool CMARK_NODE_TYPE_BLOCK_P(cmark_node_type node_type) {
|
||||
return (node_type & CMARK_NODE_TYPE_MASK) == CMARK_NODE_TYPE_BLOCK;
|
||||
@@ -107,7 +107,7 @@ static CMARK_INLINE bool CMARK_NODE_INLINE_P(cmark_node *node) {
|
||||
return node != NULL && CMARK_NODE_TYPE_INLINE_P((cmark_node_type) node->type);
|
||||
}
|
||||
|
||||
CMARK_EXPORT bool cmark_node_can_contain_type(cmark_node *node, cmark_node_type child_type);
|
||||
CMARK_GFM_EXPORT bool cmark_node_can_contain_type(cmark_node *node, cmark_node_type child_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark_extension_api.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "cmark-gfm-extension_api.h"
|
||||
|
||||
/**
|
||||
* cmark_plugin:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "parser.h"
|
||||
#include "references.h"
|
||||
#include "inlines.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "syntax_extension.h"
|
||||
#include "registry.h"
|
||||
#include "plugin.h"
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "plugin.h"
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_register_plugin(cmark_plugin_init_func reg_fn);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_release_plugins(void);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
cmark_llist *cmark_list_syntax_extensions(cmark_mem *mem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "buffer.h"
|
||||
#include "chunk.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "utf8.h"
|
||||
#include "render.h"
|
||||
#include "node.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CMARK_SCANNERS_H
|
||||
#define CMARK_SCANNERS_H
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "chunk.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "syntax_extension.h"
|
||||
#include "buffer.h"
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef CMARK_SYNTAX_EXTENSION_H
|
||||
#define CMARK_SYNTAX_EXTENSION_H
|
||||
|
||||
#include "cmark.h"
|
||||
#include "cmark_extension_api.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "cmark-gfm-extension_api.h"
|
||||
#include "config.h"
|
||||
|
||||
struct cmark_syntax_extension {
|
||||
|
||||
12
src/utf8.h
12
src/utf8.h
@@ -8,24 +8,24 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_utf8proc_case_fold(cmark_strbuf *dest, const uint8_t *str,
|
||||
bufsize_t len);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_utf8proc_encode_char(int32_t uc, cmark_strbuf *buf);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_utf8proc_iterate(const uint8_t *str, bufsize_t str_len, int32_t *dst);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
void cmark_utf8proc_check(cmark_strbuf *dest, const uint8_t *line,
|
||||
bufsize_t size);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_utf8proc_is_space(int32_t uc);
|
||||
|
||||
CMARK_EXPORT
|
||||
CMARK_GFM_EXPORT
|
||||
int cmark_utf8proc_is_punctuation(int32_t uc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
#include "node.h"
|
||||
#include "buffer.h"
|
||||
#include "houdini.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "cmark.h"
|
||||
#include "cmark-gfm.h"
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
int options = 0;
|
||||
|
||||
@@ -12,7 +12,7 @@ def pipe_through_prog(prog, text):
|
||||
return [p1.returncode, result.decode('utf-8'), err]
|
||||
|
||||
def parse(lib, extlib, text, extensions):
|
||||
core_extensions_ensure_registered = extlib.core_extensions_ensure_registered
|
||||
cmark_gfm_core_extensions_ensure_registered = extlib.cmark_gfm_core_extensions_ensure_registered
|
||||
|
||||
find_syntax_extension = lib.cmark_find_syntax_extension
|
||||
find_syntax_extension.restype = c_void_p
|
||||
@@ -32,7 +32,7 @@ def parse(lib, extlib, text, extensions):
|
||||
parser_finish.restype = c_void_p
|
||||
parser_finish.argtypes = [c_void_p]
|
||||
|
||||
core_extensions_ensure_registered()
|
||||
cmark_gfm_core_extensions_ensure_registered()
|
||||
|
||||
parser = parser_new(0)
|
||||
for e in set(extensions):
|
||||
@@ -97,7 +97,7 @@ class CMark:
|
||||
break
|
||||
cmark = CDLL(libpath)
|
||||
extlib = CDLL(os.path.join(
|
||||
library_dir, "..", "extensions", prefix + "cmark-gfmextensions" + suffix))
|
||||
library_dir, "..", "extensions", prefix + "cmark-gfm-extensions" + suffix))
|
||||
self.to_html = lambda x, exts=[]: to_html(cmark, extlib, x, exts + self.extensions)
|
||||
self.to_commonmark = lambda x, exts=[]: to_commonmark(cmark, extlib, x, exts + self.extensions)
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#
|
||||
# Example for using the shared library from python.
|
||||
# Will work with either python 2 or python 3.
|
||||
# Requires cmark-gfm and cmark-gfmextensions libraries to be installed.
|
||||
# Requires cmark-gfm and cmark-gfm-extensions libraries to be installed.
|
||||
#
|
||||
# This particular example uses the GitHub extensions from the gfmextensions
|
||||
# This particular example uses the GitHub extensions from the gfm-extensions
|
||||
# library. EXTENSIONS specifies which to use, and the sample shows how to
|
||||
# connect them into a parser.
|
||||
#
|
||||
@@ -15,13 +15,13 @@ import ctypes
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
libname = 'libcmark-gfm.dylib'
|
||||
extname = 'libcmark-gfmextensions.dylib'
|
||||
extname = 'libcmark-gfm-extensions.dylib'
|
||||
elif sys.platform == 'win32':
|
||||
libname = 'cmark-gfm.dll'
|
||||
extname = 'cmark-gfmextensions.dll'
|
||||
extname = 'cmark-gfm-extensions.dll'
|
||||
else:
|
||||
libname = 'libcmark-gfm.so'
|
||||
extname = 'libcmark-gfmextensions.so'
|
||||
extname = 'libcmark-gfm-extensions.so'
|
||||
cmark = ctypes.CDLL(libname)
|
||||
cmark_ext = ctypes.CDLL(extname)
|
||||
|
||||
@@ -76,7 +76,7 @@ F_cmark_render_html.argtypes = (ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p)
|
||||
|
||||
|
||||
# Set up the libcmark-gfm library and its extensions
|
||||
F_register = cmark_ext.core_extensions_ensure_registered
|
||||
F_register = cmark_ext.cmark_gfm_core_extensions_ensure_registered
|
||||
F_register.restype = None
|
||||
F_register.argtypes = ( )
|
||||
F_register()
|
||||
|
||||
Reference in New Issue
Block a user