Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
endif()

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_STATIC "Build static libcmarkly library" ON)
option(CMARK_SHARED "Build shared libcmarkly library" ON)
option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF)
option(CMARK_FUZZ_QUADRATIC "Build quadratic fuzzing harness" OFF)

Expand Down
4 changes: 2 additions & 2 deletions api_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ include_directories(
${PROJECT_BINARY_DIR}/extensions
)
if(CMARK_SHARED)
target_link_libraries(api_test libcmark-gfm-extensions libcmark-gfm)
target_link_libraries(api_test libcmarkly-extensions libcmarkly)
else()
target_link_libraries(api_test libcmark-gfm-extensions_static libcmark-gfm_static)
target_link_libraries(api_test libcmarkly-extensions_static libcmarkly_static)
endif()

# Compiler flags
Expand Down
20 changes: 9 additions & 11 deletions extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(LIBRARY "libcmark-gfm-extensions")
set(STATICLIBRARY "libcmark-gfm-extensions_static")
set(LIBRARY "libcmarkly-extensions")
set(STATICLIBRARY "libcmarkly-extensions_static")
set(LIBRARY_SOURCES
core-extensions.c
table.c
Expand All @@ -26,19 +26,18 @@ if (CMARK_SHARED)
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})

set_target_properties(${LIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions"
DEFINE_SYMBOL "cmark-gfm"
OUTPUT_NAME "cmarkly-extensions"
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
VERSION ${PROJECT_VERSION})

set_property(TARGET ${LIBRARY}
APPEND PROPERTY MACOSX_RPATH true)

# Avoid name clash between PROGRAM and LIBRARY pdb files.
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm-extensions_dll)
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmarkly-extensions_dll)

list(APPEND CMARK_INSTALL ${LIBRARY})
target_link_libraries(${LIBRARY} libcmark-gfm)
target_link_libraries(${LIBRARY} libcmarkly)

endif()

Expand All @@ -47,16 +46,15 @@ if (CMARK_STATIC)

set_target_properties(${STATICLIBRARY} PROPERTIES
COMPILE_FLAGS "-DCMARK_GFM_STATIC_DEFINE -DCMARK_GFM_EXTENSIONS_STATIC_DEFINE"
DEFINE_SYMBOL "cmark-gfm"
POSITION_INDEPENDENT_CODE ON)

if (MSVC)
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions_static"
OUTPUT_NAME "cmarkly-extensions_static"
VERSION ${PROJECT_VERSION})
else()
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions"
OUTPUT_NAME "cmarkly-extensions"
VERSION ${PROJECT_VERSION})
endif(MSVC)

Expand All @@ -67,7 +65,7 @@ set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)

include (InstallRequiredSystemLibraries)
install(TARGETS ${CMARK_INSTALL}
EXPORT cmark-gfm-extensions
EXPORT cmarkly-extensions
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
Expand All @@ -79,7 +77,7 @@ if (CMARK_SHARED OR CMARK_STATIC)
DESTINATION include
)

install(EXPORT cmark-gfm-extensions DESTINATION lib${LIB_SUFFIX}/cmake-gfm-extensions)
install(EXPORT cmarkly-extensions DESTINATION lib${LIB_SUFFIX}/cmake/cmarkly-extensions)
endif()

# Feature tests
Expand Down
4 changes: 2 additions & 2 deletions fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ macro(fuzzer name)
COMPILE_FLAGS "-fsanitize=fuzzer"
LINK_FLAGS "-fsanitize=fuzzer")
if(CMARK_SHARED)
target_link_libraries(${name} libcmark-gfm-extensions libcmark-gfm)
target_link_libraries(${name} libcmarkly-extensions libcmarkly)
elseif(CMARK_STATIC)
target_link_libraries(${name} libcmark-gfm-extensions_static libcmark-gfm_static)
target_link_libraries(${name} libcmarkly-extensions_static libcmarkly_static)
endif()
endmacro()

Expand Down
4 changes: 2 additions & 2 deletions man/make_man_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
sysname = platform.system()

if sysname == 'Darwin':
cmark = CDLL("build/src/libcmark-gfm.dylib")
cmark = CDLL("build/src/libcmarkly.dylib")
else:
cmark = CDLL("build/src/libcmark-gfm.so")
cmark = CDLL("build/src/libcmarkly.so")

parse_document = cmark.cmark_parse_document
parse_document.restype = c_void_p
Expand Down
43 changes: 33 additions & 10 deletions README.md → readme.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
cmark-gfm
=========
# CMarkly

![Actions CI](https://github.com/github/cmark-gfm/actions/workflows/ci.yml/badge.svg)
![Actions CI](https://github.com/socketry/cmarkly/actions/workflows/ci.yml/badge.svg)

`cmark-gfm` is an extended version of the C reference implementation of
[CommonMark], a rationalized version of Markdown syntax with a spec. This
repository adds GitHub Flavored Markdown extensions to
[the upstream implementation], as defined in [the spec].
`CMarkly` is [Markly]'s maintained fork of [GitHub's `cmark-gfm`]. It adds
functionality needed by Markly while remaining based on GitHub's implementation
of GitHub Flavored Markdown.

The rest of the README is preserved as-is from the upstream source. Note that
the library and binaries produced by this fork are suffixed with `-gfm` in
order to distinguish them from the upstream.
The existing `cmark-gfm` C API, headers, and command retain their original names
for source compatibility and to keep synchronizing upstream changes
straightforward. The libraries, pkg-config metadata, and CMake targets use the
`cmarkly` name to distinguish this independently maintained fork from its
upstream project.

## Maintained Differences

Compared with GitHub's `cmark-gfm`, CMarkly:

- Accepts `:` in HTML tag names, supporting XML namespace prefixes such as
`<svg:circle>`.
- Omits the trailing newline when rendering an inline node by itself.
- Reports accurate end-line source positions for single-line and multi-line HTML
blocks.
- Supports opt-in front matter parsing through `CMARK_OPT_FRONT_MATTER`, exposed
as `CMARK_NODE_FRONT_MATTER` nodes.
- Supports opt-in language prefixes for inline code, such as `` ruby:`Object.new` ``,
through `CMARK_OPT_INLINE_CODE_INFO` and the code-info accessors.
- Provides `cmark_node_clone` for independently cloning complete node trees,
including supported extension metadata and footnote relationships. User data
is intentionally not copied.

The rest of the README is preserved as-is from the upstream source. References
to `cmark-gfm` below describe the compatible API, headers, and command inherited
from upstream.

---

Expand Down Expand Up @@ -194,6 +215,8 @@ Nick Wellnhofer contributed many improvements, including
most of the C library's API and its test harness.

[benchmarks]: benchmarks.md
[Markly]: https://github.com/socketry/markly
[GitHub's `cmark-gfm`]: https://github.com/github/cmark-gfm
[the spec]: https://github.github.com/gfm/
[the upstream implementation]: https://github.com/jgm/cmark
[CommonMark]: http://commonmark.org
Expand Down
26 changes: 13 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ endif()

include(GNUInstallDirs)

set(LIBRARY "libcmark-gfm")
set(STATICLIBRARY "libcmark-gfm_static")
set(LIBRARY "libcmarkly")
set(STATICLIBRARY "libcmarkly_static")
set(HEADERS
cmark-gfm.h
cmark-gfm-extension_api.h
Expand Down Expand Up @@ -79,9 +79,9 @@ CHECK_FILE_OFFSET_BITS()
add_executable(${PROGRAM} ${PROGRAM_SOURCES})

if(CMARK_SHARED)
target_link_libraries(${PROGRAM} libcmark-gfm-extensions libcmark-gfm)
target_link_libraries(${PROGRAM} libcmarkly-extensions libcmarkly)
elseif(CMARK_STATIC)
target_link_libraries(${PROGRAM} libcmark-gfm-extensions_static libcmark-gfm_static)
target_link_libraries(${PROGRAM} libcmarkly-extensions_static libcmarkly_static)
endif()

# Disable the PUBLIC declarations when compiling the executable:
Expand All @@ -103,15 +103,15 @@ if (CMARK_SHARED)
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
# Include minor version and patch level in soname for now.
set_target_properties(${LIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm"
OUTPUT_NAME "cmarkly"
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
VERSION ${PROJECT_VERSION})

set_property(TARGET ${LIBRARY}
APPEND PROPERTY MACOSX_RPATH true)

# Avoid name clash between PROGRAM and LIBRARY pdb files.
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm_dll)
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmarkly_dll)

generate_export_header(${LIBRARY}
BASE_NAME ${PROJECT_NAME})
Expand All @@ -127,11 +127,11 @@ if (CMARK_STATIC)

if (MSVC)
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm_static"
OUTPUT_NAME "cmarkly_static"
VERSION ${PROJECT_VERSION})
else()
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm"
OUTPUT_NAME "cmarkly"
VERSION ${PROJECT_VERSION})
endif(MSVC)

Expand All @@ -156,16 +156,16 @@ endif()
set(libdir lib${LIB_SUFFIX})

install(TARGETS ${PROGRAM} ${CMARK_INSTALL}
EXPORT cmark-gfm
EXPORT cmarkly
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${libdir}
ARCHIVE DESTINATION ${libdir}
)

if(CMARK_SHARED OR CMARK_STATIC)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmark-gfm.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libcmark-gfm.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark-gfm.pc
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmarkly.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libcmarkly.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmarkly.pc
DESTINATION ${libdir}/pkgconfig)

install(FILES
Expand All @@ -176,7 +176,7 @@ if(CMARK_SHARED OR CMARK_STATIC)
DESTINATION include
)

install(EXPORT cmark-gfm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
install(EXPORT cmarkly DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cmarkly)
endif()

# Feature tests
Expand Down
6 changes: 3 additions & 3 deletions src/libcmark-gfm.pc.in → src/libcmarkly.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_PREFIX@/@libdir@
includedir=@CMAKE_INSTALL_PREFIX@/include

Name: libcmark-gfm
Description: CommonMark parsing, rendering, and manipulation with GitHub Flavored Markdown extensions
Name: libcmarkly
Description: CMarkly Markdown parsing, rendering, and manipulation
Version: @PROJECT_VERSION@
Libs: -L${libdir} -lcmark-gfm -lcmark-gfm-extensions
Libs: -L${libdir} -lcmarkly -lcmarkly-extensions
Cflags: -I${includedir}
5 changes: 2 additions & 3 deletions test/cmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ def __init__(self, prog=None, library_dir=None, extensions=None):
if not library_dir:
library_dir = os.path.join("..", "build", "src")
for prefix, suffix in libnames:
candidate = os.path.join(library_dir, prefix + "cmark-gfm" + suffix)
candidate = os.path.join(library_dir, prefix + "cmarkly" + suffix)
if os.path.isfile(candidate):
libpath = candidate
break
cmark = CDLL(libpath)
extlib = CDLL(os.path.join(
library_dir, "..", "extensions", prefix + "cmark-gfm-extensions" + suffix))
library_dir, "..", "extensions", prefix + "cmarkly-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)

18 changes: 9 additions & 9 deletions wrappers/wrapper_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Example for using the shared library from python.
# Will work with either python 2 or python 3.
# Requires cmark-gfm and cmark-gfm-extensions libraries to be installed.
# Requires libcmarkly and libcmarkly-extensions to be installed.
#
# This particular example uses the GitHub extensions from the gfm-extensions
# library. EXTENSIONS specifies which to use, and the sample shows how to
Expand All @@ -14,14 +14,14 @@
import ctypes

if sys.platform == 'darwin':
libname = 'libcmark-gfm.dylib'
extname = 'libcmark-gfm-extensions.dylib'
libname = 'libcmarkly.dylib'
extname = 'libcmarkly-extensions.dylib'
elif sys.platform == 'win32':
libname = 'cmark-gfm.dll'
extname = 'cmark-gfm-extensions.dll'
libname = 'cmarkly.dll'
extname = 'cmarkly-extensions.dll'
else:
libname = 'libcmark-gfm.so'
extname = 'libcmark-gfm-extensions.so'
libname = 'libcmarkly.so'
extname = 'libcmarkly-extensions.so'
cmark = ctypes.CDLL(libname)
cmark_ext = ctypes.CDLL(extname)

Expand All @@ -36,7 +36,7 @@
'tagfilter',
)

# Use ctypes to access the functions in libcmark-gfm
# Use ctypes to access the functions in libcmarkly

F_cmark_parser_new = cmark.cmark_parser_new
F_cmark_parser_new.restype = ctypes.c_void_p
Expand Down Expand Up @@ -75,7 +75,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
# Set up the libcmarkly library and its extensions
F_register = cmark_ext.cmark_gfm_core_extensions_ensure_registered
F_register.restype = None
F_register.argtypes = ( )
Expand Down
Loading