From 03c3561f2c8d4a88d3ef9dccab3a1d5605ec4f63 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 13 Dec 2021 00:57:15 +0300 Subject: [PATCH] experimenting with md generation... Signed-off-by: Alex A. Naanou --- Makefile | 68 +++++++++++++++++++++++++++++++++++++++++++++++-------- README.md | 2 +- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 2ef5174..6022c74 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ # # # Main targets: -# doc - build class documentation +# pdf - build class pdf documentation... +# md - build class markdown documentation (XXX EXPERIMENTAL)... # # Distribution and install: # dist - build a distributable zip @@ -79,7 +80,6 @@ COMMIT = $(strip $(shell git rev-parse HEAD)) # - link vs. copy/strip # - $(LN) vs. $(INSTALL) in the install target... CODE_INSTALL ?= strip - ifeq ($(CODE_INSTALL),strip) MODULE_CODE := $(MODULE)-stripped else @@ -87,6 +87,24 @@ else endif +# markdown dialect... +# +# XXX still needs some tweaking... +MD_FORMAT ?= markdown_github + + +# debug output... +# +# $DEBUG can either be empty or anything else... +DEBUG ?= +ifeq ($(DEBUG),) + STDERR := > /dev/null +else + STDERR := +endif + + + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Paths and files... @@ -139,11 +157,39 @@ LN := cp -l #---------------------------------------------------------------------- # Rules... +# docs (pdf)... +# %.pdf: %.tex - $(TEX) $< > /dev/null + $(TEX) $< $(STDERR) + +# docs (markdown)... +# +# XXX this still needs some tweaking... +# - |..| - verbatim does not work... +# - || - parts of doc omitted... +# - verbatim blocks get merged sometimes... +# - ... +#%.md: %.tex +# pandoc -t $(MD_FORMAT) -s $< -o $@ + +# XXX STUB/HACK... +# ...need to call $(TEX) on the result... +# ...need to install the internet class... +# https://github.com/loopspace/latex-to-internet +# XXX revise: +# ...for this to work we need to replace: +# \documentclass{ltxdoc} +# to: +# \documentclass[markdownextra]{internet} +%.md: %.tex + cat $< \ + | sed 's/documentclass{ltxdoc}/documentclass[markdownextra]{internet}/' \ + > $<.tmp + mv $<{.tmp,} + $(TEX) $< $(STDERR) -# docs... +# meta-section... # # NOTE: .sty and .cls are essentially the same in terms of documentation # generation... @@ -197,8 +243,12 @@ version: #---------------------------------------------------------------------- # Main targets... -.PHONY: doc -doc: $(MODULE).pdf +.PHONY: pdf +pdf: $(MODULE).pdf + + +.PHONY: md +md: $(MODULE).md # XXX STUB -- not sure how to approach this yet... @@ -218,7 +268,7 @@ dist: $(DIST_FILES) .PHONY: all -all: doc +all: pdf # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -233,7 +283,7 @@ all: doc # user install... .PHONY: install -install: doc $(MODULE_CODE).cls +install: pdf $(MODULE_CODE).cls $(MD) $(INSTALL_PATH)/{tex,source,doc}/latex/$(MODULE) $(INSTALL) "$(MODULE).pdf" $(INSTALL_PATH)/doc/latex/$(MODULE) $(INSTALL) "$(MODULE_CODE).cls" $(INSTALL_PATH)/tex/latex/$(MODULE)/$(MODULE).cls @@ -300,7 +350,7 @@ sweep: .PHONY: clean clean: sweep - rm -rf $(DIST_DIR) $(BUILD_DIR) *.pdf + rm -rf $(DIST_DIR) $(BUILD_DIR) $(MODULE).md *.pdf diff --git a/README.md b/README.md index e6db054..ae156f0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ LaTeX class for making photo books. -## Build requirements +## Build requirements for docs - LaTeX tool chain (including: `lualatex`, `latexmk`, ..) The simplest way to get started is [TeX Live](https://www.tug.org/texlive/),