diff --git a/CMakeLists.txt b/CMakeLists.txt index 12b4915e3..9ce10c4ef 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/api_test/CMakeLists.txt b/api_test/CMakeLists.txt index 55f33e087..220a7812d 100644 --- a/api_test/CMakeLists.txt +++ b/api_test/CMakeLists.txt @@ -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 diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index e545b6d6f..0a01d074f 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -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 @@ -26,8 +26,7 @@ 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}) @@ -35,10 +34,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-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() @@ -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) @@ -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} @@ -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 diff --git a/fuzz/CMakeLists.txt b/fuzz/CMakeLists.txt index a9ed57aa5..8bde0300d 100644 --- a/fuzz/CMakeLists.txt +++ b/fuzz/CMakeLists.txt @@ -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() diff --git a/man/make_man_page.py b/man/make_man_page.py index d95620252..64ccaa0a5 100644 --- a/man/make_man_page.py +++ b/man/make_man_page.py @@ -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 diff --git a/README.md b/readme.md similarity index 81% rename from README.md rename to readme.md index 0b9f719f6..7bf8fb9cb 100644 --- a/README.md +++ b/readme.md @@ -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 + ``. +- 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. --- @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79c2382d9..9339a48b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 @@ -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: @@ -103,7 +103,7 @@ 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}) @@ -111,7 +111,7 @@ 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-gfm_dll) + set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmarkly_dll) generate_export_header(${LIBRARY} BASE_NAME ${PROJECT_NAME}) @@ -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) @@ -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 @@ -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 diff --git a/src/libcmark-gfm.pc.in b/src/libcmarkly.pc.in similarity index 53% rename from src/libcmark-gfm.pc.in rename to src/libcmarkly.pc.in index 46fff31a2..03c71e406 100644 --- a/src/libcmark-gfm.pc.in +++ b/src/libcmarkly.pc.in @@ -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} diff --git a/test/cmark.py b/test/cmark.py index b0eb20dbe..5526e0340 100644 --- a/test/cmark.py +++ b/test/cmark.py @@ -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) - diff --git a/wrappers/wrapper_ext.py b/wrappers/wrapper_ext.py index f08cc2076..2df522cac 100755 --- a/wrappers/wrapper_ext.py +++ b/wrappers/wrapper_ext.py @@ -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 @@ -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) @@ -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 @@ -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 = ( )