Skip to content

Instantly share code, notes, and snippets.

@neverkas
Last active February 2, 2022 18:06
Show Gist options
  • Select an option

  • Save neverkas/3073b9bc4c86f275f3c6e2e38d83b99d to your computer and use it in GitHub Desktop.

Select an option

Save neverkas/3073b9bc4c86f275f3c6e2e38d83b99d to your computer and use it in GitHub Desktop.
Exportar .org a HTML (Versión Simple)
ORG_PATH := src/org-doc
HTML_PATH := views
ORG := $(wildcard $(ORG_PATH)/*.org)
# fundamental evitar espacios en $(var:%.old=%.new)
HTML = $(ORG:$(ORG_PATH)/%.org=$(HTML_PATH)/%.html)
RM := rm -rfv
.PHONY: all
all: export
.PHONY: export
export: $(HTML)
.PHONY: clean
clean:
@echo "TAREA: Borrando archivos html..."
@-$(RM) $(HTML)
# - la orden asociada a la regla de patrón se ejecuta
# cuando alguna de las dependencias .org tenga un timestamp
# más reciente que su objetivo
# - la macro automática $< se expande a $(ORG_PATH)/$*.org
# - la macro automática $@ se expande a $(HTML_PATH)/$*.html
$(HTML):$(HTML_PATH)/%.html:$(ORG_PATH)/%.org
@echo "TAREA: Exportando a html el fichero $(notdir $<) ..."
@docker run --rm \
--volume "$(shell pwd):/data" \
--user $(shell id -u):$(shell id -g) \
pandoc/minimal $< -o $@
# esta regla no tendria el comportamiento esperado...
# no evaluaría cambios específicos por dependencia, exportaría cada .org
# $(HTML): $(ORG)
# @echo "tratando $@ : $< , $^"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment