From de8fd9328e9deb0d1ec596d7486686ea3cb688c2 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Tue, 9 Jun 2020 18:27:38 +0200 Subject: Includes cmark markdown parser library. --- lib/cmark/tools/appveyor-build.bat | 13 ++ lib/cmark/tools/make_entities_inc.py | 32 ++++ lib/cmark/tools/mkcasefold.pl | 22 +++ lib/cmark/tools/xml2md.xsl | 319 +++++++++++++++++++++++++++++++++++ 4 files changed, 386 insertions(+) create mode 100644 lib/cmark/tools/appveyor-build.bat create mode 100644 lib/cmark/tools/make_entities_inc.py create mode 100755 lib/cmark/tools/mkcasefold.pl create mode 100644 lib/cmark/tools/xml2md.xsl (limited to 'lib/cmark/tools') diff --git a/lib/cmark/tools/appveyor-build.bat b/lib/cmark/tools/appveyor-build.bat new file mode 100644 index 0000000..73d555b --- /dev/null +++ b/lib/cmark/tools/appveyor-build.bat @@ -0,0 +1,13 @@ +@echo off + +if "%MSVC_VERSION%" == "10" goto msvc10 + +call "C:\Program Files (x86)\Microsoft Visual Studio %MSVC_VERSION%.0\VC\vcvarsall.bat" amd64 +goto build + +:msvc10 +call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 + +:build +nmake + diff --git a/lib/cmark/tools/make_entities_inc.py b/lib/cmark/tools/make_entities_inc.py new file mode 100644 index 0000000..7b8ee41 --- /dev/null +++ b/lib/cmark/tools/make_entities_inc.py @@ -0,0 +1,32 @@ +# Creates C data structures for binary lookup table of entities, +# using python's html5 entity data. +# Usage: python3 tools/make_entities_inc.py > src/entities.inc + +import html + +entities5 = html.entities.html5 + +# remove keys without semicolons. For some reason the list +# has duplicates of a few things, like auml, one with and one +# without a semicolon. +entities = sorted([(k[:-1], entities5[k].encode('utf-8')) for k in entities5.keys() if k[-1] == ';']) + +# Print out the header: +print("""/* Autogenerated by tools/make_headers_inc.py */ + +struct cmark_entity_node { + unsigned char *entity; + unsigned char bytes[8]; +}; + +#define CMARK_ENTITY_MIN_LENGTH 2 +#define CMARK_ENTITY_MAX_LENGTH 32""") + +print("#define CMARK_NUM_ENTITIES " + str(len(entities))); + +print("\nstatic const struct cmark_entity_node cmark_entities[] = {"); + +for (ent, bs) in entities: + print('{(unsigned char*)"' + ent + '", {' + ', '.join(map(str, bs)) + ', 0}},') + +print("};") diff --git a/lib/cmark/tools/mkcasefold.pl b/lib/cmark/tools/mkcasefold.pl new file mode 100755 index 0000000..740ce77 --- /dev/null +++ b/lib/cmark/tools/mkcasefold.pl @@ -0,0 +1,22 @@ +binmode STDOUT; +print(" switch (c) {\n"); +my $lastchar = ""; +while () { + if (/^[A-F0-9]/ and / [CF]; /) { + my ($char, $type, $subst) = m/([A-F0-9]+); ([CF]); ([^;]+)/; + if ($char eq $lastchar) { + break; + } + my @subst = $subst =~ m/(\w+)/g; + printf(" case 0x%s:\n", $char); + foreach (@subst) { + printf(" bufpush(0x%s);\n", $_); + } + printf(" break;\n"); + $lastchar = $char; + } +} +printf(" default:\n"); +printf(" bufpush(c);\n"); +print(" }\n"); + diff --git a/lib/cmark/tools/xml2md.xsl b/lib/cmark/tools/xml2md.xsl new file mode 100644 index 0000000..0122e5f --- /dev/null +++ b/lib/cmark/tools/xml2md.xsl @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + Unsupported element '' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + *** + + + + + + + + + + + + + - + + + + . + ) + + + + + + + + + + + + + + + + + + + + + + + > + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \. + + + + + + + \) + + + + + + + \ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + + * + + + + ** + + ** + + + + + + + + + + + + + + + + + + + + + ! + [ + + ]( + + + + + + " + + + + + " + + ) + + + + + + + + + + + + + + + + + + + + + \ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3