Commit bc31e88a authored by Nikita Sirgienko's avatar Nikita Sirgienko

Fix problems with building cantor without LANG environment variable

BUG: 410802
FIXED-IN: 19.12
(cherry picked from commit febeff84)
parent 25c2c2b3
......@@ -7,7 +7,7 @@ set (DISCOUNT_ONLY_LIBRARY ON)
set (DISCOUNT_MAKE_INSTALL OFF)
ExternalProject_Add(
discount_project
URL ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/discount-2.2.6-patched.tar
URL ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/discount-2.2.6-patched
SOURCE_SUBDIR cmake
CMAKE_ARGS DISCOUNT_ONLY_LIBRARY DISCOUNT_MAKE_INSTALL
CMAKE_CACHE_ARGS "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true"
......
## 3rd party libraries
This folder contains (patched) versions of libraries and files Cantor depends on.
## DISCOUNT
DISCOUNT is a implementation of Markdown markup language ([link](https://github.com/Orc/discount)).
The version included here provides two additional patches:
* Better LaTeX support: `$` math delimiter and `mkd_e_latex` callback (https://github.com/Orc/discount/pull/214)
* Better recognition of the mathematical expressions between $...$, $$...$$
## standalone.cls
This file provides the LaTeX class and package 'standalone' ([link](https://ctan.org/tex-archive/macros/latex/contrib/standalone)),
which allows TeX pictures or other TeX code in sub-files to be compiled standalone or as part of a main document.
This package is used for the rendering of mathematical LaTeX expressions embedded in the Cantor's worksheet.
->Copyright (C) 2007 David Loren Parsons.
All rights reserved.<-
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of works must retain the original copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the original copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither my name (David L Parsons) nor the names of contributors to
this code may be used to endorse or promote products derived
from this work without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Discount is primarily my work, but it has only reached the point
where it is via contributions, critiques, and bug reports from a
host of other people, some of which are listed before. If your
name isn't on this list, please remind me
-david parsons (orc@pell.portland.or.us)
Josh Wood -- Plan9 support.
Mike Schiraldi -- Reddit style automatic links, MANY MANY MANY
bug reports about boundary conditions and
places where I didn't get it right.
Jjgod Jiang -- Table of contents support.
Petite Abeille -- Many bug reports about places where I didn't
get it right.
Tim Channon -- inspiration for the `mkd_xhtmlpage()` function
Christian Herenz-- Many bug reports regarding my implementation of
`[]()` and `![]()`
A.S.Bradbury -- Portability bug reports for 64 bit systems.
Joyent -- Loan of a solaris box so I could get discount
working under solaris.
Ryan Tomayko -- Portability requests (and the rdiscount ruby
binding.)
yidabu -- feedback on the documentation, bug reports
against utf-8 support.
Pierre Joye -- bug reports, php discount binding.
Masayoshi Sekimura- perl discount binding.
Jeremy Hinegardner- bug reports about list handling.
Andrew White -- bug reports about the format of generated urls.
Steve Huff -- bug reports about Makefile portability (for Fink)
Ignacio Burgue?o-- bug reports about `>%class%`
Henrik Nyh -- bug reports about embedded html handling.
John J. Foerch -- bug reports about incorrect `&ndash;` and `&mdash;`
translations.
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "cstring.h"
#include "markdown.h"
#include "amalloc.h"
/* putc() into a cstring
*/
void
Csputc(int c, Cstring *iot)
{
EXPAND(*iot) = c;
}
/* printf() into a cstring
*/
int
Csprintf(Cstring *iot, char *fmt, ...)
{
va_list ptr;
int siz=100;
do {
RESERVE(*iot, siz);
va_start(ptr, fmt);
siz = vsnprintf(T(*iot)+S(*iot), ALLOCATED(*iot)-S(*iot), fmt, ptr);
va_end(ptr);
} while ( siz > (ALLOCATED(*iot)-S(*iot)) );
S(*iot) += siz;
return siz;
}
/* write() into a cstring
*/
int
Cswrite(Cstring *iot, char *bfr, int size)
{
RESERVE(*iot, size);
memcpy(T(*iot)+S(*iot), bfr, size);
S(*iot) += size;
return size;
}
/* reparse() into a cstring
*/
void
Csreparse(Cstring *iot, char *buf, int size, mkd_flag_t flags)
{
MMIOT f;
___mkd_initmmiot(&f, 0);
___mkd_reparse(buf, size, flags, &f, 0);
___mkd_emblock(&f);
SUFFIX(*iot, T(f.out), S(f.out));
___mkd_freemmiot(&f, 0);
}
HOW TO BUILD AND INSTALL DISCOUNT
1) Unpacking the distribution
The DISCOUNT sources are distributed in tarballs. After extracting from
the tarball, you should end up with all the source and build files in the
directory
discount-(version)
2) Installing the distribution
DISCOUNT uses configure.sh to set itself up for compilation. To run
configure, just do ``./configure.sh'' and it will check your system for
build dependencies and build makefiles for you. If configure.sh finishes
without complaint, you can then do a ``make'' to compile everything and a
``make install'' to install the binaries.
Configure.sh has a few options that can be set:
--src=DIR where the source lives (.)
--prefix=DIR where to install the final product (/usr/local)
--execdir=DIR where to put executables (prefix/bin)
--sbindir=DIR where to put static executables (prefix/sbin)
--confdir=DIR where to put configuration information (/etc)
--libdir=DIR where to put libraries (prefix/lib)
--libexecdir=DIR where to put private executables
--mandir=DIR where to put manpages
--with-amalloc Use my paranoid malloc library to catch memory leaks
--shared Build shared libraries
--debian-glitch When mangling email addresses, do them deterministically
so the Debian regression tester won't complain
--pkg-config Build & install a pkg-config(1) .pc file for
the discount library.
--h1-title Have theme & mkd2html use the first h1 in a document
as the title if there's no pandoc header or title
specified on the command line.
--cxx-binding Wrap mkdio.h with (conditional) 'extern "C"' for c++
binding.
3) Testing
``make test'' runs discount against a collection of test cases.
4) Installing sample programs and manpages
The standard ``make install'' rule just installs the binaries. If you
want to install the sample programs, they are installed with
``make install.samples''; to install manpages, ``make install.man''.
A shortcut to install everything is ``make install.everything''
5) Assorted platform gotchas
1. On NetBSD (version 8 for certain) running configure.sh by
itself will result in logging output being mixed in with diagnostic
output on the screen instead of having it written to config.log.
If, instead, you do `ksh ./configure.sh`, it will be much less
garbled (the shell defaults all fds > stderr to close on exec,
so my redirecting stdout fails after the first subprocess.)
2. On 9Front (and maybe every other extant plan9 variant) the
system mkfile sets the `T' flag in CFLAGS; there are several
places where I typedef voids to opaque structure pointers and
this makes the build die when it attempts to link anything.
CC=@CC@
CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@
AR=@AR@
RANLIB=@RANLIB@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_DIR=@INSTALL_DIR@
INSTALL_DATA=@INSTALL_DATA@
BUILD=$(CC) -fPIC -I. $(CFLAGS)
LINK=$(CC) -fPIC -L. $(LDFLAGS)
.c.o:
$(BUILD) -c -o $@ $<
BINDIR=@exedir@
MANDIR=@mandir@
LIBDIR=@libdir@
INCDIR=@prefix@/include
@MK_PKGCONFIG@PKGDIR=$(LIBDIR)/pkgconfig
PGMS=markdown
SAMPLE_PGMS=mkd2html makepage
@THEME@SAMPLE_PGMS+= theme
MKDLIB=libmarkdown
OBJS=mkdio.o markdown.o dumptree.o generate.o \
resource.o docheader.o version.o toc.o css.o \
xml.o Csio.o xmlpage.o basename.o emmatch.o \
github_flavoured.o setup.o tags.o html5.o \
@AMALLOC@ @H1TITLE@ flags.o
TESTFRAMEWORK=echo cols branch pandoc_headers
# modules that markdown, makepage, mkd2html, &tc use
COMMON=pgm_options.o gethopt.o notspecial.o
MAN3PAGES=mkd-callbacks.3 mkd-functions.3 markdown.3 mkd-line.3
all: $(PGMS) $(SAMPLE_PGMS) $(TESTFRAMEWORK)
install: $(PGMS) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR) $(DESTDIR)$(PKGDIR)
$(INSTALL_PROGRAM) $(PGMS) $(DESTDIR)$(BINDIR)
./librarian.sh install libmarkdown VERSION $(DESTDIR)$(LIBDIR)
$(INSTALL_DATA) mkdio.h $(DESTDIR)$(INCDIR)
@MK_PKGCONFIG@$(INSTALL_DATA) $(MKDLIB).pc $(DESTDIR)$(PKGDIR)
install.everything: install install.samples install.man
install.samples: $(SAMPLE_PGMS) install $(DESTDIR)$(BINDIR)
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man1
for x in $(SAMPLE_PGMS); do \
$(INSTALL_PROGRAM) $$x $(DESTDIR)$(BINDIR)/$(SAMPLE_PFX)$$x; \
$(INSTALL_DATA) $$x.1 $(DESTDIR)$(MANDIR)/man1/$(SAMPLE_PFX)$$x.1; \
done
install.man:
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man3
$(INSTALL_DATA) $(MAN3PAGES) $(DESTDIR)$(MANDIR)/man3
for x in mkd_line mkd_generateline; do \
( echo '.\"' ; echo ".so man3/mkd-line.3" ) > $(DESTDIR)$(MANDIR)/man3/$$x.3;\
done
for x in mkd_in mkd_string; do \
( echo '.\"' ; echo ".so man3/markdown.3" ) > $(DESTDIR)$(MANDIR)/man3/$$x.3;\
done
for x in mkd_compile mkd_css mkd_generatecss mkd_generatehtml mkd_cleanup mkd_doc_title mkd_doc_author mkd_doc_date; do \
( echo '.\"' ; echo ".so man3/mkd-functions.3" ) > $(DESTDIR)$(MANDIR)/man3/$$x.3; \
done
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man7
$(INSTALL_DATA) markdown.7 mkd-extensions.7 $(DESTDIR)$(MANDIR)/man7
$(INSTALL_DIR) $(DESTDIR)$(MANDIR)/man1
$(INSTALL_DATA) markdown.1 $(DESTDIR)$(MANDIR)/man1
install.everything: install install.man
$(DESTDIR)$(BINDIR):
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
$(DESTDIR)$(INCDIR):
$(INSTALL_DIR) $(DESTDIR)$(INCDIR)
$(DESTDIR)$(LIBDIR):
$(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
@MK_PKGCONFIG@$(DESTDIR)$(PKGDIR):
@MK_PKGCONFIG@ $(INSTALL_DIR) $(DESTDIR)$(PKGDIR)
version.o: version.c VERSION branch
$(BUILD) -DBRANCH=`./branch` -DVERSION=\"`cat VERSION`\" -c version.c
VERSION:
@true
tags.o: tags.c cstring.h tags.h blocktags
blocktags: mktags
./mktags > blocktags
mktags: mktags.o
$(LINK) -o mktags mktags.o
# example programs
@THEME@theme: theme.o $(COMMON) $(MKDLIB) mkdio.h
@THEME@ $(LINK) -o theme theme.o $(COMMON) -lmarkdown @LIBS@
mkd2html: mkd2html.o $(MKDLIB) mkdio.h gethopt.h $(COMMON)
$(LINK) -o mkd2html mkd2html.o $(COMMON) -lmarkdown @LIBS@
markdown: main.o $(COMMON) $(MKDLIB)
$(LINK) -o markdown main.o $(COMMON) -lmarkdown @LIBS@
makepage.o: makepage.c mkdio.h
$(BUILD) -c makepage.c
makepage: makepage.o $(COMMON) $(MKDLIB)
$(LINK) -o makepage makepage.o $(COMMON) -lmarkdown @LIBS@
pgm_options.o: pgm_options.c mkdio.h config.h
$(BUILD) -c pgm_options.c
notspecial.o: notspecial.c
$(BUILD) -c notspecial.c
gethopt.o: gethopt.c
$(BUILD) -c gethopt.c
main.o: main.c mkdio.h config.h
$(BUILD) -c main.c
$(MKDLIB): $(OBJS)
./librarian.sh make $(MKDLIB) VERSION $(OBJS)
verify: echo tools/checkbits.sh
@./echo -n "headers ... "; tools/checkbits.sh && echo "GOOD"
test: $(PGMS) $(TESTFRAMEWORK) verify
@for x in $${TESTS:-tests/*.t}; do \
@LD_LIBRARY_PATH@=`pwd` sh $$x || exit 1; \
done
pandoc_headers.o: tools/pandoc_headers.c config.h
$(BUILD) -c -o pandoc_headers.o tools/pandoc_headers.c
pandoc_headers: pandoc_headers.o
$(LINK) -o pandoc_headers pandoc_headers.o $(COMMON) -lmarkdown
branch.o: tools/branch.c config.h
$(BUILD) -c -o branch.o tools/branch.c
branch: branch.o
$(LINK) -o branch branch.o
cols.o: tools/cols.c config.h
$(BUILD) -c -o cols.o tools/cols.c
cols: cols.o
$(LINK) -o cols cols.o
echo.o: tools/echo.c config.h
$(BUILD) -c -o echo.o tools/echo.c
echo: echo.o
$(LINK) -o echo echo.o
clean:
rm -f $(PGMS) $(TESTFRAMEWORK) $(SAMPLE_PGMS) *.o
rm -f $(MKDLIB) `./librarian.sh files $(MKDLIB) VERSION`
distclean spotless: clean
@DISTCLEAN@ @GENERATED_FILES@ @CONFIGURE_FILES@ ./mktags ./blocktags
Csio.o: Csio.c cstring.h amalloc.h config.h markdown.h
amalloc.o: amalloc.c
basename.o: basename.c config.h cstring.h amalloc.h markdown.h
css.o: css.c config.h cstring.h amalloc.h markdown.h
docheader.o: docheader.c config.h cstring.h amalloc.h markdown.h
dumptree.o: dumptree.c markdown.h cstring.h amalloc.h config.h
emmatch.o: emmatch.c config.h cstring.h amalloc.h markdown.h
generate.o: generate.c config.h cstring.h amalloc.h markdown.h
main.o: main.c config.h amalloc.h
pgm_options.o: pgm_options.c pgm_options.h config.h amalloc.h
makepage.o: makepage.c
markdown.o: markdown.c config.h cstring.h amalloc.h markdown.h
mkd2html.o: mkd2html.c config.h mkdio.h cstring.h amalloc.h
mkdio.o: mkdio.c config.h cstring.h amalloc.h markdown.h
resource.o: resource.c config.h cstring.h amalloc.h markdown.h
theme.o: theme.c config.h mkdio.h cstring.h amalloc.h
toc.o: toc.c config.h cstring.h amalloc.h markdown.h
version.o: version.c config.h
xml.o: xml.c config.h cstring.h amalloc.h markdown.h
xmlpage.o: xmlpage.c config.h cstring.h amalloc.h markdown.h
setup.o: setup.c config.h cstring.h amalloc.h markdown.h
github_flavoured.o: github_flavoured.c config.h cstring.h amalloc.h markdown.h
gethopt.o: gethopt.c gethopt.h
h1title.o: h1title.c markdown.h
notspecial.o: notspecial.c config.h
# *Discount* Markdown compiler on Plan 9
## Build
% CONFIG='--with-tabstops=7' mk config
% mk test
% mk install
% markdown -V
markdown: discount X.Y.Z TAB=7
### Configuration
To select features and extensions, `--with-tabstops=7` may be replaced by zero or more of:
* `--enable-pandoc-header`: Use pandoc-style header blocks
* `--enable-superscript`: `A^B` becomes A<sup>B</sup>
* `--enable-amalloc`: Enable memory allocation debugging
* `--with-tabstops=`*N*: Set tabstops to *N* characters (default 4)
* `--enable-alpha-list`: Enable `(a)/(b)/(c)` list markers
* `--enable-all-features`: Turn on all stable optional features
## Notes
1. This is not a port from POSIX to native Plan 9 APIs. The supplied
`mkfile` merely drives Discount's own `configure.sh` through Plan 9's
*APE* environment (in *pcc*(1)) to build the Discount source, then
copies the result to locations appropriate for system-wide use on
Plan 9.
2. There are a few other *mk*(1) targets:
* `install.libs`: Discount includes a C library and header.
Installation is optional. Plan 9 binaries are statically linked.
* `install.man`: Add manual pages for *markdown* in sections 1, 2, and 6.
* `install.progs`: Extra programs. *makepage* writes complete XHTML
documents, rather than fragments. *mkd2html* is similar, but produces
HTML.
.TH MARKDOWN 1
.SH NAME
markdown \- convert Markdown text to HTML
.SH SYNOPSIS
.B markdown
[
.B -dTV
]
[
.BI -b " url-base
]
[
.BI -F " bitmap
]
[
.BI -f " flags
]
[
.BI -o " ofile
]
[
.BI -s " text
]
[
.BI -t " text
]
[
.I file
]
.SH DESCRIPTION
The
.I markdown
utility reads the
.IR Markdown (6)-formatted
.I file
(or standard input) and writes its
.SM HTML
fragment representation on standard output.
.PP
The options are:
.TF dfdoptions
.TP
.BI -b " url-base
Links in source begining with
.B /
will be prefixed with
.I url-base
in the output.
.TP
.B -d
Instead of printing an
.SM HTML
fragment, print a parse tree.
.TP
.BI -F " bitmap
Set translation flags.
.I Bitmap
is a bit map of the various configuration options described in
.IR markdown (2).
.TP
.BI -f " flags
Set or clear various translation
.IR flags ,
described below.
.I Flags
are in a comma-delimited list, with an optional
.B +
(set) prefix on each flag.
.TP
.BI -o " ofile
Write the generated
.SM HTML
to
.IR ofile .
.TP
.BI -s " text
Use the
.IR markdown (2)
function to format the
.I text
on standard input.
.TP
.B -T
Under
.B -f
.BR toc ,
print the table of contents as an unordered list before the usual
.SM HTML
output.
.TP
.BI -t " text
Use
.IR mkd_text
(in
.IR markdown (2))
to format
.I text
instead of processing standard input with
.IR markdown .
.TP
.B -V
Show version number and configuration. If the version includes the string
.BR DL_TAG ,
.I markdown
was configured with definition list support. If the version includes the string
.BR HEADER ,
.I markdown
was configured to support pandoc header blocks.
.PD
.SS TRANSLATION FLAGS
The translation flags understood by
.B -f
are:
.TF \ noheader
.TP
.B noimage
Don't allow image tags.
.TP
.B nolinks
Don't allow links.
.TP
.B nohtml
Don't allow any embedded HTML.
.TP
.B cdata
Generate valid XML output.
.TP
.B noheader
Do not process pandoc headers.
.TP
.B notables
Do not process the syntax extension for tables.
.TP
.B tabstops
Use Markdown-standard 4-space tabstops.
.TP
.B strict
Disable superscript and relaxed emphasis.
.TP