Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the handle_backticks issue #426

Closed
wants to merge 229 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
229 commits
Select commit Hold shift + click to select a range
cec3765
More runs in benchmark; .gitignore update
Sep 26, 2016
f30d3c6
Arena allocator
Sep 27, 2016
c8960d7
Extensions API (https://github.com/jgm/cmark/pull/123)
MathieuDuponchelle Dec 1, 2016
3e3761a
Strip extensions API down and separate from core
Dec 1, 2016
0445d10
Table extension from c068469 reworked
Nov 29, 2016
c55225f
Strikethrough extension from c068469 reworked
Nov 29, 2016
920f728
Autolink extension
Nov 29, 2016
1eab596
Tagfilter extension
Nov 29, 2016
3e5f8a4
Reduce maximum amount of backticks
vmg Nov 28, 2016
c36f848
Get a clean build on MSVC (#5)
Dec 9, 2016
b9df6b3
table: trim cells, fix escaping, cleanup (#4)
Dec 13, 2016
3636dc9
Initialise openers bottom correctly
Jan 5, 2017
a49c13a
Fix for inline parser changes
Jan 23, 2017
b555d89
Abort if we fail to alloc chunk itself
Jan 26, 2017
16846c6
Add a no-crash test
Jan 27, 2017
f893cfa
Add opaque_free_func to extensions
Feb 6, 2017
9822599
Use opaque instead of user_data in table
Feb 6, 2017
061c1f6
Rework email autolink as postprocessor
Feb 2, 2017
9f85003
Compile shared library for extensions
Feb 6, 2017
b9a3ab8
Use extensions in spec test
Feb 6, 2017
7b0b501
Only escape pipes in commonmark output when necessary
Feb 6, 2017
d6ac760
Fix Windows build
Feb 7, 2017
fd110a5
Preserve number of tildes in failed strikethru
Feb 9, 2017
e548d42
autolink simplification
Feb 10, 2017
6923e1e
autolink_delim only works with ")", fix balance behaviour
Feb 10, 2017
a331579
spec update
Feb 9, 2017
8cb4978
Windows build fix (again)
Mar 6, 2017
90b6f7d
Support UTF-8 domains in autolinks
Mar 13, 2017
dcfddd7
Handle links in quotes correctly.
Mar 13, 2017
331b192
Reference links in tables (#10)
Mar 15, 2017
166942b
Handle UTF-8 BOM (#14)
Mar 20, 2017
5d08859
Add CMARK_OPT_GITHUB_PRE_LANG
Mar 22, 2017
81816f3
Use <pre><code>
Mar 22, 2017
0c167f8
Fix empty table cell behaviour (#17)
Mar 26, 2017
8fafc10
Limit arena
Mar 27, 2017
2714110
Add Dockerfile
Mar 28, 2017
c2712a4
Add -gfm suffix to artifacts
Mar 28, 2017
eaf3b8f
README updates
Mar 28, 2017
4c4df80
Correct manpages. Fixes #20.
Apr 3, 2017
21bbc4c
Simple tables (#21)
Apr 4, 2017
36b5588
Latest spec
Apr 4, 2017
5dfedc7
Skip disabled extensions
Apr 4, 2017
f2fa4a1
roundtrip_tests reports results
Apr 4, 2017
9dc52d8
Add GFM version number
May 1, 2017
c0f16ae
Plaintext renderer (#25)
May 8, 2017
47e724d
Remove normalize as an option per #190 (#194)
May 8, 2017
afd530f
Remove dead/misleading code
May 15, 2017
9f81059
Add table alignment getters (#29)
May 22, 2017
b0707b6
make install also installs extensions (#32)
May 29, 2017
fff48d5
0.27.1.gfm.1
May 29, 2017
d9526ab
Add CMARK_GFM_VERSION define.
May 29, 2017
1cd892e
Fix link order of cmark-gfm (#35)
nafest May 31, 2017
ec5dcf4
Add `cmark_syntax_extension_get_private()` (#36)
foonathan Jun 2, 2017
fa66ade
Unmark as static
Jun 16, 2017
a38cfc0
Don't scan past an EOL (#37)
Jun 21, 2017
cb91444
Regenerate scanner
Jun 21, 2017
4b3267d
Also exclude \n
Jun 21, 2017
a758a35
Update cmark-fuzz for cmark-gfm
Jun 29, 2017
71b0d00
Latest cmake in Docker
Jun 30, 2017
0fbab47
Fix a misaligned write
Jun 30, 2017
2af1c5c
0.27.1.gfm.2
Jun 30, 2017
ffa8c3e
Install ninja-build
Jun 30, 2017
3a3ac47
Avoid memcpy'ing NULL pointers (#38)
philipturnbull Jul 6, 2017
fca380c
Case-insensitive tagfilter. Fixes #42. (#43)
Jul 7, 2017
7d70d2c
Allocate memory from arena with correct alignment (#40)
philipturnbull Jul 11, 2017
494f10a
Use unsigned integer when shifting (#39)
philipturnbull Jul 11, 2017
970e029
0.27.1.gfm.3
kivikakk Jul 11, 2017
298d9d2
> 32 nested balanced parens in a link is bananas (#48)
Jul 12, 2017
175542b
0.27.1.gfm.4
kivikakk Jul 12, 2017
c93dc8b
Latest spec
kivikakk Jul 14, 2017
d219c0a
Fix typo (#52)
Alhadis Jul 17, 2017
e45ee8d
test: Add test case for pathological collisions
vmg Jul 14, 2017
384cc9d
references: Fix pathological quadatric behavior
vmg Jul 14, 2017
45ca300
Fix pathological test runner on Windows
kivikakk Jul 17, 2017
62166fe
Add casts for MSVC10
kivikakk Jul 17, 2017
66a0836
Merge branch 'vmg/collisions'
kivikakk Jul 17, 2017
2b158e1
Update to latest spec
kivikakk Aug 2, 2017
2731cb0
Add the idempotent core_extensions_ensure_registered
kivikakk Aug 7, 2017
b9459ef
Inline sourcepos (#53)
Aug 9, 2017
7cf993f
Remove unneeded TODO
kivikakk Aug 9, 2017
8595dda
0.28.0.gfm.5
kivikakk Aug 9, 2017
fd7d177
Sourcepos fixes (#54)
Aug 10, 2017
3a9081b
0.28.0.gfm.6
kivikakk Aug 10, 2017
8eb09f8
Skip strikethroughs when considering emphasis (#55)
Aug 17, 2017
2667be9
0.28.0.gfm.7
kivikakk Aug 17, 2017
fa84ac8
Autolink should not cause : to be skipped
kivikakk Aug 25, 2017
c939f0e
Merge remote-tracking branch 'upstream/master'
kivikakk Aug 25, 2017
28232aa
0.28.0.gfm.8
kivikakk Aug 25, 2017
820372d
Recursive chevrons are bananas (#49)
Sep 6, 2017
150239c
0.28.0.gfm.9
kivikakk Sep 6, 2017
63f17be
blocks: Fix quadratic behavior in `finalize`
vmg Sep 7, 2017
d946b7c
0.28.0.gfm.10
kivikakk Sep 8, 2017
3afbcad
No empty <tbody>
kivikakk Sep 11, 2017
e3f3a27
0.28.0.gfm.11
kivikakk Sep 11, 2017
07fe00f
Period in email must precede alnum (#58)
Oct 3, 2017
fff5fef
Merge branch 'upstream-master'
kivikakk Nov 5, 2017
1781c95
feature test macros in harness
kivikakk Nov 6, 2017
37804e6
Fix install EXPORT target
kivikakk Nov 6, 2017
8d71a16
Shift includes around for proper header install (#63)
Nov 6, 2017
9188bdf
add node.js wrapper (#46)
killagu Nov 9, 2017
59f7233
Footnotes (#64)
Nov 16, 2017
57b3567
FOOTNOTE_REFERENCE has text content
kivikakk Nov 16, 2017
6b101e3
Footnote fix per kivikakk/comrak#44
kivikakk Nov 26, 2017
0c6d1c4
ASCII clean source
kivikakk Dec 12, 2017
e97b324
Add -lcmark-gfmextensions to libcmark-gfm.pc.in
kivikakk Jan 7, 2018
e1fa457
Merge remote-tracking branch 'upstream/master'
kivikakk Jan 7, 2018
6df666d
Fix extensions with static only
kivikakk Jan 7, 2018
f0b8686
Build static on Windows again
kivikakk Jan 7, 2018
7ef1ebc
0.28.3.gfm.12
kivikakk Jan 7, 2018
9137851
Add CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE. Closes #71.
kivikakk Jan 25, 2018
7ddfb10
add CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES (#86)
gfx Feb 20, 2018
b6098ab
add tests for --table-prefer-style-attributes (#87)
gfx Feb 20, 2018
bf28ef6
Remove square brackets when rendering HTML for footnotes (#90)
pyrmont Mar 12, 2018
c7ac6ac
Merge remote-tracking branch 'upstream/master'
kivikakk Apr 13, 2018
b7a3b74
Handle deeply nested lists (#95)
philipturnbull Jun 20, 2018
7b4a497
Expose `cmark_node_type CMARK_NODE_TABLE` etc., make XCode happy with…
molikto Jun 20, 2018
907dcdf
Debian packaging (#97)
troglobit Jun 20, 2018
02bc37d
Removed meta from list of block tags.
jgm Jun 11, 2018
61f1f05
Fix spaces on regression test.
jgm Jun 11, 2018
38cc7a4
add regression test from comrak
kivikakk Jul 12, 2018
e9a231f
latest spec
kivikakk Jul 12, 2018
343c5d2
latest spec
kivikakk Jul 15, 2018
648b388
regressions.txt has non-specified strikethrough
kivikakk Jul 15, 2018
8aa0868
Add example of a Python wrapper which uses libcmark-gfmextensions. (#…
gstein Jul 19, 2018
4503875
Parse rest of info string as meta (#103)
mikekavouras Aug 8, 2018
4057e9f
0.28.3.gfm.13
kivikakk Aug 8, 2018
0accc94
add plaintext render func for strikethru
kivikakk Aug 9, 2018
1b1f90d
0.28.3.gfm.14
kivikakk Aug 10, 2018
17b339e
commonmark writer: escape tilde (~). (#106)
jgm Aug 19, 2018
1470c30
table extension: cosmetic fix for uniformity of output. (#105)
jgm Aug 19, 2018
9ceb8bd
commonmark writer/strikethrough: use two tildes for delimiters. (#104)
jgm Aug 19, 2018
3221400
Normalise header and define names (#109)
Aug 21, 2018
f649003
0.28.3.gfm.15
kivikakk Aug 21, 2018
ea2a07d
`~` should not be escaped in href (#110)
Sep 5, 2018
a9dbc9c
Footnotes in tables (#112)
Sep 10, 2018
446767d
0.28.3.gfm.16
kivikakk Sep 10, 2018
22d1149
Allow extension to provide "opaque" alloc function (#89)
nojb Sep 13, 2018
e4de28e
Merge remote-tracking branch 'upstream/master'
kivikakk Sep 16, 2018
258d2a4
XML attribute formatters (#116)
Sep 24, 2018
e7dc6ae
Add support for tables and strike-through text in the XSLT (#117)
maelle Sep 25, 2018
1512c9c
0.28.3.gfm.17
kivikakk Sep 25, 2018
4ec9b35
Be more strict on matching strikethrough (#120)
Oct 7, 2018
975a9d1
Remove /debian by suggestion in #122
kivikakk Oct 10, 2018
6e73dea
update travis-ci link
kivikakk Oct 15, 2018
a9ed0e2
fix image target
kivikakk Oct 15, 2018
f64691b
Default to safe operation (#123)
Oct 17, 2018
304bce0
0.28.3.gfm.18
kivikakk Oct 17, 2018
198669d
Prevent out-of-bound memory access. (#124)
Xadeck Oct 17, 2018
21f7420
Limit the recursion in autolink extension. (#125)
Xadeck Oct 17, 2018
bbb9dd1
Add plaintext rendering for footnotes. Otherwise, it crashes in debug…
Xadeck Oct 17, 2018
bc48e4f
0.28.3.gfm.19
kivikakk Oct 17, 2018
3c4da5b
Add GFM extensions to fuzzing harness (#127)
philipturnbull Oct 18, 2018
36e36cd
Fix a buffer overread in the CMark tables extension. (#128)
Sjlver Oct 22, 2018
d53d533
don't crash on test failure on macos
kivikakk Nov 12, 2018
44eafe0
use pledge(2) (#132)
Nov 19, 2018
42f5a52
check for OpenBSD 5.9+
kivikakk Nov 21, 2018
9bdf783
be more liberal in strikethru regression
kivikakk Nov 27, 2018
02b19e0
fix misplaced parenthesis
Nov 27, 2018
6d60bfa
add tasklist extension (#94)
Watson1978 Dec 2, 2018
b153c5a
add changelog entry
kivikakk Dec 2, 2018
301eefc
fix attribution
kivikakk Dec 2, 2018
3785191
0.28.3.gfm.20
kivikakk Jan 31, 2019
7c71bd1
Merge branch 'upstream-master'
kivikakk Feb 5, 2019
90048f9
Remove options mask from fuzzing harness (#129)
philipturnbull Feb 5, 2019
4b9523d
remove the class here
kivikakk Feb 12, 2019
9f7ca02
Adjustments to how the tasklist generation occurs (#136)
gjtorikian Mar 4, 2019
2a9996f
Define _DEFAULT_SOURCE to get various posix/gnu glibc functions decla…
keith-packard Mar 12, 2019
365dabb
Add automatic configuration of compiler to get large file support (#138)
keith-packard Mar 12, 2019
f26f75c
Merge branch 'upstream-master'
kivikakk Apr 8, 2019
b8eb2e0
Merge branch 'upstream-master'
kivikakk Apr 8, 2019
87c0139
Fix bug with determining if task is complete & adjust to spec. (#142)
NightFlyer Apr 29, 2019
4a7985e
Add XML attribute to tasklist (#145)
NightFlyer May 1, 2019
17169ab
Specify parenthesis matching in autolink extension (#148)
waldyrious May 1, 2019
78d8268
Fix valid domain ambiguity (#151)
JohelEGP May 3, 2019
10730e1
Fix extended email autolink ambiguity (#152)
JohelEGP May 3, 2019
ef13dc5
Fix table cannot be recoginsed without empty line (#154)
jinhucheung May 8, 2019
4ee4901
Fix hard line break example (#155)
JohelEGP May 8, 2019
6a90249
correct _STATIC_DEFINE flag names
kivikakk May 13, 2019
4b6ceb6
import spec changes
kivikakk May 15, 2019
4b625f5
Merge remote-tracking branch 'upstream/master'
kivikakk May 15, 2019
438f3b2
Change cmark_gfm_extensions_get_tasklist_state to cmark_gfm_extension…
NightFlyer May 31, 2019
f5c77c6
Make "set" methods public, add "set" method for tasklist (#162)
NightFlyer Jun 19, 2019
b47d804
Fixes Visual C++ 2019 compiler warnings for x64 targets (#166)
rysavyjan Jun 21, 2019
0996db0
Fix bug where tasklist extension was using union in two ways. (#169)
NightFlyer Jun 25, 2019
9a5bbf7
Revert "import spec changes"
kivikakk Jun 25, 2019
aed182e
Add link to Tcl bindings. (#171)
apnadkarni Jul 17, 2019
36c1553
Correct path to artifact (#173)
alkuzad Sep 5, 2019
8a624e5
Rebuild `ext_scanners.c` with latest `re2c`.
arthurschreiber Mar 3, 2020
db11187
[PATCH] Fix `O(n*n)` corner-case runtime in GFM's table extension.
Sjlver Mar 3, 2020
3267377
Add a test.
arthurschreiber Mar 3, 2020
ddf21bb
Restore compatibility with other changes.
arthurschreiber Mar 3, 2020
85d8952
Merge pull request from GHSA-7gc6-9qr5-hc85
philipturnbull Jun 30, 2020
88a6f87
Add Swift Package Manager Support
bitjammer Sep 23, 2020
b4e18c1
Use pre-set config.h header
bitjammer Oct 6, 2020
c773440
Track opening backtick count for inline code spans
bitjammer Oct 8, 2020
1429a7f
apply block offsets for autolink source position info
QuietMisdreavus Dec 7, 2020
57bee4e
don't let blocks get end lines before their start lines
QuietMisdreavus Dec 8, 2020
3489555
Add inline directive syntax
parkera Dec 15, 2020
f97a08c
properly set image/link sourcepos when spanning multiple lines
QuietMisdreavus Dec 17, 2020
482d443
Add ^ to special chars array
parkera Jan 17, 2021
39ae2a8
fixes existing data races
QuietMisdreavus Aug 3, 2021
d62fa12
add mutex initializer in new header
QuietMisdreavus Mar 30, 2021
437dcb0
add locks around arena ops
QuietMisdreavus Mar 30, 2021
92fb896
tweak definitions of statics in inlines.c
QuietMisdreavus Mar 30, 2021
cb88af7
add locks around extensions registry ops
QuietMisdreavus Mar 30, 2021
562c89a
make locking a compile-time setting
QuietMisdreavus Mar 30, 2021
18b7394
add latch macros and use them for registering plugins
QuietMisdreavus Mar 30, 2021
fc95a68
fix deadlock in arena
QuietMisdreavus Mar 30, 2021
0489d3c
use pthread_once instead of atomics
QuietMisdreavus Mar 31, 2021
a595ea9
Add preserve-whitespace and inline-only options
jmschonfeld Apr 14, 2021
471d20c
Allow all whitespace when preserving whitespace
jmschonfeld May 5, 2021
6df1faa
Don't emit an attribute node if it doesn't have parentheses
iCharlesHu May 18, 2021
2afe77a
update use of mutexes
QuietMisdreavus May 12, 2021
061a4d8
move global characters arrays into the parser
QuietMisdreavus May 18, 2021
fe9ba10
free special char blocks alongside the parser
QuietMisdreavus Jun 1, 2021
5d99168
don't reset the special-char blocks in parser_reset
QuietMisdreavus Jun 1, 2021
ea07fb5
add comment about freeing special-chars memory
QuietMisdreavus Jun 1, 2021
6f75d91
save special_chars/skip_chars in parser_reset
QuietMisdreavus Jun 2, 2021
7586471
don't leak my_ext in the parser_interrupt test
QuietMisdreavus Jun 2, 2021
cea3e64
Add custom attributes using ^[foo][N] syntax
iCharlesHu Jun 16, 2021
1424dac
Preserve leading newlines when CMARK_OPT_PRESERVE_WHITESPACE is set
jmschonfeld Jun 14, 2021
e9b454e
add cmark-gfm-bin target to Package.swift
QuietMisdreavus Jun 15, 2021
8a631d3
add .build/.swiftpm to gitignore
QuietMisdreavus Jun 15, 2021
4e7da18
add api_test to Package.swift
QuietMisdreavus Jun 15, 2021
f0c2fb1
fix warning in api_test
QuietMisdreavus Jun 15, 2021
4c9a330
add explicit modulemap for cmark-gfm
QuietMisdreavus Jun 15, 2021
44090a3
add intention to take upstream changes
bontoJR Jul 30, 2021
2190baa
Update README.md
franklinsch Aug 2, 2021
e21b3eb
[Bugfix] Fix the backticks bug
Kyle-Ye Nov 7, 2021
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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ bstrlib.txt
build
cmark.dSYM/*
cmark
.vscode

# Testing and benchmark
alltests.md
progit/
bench/benchinput.md
test/afl_results/

# Build directories for SwiftPM and Xcode
.swiftpm
.build
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
cmake_minimum_required(VERSION 3.0)
project(cmark VERSION 0.29.0)
project(cmark-gfm)

set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 29)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_GFM 0)
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM})

include("FindAsan.cmake")
include("CheckFileOffsetBits.cmake")

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()

option(CMARK_TESTS "Build cmark tests and enable testing" ON)
option(CMARK_STATIC "Build static libcmark library" ON)
option(CMARK_SHARED "Build shared libcmark library" 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)
option(CMARK_THREADING "Add locks around static accesses via pthreads" OFF)

add_subdirectory(src)
add_subdirectory(extensions)
if(CMARK_TESTS AND (CMARK_SHARED OR CMARK_STATIC))
add_subdirectory(api_test)
endif()
Expand Down
14 changes: 14 additions & 0 deletions CheckFileOffsetBits.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <sys/types.h>

#define KB ((off_t)1024)
#define MB ((off_t)1024 * KB)
#define GB ((off_t)1024 * MB)
#define TB ((off_t)1024 * GB)
int t2[(((64 * GB -1) % 671088649) == 268434537)
&& (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1];

int main()
{
;
return 0;
}
43 changes: 43 additions & 0 deletions CheckFileOffsetBits.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# - Check if _FILE_OFFSET_BITS macro needed for large files
# CHECK_FILE_OFFSET_BITS ()
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# Copyright (c) 2009, Michihiro NAKAJIMA
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

#INCLUDE(CheckCSourceCompiles)

GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits
"${CMAKE_CURRENT_LIST_FILE}" PATH)

MACRO (CHECK_FILE_OFFSET_BITS)
IF(NOT DEFINED _FILE_OFFSET_BITS)
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files")
TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64
${CMAKE_CURRENT_BINARY_DIR}
${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
IF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64
${CMAKE_CURRENT_BINARY_DIR}
${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64)

IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - needed")
ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed")
ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
ENDIF(NOT DEFINED _FILE_OFFSET_BITS)

ENDMACRO (CHECK_FILE_OFFSET_BITS)
50 changes: 39 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
SRCDIR=src
EXTDIR=extensions
DATADIR=data
BUILDDIR?=build
GENERATOR?=Unix Makefiles
MINGW_BUILDDIR?=build-mingw
MINGW_INSTALLDIR?=windows
SPEC=test/spec.txt
EXTENSIONS_SPEC=test/extensions.txt
SITE=_site
SPECVERSION=$(shell perl -ne 'print $$1 if /^version: *([0-9.]+)/' $(SPEC))
FUZZCHARS?=2000000 # for fuzztest
BENCHDIR=bench
BENCHSAMPLES=$(wildcard $(BENCHDIR)/samples/*.md)
BENCHFILE=$(BENCHDIR)/benchinput.md
ALLTESTS=alltests.md
NUMRUNS?=10
CMARK=$(BUILDDIR)/src/cmark
NUMRUNS?=20
CMARK=$(BUILDDIR)/src/cmark-gfm
CMARK_FUZZ=$(BUILDDIR)/src/cmark-fuzz
PROG?=$(CMARK)
VERSION?=$(SPECVERSION)
RELEASE?=CommonMark-$(VERSION)
INSTALL_PREFIX?=/usr/local
CLANG_CHECK?=clang-check
CLANG_FORMAT=clang-format -style llvm -sort-includes=0 -i
CLANG_FORMAT=clang-format-3.5 -style llvm -sort-includes=0 -i
AFL_PATH?=/usr/local/bin

.PHONY: all cmake_build leakcheck clean fuzztest test debug ubsan asan mingw archive newbench bench format update-spec afl clang-check libFuzzer
.PHONY: all cmake_build leakcheck clean fuzztest test debug ubsan asan mingw archive newbench bench format update-spec afl clang-check docker libFuzzer

all: cmake_build man/man3/cmark.3
all: cmake_build man/man3/cmark-gfm.3

$(CMARK): cmake_build

Expand Down Expand Up @@ -79,8 +81,9 @@ afl:
-i test/afl_test_cases \
-o test/afl_results \
-x test/fuzzing_dictionary \
$(AFL_OPTIONS) \
-t 100 \
$(CMARK) $(CMARK_OPTS)
$(CMARK) -e table -e strikethrough -e autolink -e tagfilter $(CMARK_OPTS)

libFuzzer:
@[ -n "$(LIB_FUZZER_PATH)" ] || { echo '$$LIB_FUZZER_PATH not set'; false; }
Expand All @@ -98,7 +101,7 @@ mingw:
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$(MINGW_INSTALLDIR) ;\
$(MAKE) && $(MAKE) install

man/man3/cmark.3: src/cmark.h | $(CMARK)
man/man3/cmark-gfm.3: src/cmark-gfm.h | $(CMARK)
python man/make_man_page.py $< > $@ \

archive:
Expand Down Expand Up @@ -126,6 +129,19 @@ $(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
--encoding-policy substitute -o $@ $<
$(CLANG_FORMAT) $@

# We include scanners.c in the repository, so this shouldn't
# normally need to be generated.
$(EXTDIR)/ext_scanners.c: $(EXTDIR)/ext_scanners.re
@case "$$(re2c -v)" in \
*\ 0.13.*|*\ 0.14|*\ 0.14.1) \
echo "re2c >= 0.14.2 is required"; \
false; \
;; \
esac
re2c --case-insensitive -b -i --no-generation-date -8 \
--encoding-policy substitute -o $@ $<
clang-format-3.5 -style llvm -i $@

# We include entities.inc in the repository, so normally this
# doesn't need to be regenerated:
$(SRCDIR)/entities.inc: tools/make_entities_inc.py
Expand All @@ -138,14 +154,19 @@ update-spec:
test: $(SPEC) cmake_build
$(MAKE) -C $(BUILDDIR) test || (cat $(BUILDDIR)/Testing/Temporary/LastTest.log && exit 1)

$(ALLTESTS): $(SPEC)
python3 test/spec_tests.py --spec $< --dump-tests | python3 -c 'import json; import sys; tests = json.loads(sys.stdin.read()); print("\n".join([test["markdown"] for test in tests]))' > $@
$(ALLTESTS): $(SPEC) $(EXTENSIONS_SPEC)
( \
python3 test/spec_tests.py --spec $(SPEC) --dump-tests | \
python3 -c 'import json; import sys; tests = json.loads(sys.stdin.read()); u8s = open(1, "w", encoding="utf-8", closefd=False); print("\n".join([test["markdown"] for test in tests]), file=u8s)'; \
python3 test/spec_tests.py --spec $(EXTENSIONS_SPEC) --dump-tests | \
python3 -c 'import json; import sys; tests = json.loads(sys.stdin.read()); u8s = open(1, "w", encoding="utf-8", closefd=False); print("\n".join([test["markdown"] for test in tests]), file=u8s)'; \
) > $@

leakcheck: $(ALLTESTS)
for format in html man xml latex commonmark; do \
for opts in "" "--smart"; do \
echo "cmark -t $$format $$opts" ; \
valgrind -q --leak-check=full --dsymutil=yes --error-exitcode=1 $(PROG) -t $$format $$opts $(ALLTESTS) >/dev/null || exit 1;\
echo "cmark-gfm -t $$format -e table -e strikethrough -e autolink -e tagfilter $$opts" ; \
valgrind -q --leak-check=full --dsymutil=yes --suppressions=suppressions --error-exitcode=1 $(PROG) -t $$format -e table -e strikethrough -e autolink -e tagfilter $$opts $(ALLTESTS) >/dev/null || exit 1;\
done; \
done;

Expand Down Expand Up @@ -189,10 +210,17 @@ newbench:
format:
$(CLANG_FORMAT) src/*.c src/*.h api_test/*.c api_test/*.h

format-extensions:
clang-format-3.5 -style llvm -i extensions/*.c extensions/*.h

operf: $(CMARK)
operf $< < $(BENCHFILE) > /dev/null

distclean: clean
-rm -rf *.dSYM
-rm -f README.html
-rm -rf $(BENCHFILE) $(ALLTESTS) progit

docker:
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
4 changes: 3 additions & 1 deletion Makefile.nmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,6 +16,8 @@ $(BUILDDIR)/CMakeFiles:
-G "$(GENERATOR)" \
-D CMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-D CMAKE_INSTALL_PREFIX=$(INSTALLDIR) \
-D CMARK_STATIC=ON \
-D CMARK_SHARED=OFF \
.. && \
cd ..

Expand Down
66 changes: 66 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "cmark-gfm",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "cmark-gfm",
targets: ["cmark-gfm"]),
.library(
name: "cmark-gfm-extensions",
targets: ["cmark-gfm-extensions"]),
.executable(
name: "cmark-gfm-bin",
targets: ["cmark-gfm-bin"]),
.executable(name: "api_test",
targets: ["api_test"])
],
targets: [
.target(name: "cmark-gfm",
path: "src",
exclude: [
"scanners.re",
"libcmark-gfm.pc.in",
"config.h.in",
"CMakeLists.txt",
"cmark-gfm_version.h.in",
"case_fold_switch.inc",
"entities.inc",
]
),
.target(name: "cmark-gfm-extensions",
dependencies: [
"cmark-gfm",
],
path: "extensions",
exclude: [
"CMakeLists.txt",
"ext_scanners.re",
]
),
.target(name: "cmark-gfm-bin",
dependencies: [
"cmark-gfm",
"cmark-gfm-extensions",
],
path: "bin",
sources: [
"main.c",
]
),
.target(name: "api_test",
dependencies: [
"cmark-gfm",
"cmark-gfm-extensions",
],
path: "api_test",
exclude: [
"CMakeLists.txt",
]
)
]
)
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
cmark
=====
cmark-gfm
=========

[![Build Status]](https://travis-ci.org/commonmark/cmark)
[![Windows Build Status]](https://ci.appveyor.com/project/jgm/cmark-0ub06)
`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].

`cmark` is the C reference implementation of [CommonMark], a
rationalized version of Markdown syntax with a [spec][the spec].
(For the JavaScript reference implementation, see
[commonmark.js].)
Changes upstream in `cmark` will be pulled into this `cmark-gfm` project repository
as the upstream project evolves. The original `cmark` repository can be found here:
<https://github.com/commonmark/cmark>.

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.

## License

The original `cmark` code is released under a BSD2 license. This same license
applies to the Swift code included in this `cmark-gfm` repository.

---

It provides a shared library (`libcmark`) with functions for parsing
CommonMark documents to an abstract syntax tree (AST), manipulating
Expand Down Expand Up @@ -59,8 +71,10 @@ There are also libraries that wrap `libcmark` for
[Lua](https://github.com/jgm/cmark-lua),
[Perl](https://metacpan.org/release/CommonMark),
[Python](https://pypi.python.org/pypi/paka.cmark),
[R](https://cran.r-project.org/package=commonmark) and
[Scala](https://github.com/sparsetech/cmark-scala).
[R](https://cran.r-project.org/package=commonmark),
[Tcl](https://github.com/apnadkarni/tcl-cmark),
[Scala](https://github.com/sparsetech/cmark-scala) and
[Node.js](https://github.com/killa123/node-cmark).

Installing
----------
Expand Down Expand Up @@ -187,12 +201,13 @@ Nick Wellnhofer contributed many improvements, including
most of the C library's API and its test harness.

[benchmarks]: benchmarks.md
[the spec]: http://spec.commonmark.org
[the spec]: https://github.github.com/gfm/
[the upstream implementation]: https://github.com/jgm/cmark
[CommonMark]: http://commonmark.org
[cmake]: http://www.cmake.org/download/
[re2c]: http://re2c.org
[commonmark.js]: https://github.com/commonmark/commonmark.js
[Build Status]: https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat
[Windows Build Status]: https://ci.appveyor.com/api/projects/status/h3fd91vtd1xfmp69?svg=true
[Build Status]: https://img.shields.io/travis/github/cmark-gfm/master.svg?style=flat
[Windows Build Status]: https://ci.appveyor.com/api/projects/status/wv7ifhqhv5itm3d5?svg=true
[american fuzzy lop]: http://lcamtuf.coredump.cx/afl/
[libFuzzer]: http://llvm.org/docs/LibFuzzer.html
10 changes: 6 additions & 4 deletions api_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ add_executable(api_test
main.c
)
include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/src/include
${PROJECT_BINARY_DIR}/src/include
${PROJECT_SOURCE_DIR}/extensions/include
${PROJECT_BINARY_DIR}/extensions/include
)
if(CMARK_SHARED)
target_link_libraries(api_test libcmark)
target_link_libraries(api_test libcmark-gfm-extensions libcmark-gfm)
else()
target_link_libraries(api_test libcmark_static)
target_link_libraries(api_test libcmark-gfm-extensions_static libcmark-gfm_static)
endif()

# Compiler flags
Expand Down
Loading