diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-22 20:53:39 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-22 20:53:39 +0200 |
| commit | 8dbfb0890560fd1cd698d06fa05ac868c4db8576 (patch) | |
| tree | 57d138d7e9967473b8ed52863dabeb739a34ac8e /lib/cmark/tools | |
| parent | 058aeef80e8a33d0e385f284b23eeb117f5ec547 (diff) | |
| download | kristall-8dbfb0890560fd1cd698d06fa05ac868c4db8576.tar.gz | |
Removes 'cruft' from cmark. We only care for the source anyways.
Diffstat (limited to 'lib/cmark/tools')
| -rw-r--r-- | lib/cmark/tools/appveyor-build.bat | 13 | ||||
| -rw-r--r-- | lib/cmark/tools/make_entities_inc.py | 32 | ||||
| -rwxr-xr-x | lib/cmark/tools/mkcasefold.pl | 22 | ||||
| -rw-r--r-- | lib/cmark/tools/xml2md.xsl | 319 |
4 files changed, 0 insertions, 386 deletions
diff --git a/lib/cmark/tools/appveyor-build.bat b/lib/cmark/tools/appveyor-build.bat deleted file mode 100644 index 73d555b..0000000 --- a/lib/cmark/tools/appveyor-build.bat +++ /dev/null @@ -1,13 +0,0 @@ -@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 deleted file mode 100644 index 7b8ee41..0000000 --- a/lib/cmark/tools/make_entities_inc.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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 deleted file mode 100755 index 740ce77..0000000 --- a/lib/cmark/tools/mkcasefold.pl +++ /dev/null @@ -1,22 +0,0 @@ -binmode STDOUT; -print(" switch (c) {\n"); -my $lastchar = ""; -while (<STDIN>) { - 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 deleted file mode 100644 index 0122e5f..0000000 --- a/lib/cmark/tools/xml2md.xsl +++ /dev/null @@ -1,319 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - -xml2md.xsl -========== - -This XSLT stylesheet transforms the cmark XML format back to Commonmark. -Since the XML output is lossy, a lossless MD->XML->MD roundtrip isn't -possible. The XML->MD->XML roundtrip should produce the original XML, -though. - -Example usage with xsltproc: - - cmark -t xml doc.md | xsltproc -novalid xml2md.xsl - - ---> - -<xsl:stylesheet - version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:md="http://commonmark.org/xml/1.0"> - -<xsl:output method="text" encoding="utf-8"/> - -<!-- Generic templates --> - -<xsl:template match="/ | md:document | md:list"> - <xsl:apply-templates select="md:*"/> -</xsl:template> - -<xsl:template match="md:*"> - <xsl:message>Unsupported element '<xsl:value-of select="local-name()"/>'</xsl:message> -</xsl:template> - -<xsl:template match="md:*" mode="indent"/> - -<!-- Indent blocks --> - -<xsl:template match="md:*" mode="indent-block"> - <xsl:if test="preceding-sibling::md:*"> - <xsl:if test="not(ancestor::md:list[1][@tight='true'])"> - <xsl:apply-templates select="ancestor::md:*" mode="indent"/> - <xsl:text> </xsl:text> - </xsl:if> - <xsl:apply-templates select="ancestor::md:*" mode="indent"/> - </xsl:if> -</xsl:template> - -<!-- Heading --> - -<xsl:template match="md:heading"> - <xsl:apply-templates select="." mode="indent-block"/> - <xsl:value-of select="substring('###### ', 7 - @level)"/> - <xsl:apply-templates select="md:*"/> - <xsl:text> </xsl:text> -</xsl:template> - -<!-- Paragraph --> - -<xsl:template match="md:paragraph"> - <xsl:apply-templates select="." mode="indent-block"/> - <xsl:apply-templates select="md:*"/> - <xsl:text> </xsl:text> -</xsl:template> - -<!-- Thematic break --> - -<xsl:template match="md:thematic_break"> - <xsl:apply-templates select="." mode="indent-block"/> - <xsl:text>*** </xsl:text> -</xsl:template> - -<!-- List --> - -<xsl:template match="md:list"> - <xsl:apply-templates select="." mode="indent-block"/> - <xsl:apply-templates select="md:*"/> -</xsl:template> - -<xsl:template match="md:item"> - <xsl:apply-templates select="." mode="indent-block"/> - <xsl:choose> - <xsl:when test="../@type = 'bullet'">-</xsl:when> - <xsl:when test="../@type = 'ordered'"> - <xsl:value-of select="../@start + position() - 1"/> - <xsl:choose> - <xsl:when test="../@delim = 'period'">.</xsl:when> - <xsl:when test="../@delim = 'paren'">)</xsl:when> - </xsl:choose> - </xsl:when> - </xsl:choose> - <xsl:text> </xsl:text> - <xsl:apply-templates select="md:*"/> -</xsl:template> - -<xsl:template match="md:item" mode="indent"> - <xsl:choose> - <xsl:when test="../@type = 'bullet'"> - <xsl:text> </xsl:text> - </xsl:when> - <xsl:when test="../@type = 'ordered'"> - <xsl:text> </xsl:text> - </xsl:when> - </xsl:choose> -</xsl:template> - -<!-- Block quote --> - -<xsl:template match="md:block_quote"> - <xsl:apply-templates select="." mode="indent-block"/> - <xsl:text>> </xsl:text> - <xsl:apply-templates select="md:*"/> -</xsl:template> - -<xsl:template match="md:block_quote" mode="indent"> - <xsl:text>> </xsl:text> -</xsl:template> - -<!-- Code block --> - -<xsl:template match="md:code_block"> - <xsl:apply-templates select="." mode="indent-block"/> - - <xsl:variable name="t" select="string(.)"/> - <xsl:variable name="delim"> - <xsl:call-template name="code-delim"> - <xsl:with-param name="text" select="$t"/> - <xsl:with-param name="delim" select="'```'"/> - </xsl:call-template> - </xsl:variable> - - <xsl:value-of select="$delim"/> - <xsl:value-of select="@info"/> - <xsl:text> </xsl:text> - <xsl:call-template name="indent-lines"> - <xsl:with-param name="code" select="$t"/> - </xsl:call-template> - <xsl:apply-templates select="ancestor::md:*" mode="indent"/> - <xsl:value-of select="$delim"/> - <xsl:text> </xsl:text> -</xsl:template> - -<!-- Inline HTML --> - -<xsl:template match="md:html_block"> - <xsl:apply-templates select="." mode="indent-block"/> - <xsl:value-of select="substring-before(., ' ')"/> - <xsl:text> </xsl:text> - <xsl:call-template name="indent-lines"> - <xsl:with-param name="code" select="substring-after(., ' ')"/> - </xsl:call-template> -</xsl:template> - -<!-- Indent multiple lines --> - -<xsl:template name="indent-lines"> - <xsl:param name="code"/> - <xsl:if test="contains($code, ' ')"> - <xsl:apply-templates select="ancestor::md:*" mode="indent"/> - <xsl:value-of select="substring-before($code, ' ')"/> - <xsl:text> </xsl:text> - <xsl:call-template name="indent-lines"> - <xsl:with-param name="code" select="substring-after($code, ' ')"/> - </xsl:call-template> - </xsl:if> -</xsl:template> - -<!-- Text --> - -<xsl:template match="md:text"> - <xsl:variable name="t" select="string(.)"/> - <xsl:variable name="first" select="substring($t, 1, 1)"/> - <xsl:variable name="marker-check" select="translate(substring($t, 1, 10), '0123456789', '')"/> - <xsl:choose> - <!-- Escape ordered list markers --> - <xsl:when test="starts-with($marker-check, '.') and $first != '.'"> - <xsl:value-of select="substring-before($t, '.')"/> - <xsl:text>\.</xsl:text> - <xsl:call-template name="escape-text"> - <xsl:with-param name="text" select="substring-after($t, '.')"/> - </xsl:call-template> - </xsl:when> - <xsl:when test="starts-with($marker-check, ')') and $first != ')'"> - <xsl:value-of select="substring-before($t, ')')"/> - <xsl:text>\)</xsl:text> - <xsl:call-template name="escape-text"> - <xsl:with-param name="text" select="substring-after($t, ')')"/> - </xsl:call-template> - </xsl:when> - <!-- Escape leading block characters --> - <xsl:when test="contains('-+>#=~', $first)"> - <xsl:text>\</xsl:text> - <xsl:value-of select="$first"/> - <xsl:call-template name="escape-text"> - <xsl:with-param name="text" select="substring($t, 2)"/> - </xsl:call-template> - </xsl:when> - <!-- Otherwise --> - <xsl:otherwise> - <xsl:call-template name="escape-text"> - <xsl:with-param name="text" select="$t"/> - </xsl:call-template> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - -<!-- Breaks --> - -<xsl:template match="md:softbreak"> - <xsl:text> </xsl:text> - <xsl:apply-templates select="ancestor::md:*" mode="indent"/> -</xsl:template> - -<xsl:template match="md:linebreak"> - <xsl:text> </xsl:text> - <xsl:apply-templates select="ancestor::md:*" mode="indent"/> -</xsl:template> - -<!-- Emphasis --> - -<xsl:template match="md:emph"> - <xsl:text>*</xsl:text> - <xsl:apply-templates select="md:*"/> - <xsl:text>*</xsl:text> -</xsl:template> - -<xsl:template match="md:strong"> - <xsl:text>**</xsl:text> - <xsl:apply-templates select="md:*"/> - <xsl:text>**</xsl:text> -</xsl:template> - -<!-- Inline code --> - -<xsl:template match="md:code"> - <xsl:variable name="t" select="string(.)"/> - <xsl:variable name="delim"> - <xsl:call-template name="code-delim"> - <xsl:with-param name="text" select="$t"/> - <xsl:with-param name="delim" select="'`'"/> - </xsl:call-template> - </xsl:variable> - <xsl:value-of select="$delim"/> - <xsl:value-of select="$t"/> - <xsl:value-of select="$delim"/> -</xsl:template> - -<!-- Links and images --> - -<xsl:template match="md:link | md:image"> - <xsl:if test="self::md:image">!</xsl:if> - <xsl:text>[</xsl:text> - <xsl:apply-templates select="md:*"/> - <xsl:text>](</xsl:text> - <xsl:call-template name="escape-text"> - <xsl:with-param name="text" select="string(@destination)"/> - <xsl:with-param name="escape" select="'()'"/> - </xsl:call-template> - <xsl:if test="string(@title)"> - <xsl:text> "</xsl:text> - <xsl:call-template name="escape-text"> - <xsl:with-param name="text" select="string(@title)"/> - <xsl:with-param name="escape" select="'"'"/> - </xsl:call-template> - <xsl:text>"</xsl:text> - </xsl:if> - <xsl:text>)</xsl:text> -</xsl:template> - -<!-- Inline HTML --> - -<xsl:template match="md:html_inline"> - <xsl:value-of select="."/> -</xsl:template> - -<!-- Escaping helpers --> - -<xsl:template name="escape-text"> - <xsl:param name="text"/> - <xsl:param name="escape" select="'*_`<[]&'"/> - - <xsl:variable name="trans" select="translate($text, $escape, '\\\\\\\')"/> - <xsl:choose> - <xsl:when test="contains($trans, '\')"> - <xsl:variable name="safe" select="substring-before($trans, '\')"/> - <xsl:variable name="l" select="string-length($safe)"/> - <xsl:value-of select="$safe"/> - <xsl:text>\</xsl:text> - <xsl:value-of select="substring($text, $l + 1, 1)"/> - <xsl:call-template name="escape-text"> - <xsl:with-param name="text" select="substring($text, $l + 2)"/> - <xsl:with-param name="escape" select="$escape"/> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$text"/> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - -<xsl:template name="code-delim"> - <xsl:param name="text"/> - <xsl:param name="delim"/> - - <xsl:choose> - <xsl:when test="contains($text, $delim)"> - <xsl:call-template name="code-delim"> - <xsl:with-param name="text" select="$text"/> - <xsl:with-param name="delim" select="concat($delim, '`')"/> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$delim"/> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - -</xsl:stylesheet> |
