Compare commits

...

3 Commits

Author SHA1 Message Date
Anders Damsgaard
e56e6e57aa Makefile: do not hardcode optimization and linker flags
Adhere to git://bitreich.org/bitreich-style/c/makefile-guideline.txt

71 * $CFLAGS: do not hard-code optimization flags like (-O2) or diagnostic flags
72   such as -Wall, -Wextra, -pedantic. Even more importantly, do not
73   specify unportable compiler flags.
74
75 * $LDFLAGS: do not hard-code linker flags like -s (symbol stripping) or -g,
76   -static or such flags.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2021-06-14 12:31:37 +02:00
Christoph Lohmann
e0d87452da Add pptx2md converter. 2021-06-13 14:41:14 +02:00
Christoph Lohmann
ad95b9aa56 Only allo a-zA-Z0-9_ in filenames.
Thanks Od1n for reporting this.
2021-06-13 14:00:52 +02:00
5 changed files with 69 additions and 16 deletions

View File

@ -21,6 +21,7 @@ install:
install -m 755 bin/dir2point $(DESTDIR)$(PREFIX)/bin/dir2point install -m 755 bin/dir2point $(DESTDIR)$(PREFIX)/bin/dir2point
install -m 755 bin/md2point $(DESTDIR)$(PREFIX)/bin/md2point install -m 755 bin/md2point $(DESTDIR)$(PREFIX)/bin/md2point
install -m 755 bin/point2pdf $(DESTDIR)$(PREFIX)/bin/point2pdf install -m 755 bin/point2pdf $(DESTDIR)$(PREFIX)/bin/point2pdf
install -m 755 bin/pptx2md $(DESTDIR)$(PREFIX)/bin/pptx2md
mkdir -p $(DESTDIR)$(MANPREFIX)/man1 mkdir -p $(DESTDIR)$(MANPREFIX)/man1
install -m 644 md2point.1 $(DESTDIR)$(MANPREFIX)/man1/md2point.1 install -m 644 md2point.1 $(DESTDIR)$(MANPREFIX)/man1/md2point.1

55
bin/pptx2md Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
#
# See LICENSE for license details.
#
# This is based on:
# https://github.com/revan/pptx2md
#
# The algorithm was simplified to the essence of what the ugly
# pptx format is capable of. Microsoft amateurs are unable to use
# XML properly.
#
# Requires: xml2tsv (git://bitreich.org/xml2tsv)
#
if [ $# -lt 1 ];
then
printf "usage: %s file.pptx\n" "$(basename "$0")" >&2
exit 1
fi
pptxfile="$1"
mdfile="$1.md"
tmpdir="$(mktemp -u)"
unzip -oq -d "${tmpdir}" "${pptxfile}"
if [ $? -ne 0 ];
then
printf "Failed to extract %s.\n" "${pptxfile}"
exit 1
fi
for slidefile in ${tmpdir}/ppt/slides/*.xml;
do
linenum=0
cat "${slidefile}" \
| xml2tsv 2>/dev/null \
| grep a:r/a:t \
| cut -s -f 2 \
| while read -r line;
do
if [ $linenum -eq 0 ];
then
printf "## %s\n" "${line}" >> "${mdfile}"
else
printf "%s\n" "${line}" >> "${mdfile}"
fi
linenum=1
done
printf "\n" >> "${mdfile}"
done
rm -r "$tmpdir"
exit 0

View File

@ -16,8 +16,8 @@ CPPFLAGS = -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -DNEED_STRLCPY
# BSD # BSD
#CPPFLAGS = -DVERSION=\"${VERSION}\" #CPPFLAGS = -DVERSION=\"${VERSION}\"
CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS} CFLAGS += -std=c99 ${INCS} ${CPPFLAGS}
LDFLAGS += -g ${LIBS} LDFLAGS += ${LIBS}
# compiler and linker # compiler and linker
# CC = cc # CC = cc

BIN
examples/pptx/example.pptx Normal file

Binary file not shown.

View File

@ -62,23 +62,20 @@ void
escapechars(char *s) escapechars(char *s)
{ {
for (; *s; s++) { for (; *s; s++) {
switch (*s) { if (*s == '\n') {
case '#':
case ' ':
case '\t':
case ':':
case '.':
case '(':
case ')':
case '/':
*s = '_';
break;
case '\n':
*s = '\0'; *s = '\0';
return; return;
default:
break;
} }
/*
* Only allow ASCII printable a-zA-Z0-9 for simplicity.
*/
if ((*s >= 'a' && *s <= 'z')
|| (*s >= 'A' && *s <= 'Z')
|| (*s >= '0' && *s <= '9')) {
continue;
}
*s = '_';
} }
} }