{"id":13593005,"url":"https://github.com/fniessen/orgmk","last_synced_at":"2025-04-09T02:32:03.091Z","repository":{"id":14646939,"uuid":"17364865","full_name":"fniessen/orgmk","owner":"fniessen","description":"Streamline your Org document exports to PDF, HTML, DOC, and more with OrgMk. Simplify document compilation and enhance productivity. #orgmode #productivity #automation","archived":false,"fork":false,"pushed_at":"2025-01-12T11:36:39.000Z","size":484,"stargazers_count":228,"open_issues_count":7,"forks_count":28,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-01-12T12:31:00.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fniessen.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-03T12:04:27.000Z","updated_at":"2025-01-12T11:36:42.000Z","dependencies_parsed_at":"2025-01-05T12:26:01.063Z","dependency_job_id":"fb845fec-cb11-4f40-8c1b-e90585f00da7","html_url":"https://github.com/fniessen/orgmk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fniessen%2Forgmk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fniessen%2Forgmk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fniessen%2Forgmk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fniessen%2Forgmk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fniessen","download_url":"https://codeload.github.com/fniessen/orgmk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247965619,"owners_count":21025407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T16:01:15.561Z","updated_at":"2025-04-09T02:32:03.068Z","avatar_url":"https://github.com/fniessen.png","language":"Emacs Lisp","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=VCVAS6KPDQ4JC\u0026lc=BE\u0026item_number=orgmk\u0026currency_code=EUR\u0026bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted"],"categories":["Emacs Lisp"],"sub_categories":[],"readme":"#+TITLE:     Export Org mode documents to HTML, PDF, etc.\n#+AUTHOR:    Fabrice Niessen\n#+EMAIL:     (concat \"fniessen\" at-sign \"pirilampo.org\")\n#+DESCRIPTION: Orgmk completely automates the export of Org documents.\n#+KEYWORDS:  org-mode, orgmk, export, automate, emacs, pdf, latex, html\n#+LANGUAGE:  en\n#+OPTIONS:   H:4 toc:t num:nil\n\n#+PROPERTY:  header-args :eval no :noweb yes :comments no\n#+SETUPFILE: ~/org/theme-readtheorg.setup\n\n#+begin_export html\n\u003ca href=\"http://opensource.org/licenses/GPL-3.0\"\u003e\n  \u003cimg src=\"http://img.shields.io/:license-gpl-blue.svg\" alt=\":license-gpl-blue.svg\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=VCVAS6KPDQ4JC\u0026lc=BE\u0026item_number=orgmk\u0026currency_code=EUR\u0026bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted\"\u003e\n  \u003cimg src=\"https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif\" alt=\"btn_donate_LG.gif\" /\u003e\n\u003c/a\u003e\n#+end_export\n\n#+begin_quote\n[!TIP]\n\n*** Elevate your Emacs skills in Paris, Utrecht, Leuven or Valencia!\n*Unlock the power of Emacs!  Join my next exclusive \"Emacs Boost\" course!*\n\nReady to /supercharge your productivity/ and become an Emacs ninja?  Look no\nfurther!\n\n*What you'll learn:*\n- Master Emacs from the basics to advanced tricks.\n- /Boost your editing efficiency/ and streamline your workflow.\n- Customize Emacs to fit your unique needs.\n- And much more!\n\n*Audience:*\n\nOpen to anyone interested in Emacs, from beginners to advanced\nusers.\n\n*Why choose my course?*\n- Expert instructor with 25 years of Emacs experience.\n- /Hands-on exercises/ to reinforce your learning.\n- /Networking opportunities/ with like-minded Emacs enthusiasts.\n- Personalized attention.\n\nDon't miss this opportunity to take your Emacs skills to the next level! \\\\\n\nVisit https://emacsboost.com/en/ for more information, dates and locations, and\nto /reserve your seat/.\n#+end_quote\n\n* Overview\n\n** Description\n\nOrgmk is a suite of Bash scripts for *automating the conversion of Org mode\ndocuments to different formats* (such as HTML or PDF) from the command line.\n\n#+begin_export html\n\u003cscript src=\"http://platform.twitter.com/widgets.js\"\u003e\u003c/script\u003e\n\u003ca href=\"https://twitter.com/share\" class=\"twitter-share-button\" data-via=\"f_niessen\"\u003eTweet\u003c/a\u003e\n#+end_export\n\nThe scripts run on both Unix and Microsoft Windows (with Cygwin).\n\n** Objectives\n\nThe first goal is to *be more productive*, by running the export only when the\nsource Org files are updated.\n\nThe second goal is to *share some common Emacs and Org configuration inside your*\n*team*, separately of what you have in your personal Emacs configuration file.\n\nFinally, the third goal is also to *offload compilation into an external batch\nEmacs process*, allowing you to go on editing or working while exporting the\ndocuments.\n\n** Quotations\n\n\"If one has been trying to bulk convert many quickly changing org-documents,\n[one] will appreciate the power and flexibility of this tool.\" \\\\\n-- /z27/\n\n\"Orgmk is a wonderful tool, and, as far as I know, still unique.\" \\\\\n-- /Priyadarshan/\n\n** Requirements\n   :PROPERTIES:\n   :header-args+: :tangle no\n   :END:\n\n*** Emacs 24+\n\nEmacs version 24 (for the ~package~ facility) must be in your =PATH=.\n\n*** Org 8+\n\nOrg mode version 8 (or later) is required.\n\nIf such a version is not bundled with your Emacs, Org 8 will be automatically\ninstalled -- if you accept it! -- through ELPA.\n\n*** LaTeX (PDF)\n\nA working LaTeX installation is required for exporting to PDF. If it is not\nyet installed on your system, install [[http://www.tug.org/texlive/][TeX Live]] (for example).\n\n* Usage\n\nOrg files can have the extension ~.org~ or ~.txt~.\n\n** Standalone scripts\n\n- For \"weaving\" files (producing the formatted documentation files):\n\n  #+begin_src shell\n  org2html [OPTION] FILE\n  org2latex [OPTION] FILE\n  org2pdf [OPTION] FILE\n  org2beamerpdf [OPTION] FILE\n  org2odt [OPTION] FILE\n  org2txt [OPTION] FILE\n  #+end_src\n\n- For \"tangling\" files:\n\n  #+begin_src shell\n  org-tangle FILE\n  #+end_src\n\n** Makefile wrapper\n\n#+begin_src shell\norgmk [OPTION]\norgmk [OPTION] [html | pdf]\norgmk [OPTION] [FILE]\n#+end_src\n\nCurrently, =orgmk= does not tangle Org files.\n\n* Options\n\n** Standalone scripts\n\n- =-h=, =--help= ::\n     Print usage information and exit.\n\n- =-y= ::\n     Authorize the update of the source file (update of dynamic blocks and\n     re-computation of tables) without confirmation.\n\n     Before the conversion, the standalone scripts will try to *update all\n     dynamic blocks and recompute all tables* in the source Org file, a\n     *potentially destructive operation* for which the programs require\n     confirmation: in case the source file gets updated, you will be queried to\n     overwrite the source file with the updated version of the file -- that's\n     because the environment variable =UPDATE_SRC= defaults to =query=.\n\n     To avoid the question, you can also set that variable to =yes= or =no= in a\n     personal configuration file, =~/.orgmk-rc=.\n\n     Note that, by design, the command line argument =-y= is passed to every\n     =org2\u003cBACKEND\u003e= script called from =orgmk=, so that =orgmk= doesn't wait for\n     answers.\n\n- =--body-only= ::\n     Export only body (for HTML and LaTeX).\n\n** Makefile wrapper\n\n- =-h=, =--help= ::\n     Print usage information and exit.\n\n- =-r=, =--recursive= ::\n     Export all Org files *under each directory, recursively*.\n\n     It just calls =orgmk.mk= with the argument =ALLSUBDIRS=yes=.\n\n     By default, =orgmk= exports all Org files (which need it) in the current\n     directory only.\n\n* Files\n\n[[~/.orgmk-rc]]\n\n* Examples\n\n** Update all documents\n\nRegenerate HTML and/or PDF files for Org files that have been modified.\n\n#+begin_src shell\norgmk\n#+end_src\n\n** Update specific types of documents\n\nRegenerate HTML only for the Org files that have been changed.\n\n#+begin_src shell\norgmk html\n#+end_src\n\n** Update specific document\n\nRegenerate (or create for the first time) the file ~thesis.pdf~ from the Org file\n~thesis.org~ or ~thesis.txt~. *Don't require confirmation for updating the source\nfile.*\n\n#+begin_src shell\norgmk thesis.pdf\n#+end_src\n\nRegenerate (or create for the first time) the file ~thesis.pdf~ from the Org file\n~thesis.org~. Require confirmation for updating the source file.\n\n#+begin_src shell\norg2pdf thesis.org\n#+end_src\n\n* Installation\n\nThe installation process consists of creating symbolic links from the standard\n*final directories* on your machine to the =orgmk= executables.\n\n** Installing from the Git repository\n\n# See one-line for installation at https://github.com/tj/git-extras\n\n1. *Extract* the latest version of =orgmk=.\n\n   #+begin_src shell\n   git clone git@github.com:fniessen/orgmk.git\n   #+end_src\n\n2. Create configuration files which record where =orgmk= has been extracted\n   on your host machine.\n\n   #+begin_src shell\n   make\n   #+end_src\n\n3. By default, the =orgmk= executable and the standalone scripts (=org2html=,\n   =org2pdf=, etc.) are installed to the ~/usr/local/bin~ so that all users are\n   able to run them.\n\n   If you want to *change the destination directory*, create a ~Make.params~ file\n   with the target directory. For example:\n\n   #+begin_src makefile\n   BIN_DIR=~/bin\n   #+end_src\n\n   If needed, add that directory to your =PATH=.\n\n   *Install* =orgmk= (executable and standalone scripts that you run) to the\n   =BIN_DIR= location by typing:\n\n   #+begin_src shell\n   make install\n   #+end_src\n\nAt this point, everything should be ready for use.\n\n** Makefile for installation\n   :PROPERTIES:\n   :header-args+: :shebang \"\" :tangle Makefile\n   :END:\n\n#+begin_src makefile\n### -*- Makefile -*- definition file for Orgmk\n\n# To install `orgmk', type `make' and then `make install'.\n\nPWD=$(shell pwd)\n\nBIN_DIR=/usr/local/bin\n\n-include Make.params\n\nORGMK_ROOT=$(PWD)\nORGMK_EL=$(ORGMK_ROOT)/site-lisp/orgmk.el\n\n# WARNING -- ORGMK_EL must contain the correct path to the `orgmk.el' file\n# according to the Emacs version used (Windows, Cygwin or Linux path).\nEMACS_SYSTEM_TYPE=$(shell emacs -batch --eval \"(message \\\"%s\\\" system-type)\" 2\u003e\u00261)\nifeq ($(EMACS_SYSTEM_TYPE),windows-nt)\n\tORGMK_EL:=\"$(shell cygpath --mixed $(ORGMK_EL))\"\nendif\n\nORGMK_INIT=orgmk-init\nORGMK_SYSTEM_CONFIG=orgmk.conf\nORGMK_UPDATE_CHECK_DIFF=orgmk-update-src-check-diff\nORG2HTML=org2html\nORG2GFM=org2gfm\nORG2MD=org2md\n# ORG2REVEAL=org2reveal\nORG2LATEX=org2latex\nORG2PDF=org2pdf\nORG2BEAMERPDF=org2beamerpdf\nORG2ODT=org2odt\nORG2TXT=org2txt\nORGTANGLE=org-tangle\nORGMK_MAKE_SETUP=orgmk-stow-orgmk.mk\nORGMK_MAKE_RUN=orgmk\n\n## MAKE\n\n# Ensure `all' is the default target\nall: bin/$(ORGMK_SYSTEM_CONFIG) bin/$(ORGMK_MAKE_SETUP)  # Create Orgmk system files\n\nbin/$(ORGMK_SYSTEM_CONFIG):                    # Create file with location of `orgmk.el'\n\t@echo \"Generating system-wide configuration file...\"\n\techo \"ORGMK_EL=$(ORGMK_EL)\" \u003e bin/$(ORGMK_SYSTEM_CONFIG)\n\t@echo\n\nbin/$(ORGMK_MAKE_SETUP):                          # Create core file for `orgmk'\n\t@echo \"Generating setup file...\"\n\techo \"#!/bin/sh\" \u003e bin/$(ORGMK_MAKE_SETUP)\n\techo \"ln -f -s $(PWD)/bin/orgmk.mk orgmk.mk\" \u003e\u003e bin/$(ORGMK_MAKE_SETUP)\n\tchmod u+x bin/$(ORGMK_MAKE_SETUP)\n\t@echo\n\n## MAKE INSTALL\n\n.PHONY: install\ninstall: all                            # Create symlinks to Orgmk scripts\n\t@echo \"Creating symlinks...\"\n\tln -f -s $(PWD)/bin/$(ORGMK_INIT)              $(BIN_DIR)/$(ORGMK_INIT)\n\tln -f -s $(PWD)/bin/$(ORGMK_SYSTEM_CONFIG)     $(BIN_DIR)/$(ORGMK_SYSTEM_CONFIG)\n\tln -f -s $(PWD)/bin/$(ORGMK_UPDATE_CHECK_DIFF) $(BIN_DIR)/$(ORGMK_UPDATE_CHECK_DIFF)\n\tln -f -s $(PWD)/bin/$(ORG2HTML)                $(BIN_DIR)/$(ORG2HTML)\n\tln -f -s $(PWD)/bin/$(ORG2GFM)                 $(BIN_DIR)/$(ORG2GFM)\n\tln -f -s $(PWD)/bin/$(ORG2MD)                  $(BIN_DIR)/$(ORG2MD)\n\t# ln -f -s $(PWD)/bin/$(ORG2REVEAL)              $(BIN_DIR)/$(ORG2REVEAL)\n\tln -f -s $(PWD)/bin/$(ORG2LATEX)               $(BIN_DIR)/$(ORG2LATEX)\n\tln -f -s $(PWD)/bin/$(ORG2PDF)                 $(BIN_DIR)/$(ORG2PDF)\n\tln -f -s $(PWD)/bin/$(ORG2BEAMERPDF)           $(BIN_DIR)/$(ORG2BEAMERPDF)\n\tln -f -s $(PWD)/bin/$(ORG2ODT)                 $(BIN_DIR)/$(ORG2ODT)\n\tln -f -s $(PWD)/bin/$(ORG2TXT)                 $(BIN_DIR)/$(ORG2TXT)\n\tln -f -s $(PWD)/bin/$(ORGTANGLE)               $(BIN_DIR)/$(ORGTANGLE)\n\tln -f -s $(PWD)/bin/$(ORGMK_MAKE_SETUP)        $(BIN_DIR)/$(ORGMK_MAKE_SETUP)\n\tln -f -s $(PWD)/bin/$(ORGMK_MAKE_RUN)          $(BIN_DIR)/$(ORGMK_MAKE_RUN)\n\n### Makefile ends here\n#+end_src\n\n* Standalone scripts\n\n** Orgmk-init\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/orgmk-init\n   :END:\n\nThe =orgmk-init= script contains the common part used to setup Emacs\nand Org in order to export to HTML, PDF, etc.\n\n*** Functions\n\n#+begin_src shell\nUsage ()\n{\n    cat \u003c\u003c EOF 1\u003e\u00262\nUsage: $(basename $0) [OPTION] FILE\nConvert FILE to another format.\n\n  -h, --help     display this help and exit\n  -y             authorize update of the source file without confirmation\n  --body-only    export only body (for HTML and LaTeX exports)\nEOF\n    exit 1\n}\n#+end_src\n\n#+begin_src shell\ndie () {\n    printf \"$(basename $0): $@\\n\" \u003e /dev/stderr\n    exit 2 # an error occurred\n}\n#+end_src\n\n#+begin_src shell\nCleanUp ()\n{\n    # restore backed up target file if it hasn't been produced\n    if [ ! -z $FILE_TARGET ]; then\n        if [ -r $FILE_TARGET.orig ]; then\n            if [ ! -r $FILE_TARGET ]; then\n                printf \"Recovering OLD file $FILE_TARGET...\\n\"\n                mv $FILE_TARGET.orig $FILE_TARGET\n            else\n                rm $FILE_TARGET.orig\n            fi\n        fi\n    fi\n\n    # display log file, if present\n    if [ ! -z $FILE_LOG ]; then\n        if [ -r $FILE_LOG ]; then\n            grep -e \"^!.*\" -A 3 -B 1 $FILE_LOG\n        fi\n    fi\n\n    # remove the temporary copy of the source Org file\n    if [ ! -z $FILE_SRC_UPDT ]; then\n        rm -f $FILE_SRC_UPDT\n    fi\n}\n#+end_src\n\n*** Runtime\n\n#+name: current-time\n#+begin_src emacs-lisp :eval yes :results silent :tangle no\n(format-time-string \"\u003c%Y%m%d.%H%M\u003e\")\n#+end_src\n\n#+begin_src shell\n    cat \u003c\u003c EOF\nThis is $(basename $0), version: \u003c\u003ccurrent-time()\u003e\u003e.\nEOF\n#+end_src\n\n#+begin_src shell\n# perform housekeeping on program exit or a variety of signals\n# (EXIT, HUP, INT, QUIT, TERM)\ntrap CleanUp 0 1 2 3 15\n#+end_src\n\n#+begin_src shell\n# load the system-wide config file (definition of `ORGMK_EL')\n. orgmk.conf\n\nif [ \"$ORGMK_EL\" = \"\" ]; then\n    printf \"ORGMK_EL variable not defined, please check your setup!\\n\"\n    exit 2\nfi\n\n# source the user config file (default for `UPDATE_SRC', etc.)\nORGMK_USER_CONF=$HOME/.orgmk-rc\nif [ -r $ORGMK_USER_CONF ]; then\n    . $ORGMK_USER_CONF\nfi\n\nexport UPDATE_SRC\n\n# set a default value\nexport BODY_ONLY=\"no\"\n\nwhile true; do\n    case \"$1\" in\n        -y ) UPDATE_SRC=\"yes\"; shift ;;\n        --body-only ) BODY_ONLY=\"yes\"; shift ;;\n        -h | --help ) Usage ;;\n        ,* ) break ;;\n    esac\ndone\n# now do something with $@\n#+end_src\n\n#+begin_src shell\nif [ $# -ne 1 ]; then\n    Usage\nfi\n\nFILE_SRC_ORIG=$1\nif [ ! -r \"$FILE_SRC_ORIG\" ]; then\n    die \"Cannot read file $FILE_SRC_ORIG\"\nfi\n\nFILE_SRC_UPDT=\"${FILE_SRC_ORIG%.*}.orgmk\" # replace extension\n# The temporary file only differ by its extension (`.orgmk'), so that the\n# exported file will be named \u003corig file name\u003e.\u003cbackend ext\u003e.\n#+end_src\n\n#+begin_src shell\nFILE_LOG=\"${FILE_SRC_ORIG%.*}.log\"\nrm -f $FILE_LOG\n#+end_src\n\nIf the PDF file isn't produced (for example, because of an /undefined control\nsequence/), there is no PDF file anymore; hence, =orgmk= would ignore the source\nfile in future calls, and the PDF file (now, missing...) would completely\ndisappear from the user attention.\n\nTo avoid that, we must make a backup of the target file before the export, and\nput it back if there is no target file produced.\n\n#+begin_src shell\nFILE_TARGET=\"${FILE_SRC_ORIG%.*}.$TARGET_EXT\"\n\n# back up previous version of target file\nif [ -r $FILE_TARGET ]; then\n    mv $FILE_TARGET $FILE_TARGET.orig\nfi\n#+end_src\n\nNote that, like with the ~patch~ command, the original file is saved with the\n=.orig= extension.\n\n#+begin_src shell\nEMACS=emacs\n\nWHICH_EMACS=$(which $EMACS)\nEMACS_FLAGS=\"--eval \\\"(progn (message \\\\\\\"Launching $WHICH_EMACS...\\\\\\\") (message \\\\\\\"Emacs %s (%s)\\\\\\\" emacs-version system-type))\\\"\"\nEMACS_BATCH=\"emacs --batch -Q $EMACS_FLAGS\"\nORG_FLAGS=\"\"\nORGMK=\"$EMACS_BATCH $ORG_FLAGS --eval \\\"(message \\\\\\\"Loading ${ORGMK_EL}...\\\\\\\")\\\" -l $ORGMK_EL\"\nORGMK_UPDATE_FLAGS=\"-f org-update-all-dblocks -f org-table-iterate-buffer-tables --eval \\\"(write-file \\\\\\\"${FILE_SRC_UPDT##*/}\\\\\\\")\\\"\" # base name\n#+end_src\n\n#+begin_note\n*Batch option* \\\\\nFont Lock mode is disabled by default in batch mode.  That generates errors with\nsome Java code blocks.  Hence, one workaround, in that case, is to call Emacs\nwithout batch mode (and, then, to add ~-f kill-emacs~, or simply ~--kill~, at the\nend of the command line).\n#+end_note\n\n** org2html\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org2html\n   :END:\n\nThe =org2html= script converts an Org file to HTML.\n\n#+begin_src shell\nTARGET_EXT=html\n. orgmk-init\n\ncase $BODY_ONLY in\n    \"yes\")\n        eval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-html-export-body-only-to-html \\\n            || die \"Exported file wasn't produced\"\n        ;;\n    \"no\")\n        eval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-html-export-to-html \\\n            || die \"Exported file wasn't produced\"\nesac\n\norgmk-update-src-check-diff \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\"\n#+end_src\n\n** org2latex\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org2latex\n   :END:\n\nThe =org2latex= script converts an Org file to LaTeX.\n\n#+begin_src shell\nTARGET_EXT=tex\n. orgmk-init\n\ncase $BODY_ONLY in\n    \"yes\")\n        eval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-latex-export-body-only-to-latex \\\n            || die \"Exported file wasn't produced\"\n        ;;\n    \"no\")\n        if grep -E \"^#\\+BEAMER_THEME: \" $FILE_SRC_ORIG \u003e /dev/null; then\n            eval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-beamer-export-to-latex \\\n                || die \"Exported file wasn't produced\"\n        else\n            eval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-latex-export-to-latex \\\n                || die \"Exported file wasn't produced\"\n        fi\nesac\n\norgmk-update-src-check-diff \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\"\n#+end_src\n\n** org2pdf\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org2pdf\n   :END:\n\nThe =org2pdf= script converts an Org file to PDF.\n\n#+begin_note\nIt tries to detect whether the target is a standard LaTeX document or a Beamer\npresentation by searching for the string =#+BEAMER_THEME:= inside the Org source.\n#+end_note\n\n#+begin_src shell\nTARGET_EXT=pdf\n. orgmk-init\n\nif grep -E \"^#\\+BEAMER_THEME: \" $FILE_SRC_ORIG \u003e /dev/null; then\n    eval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-beamer-export-to-latex \\\n        || die \"Exported file wasn't produced\"\nelse\n    eval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-latex-export-to-latex \\\n        || die \"Exported file wasn't produced\"\nfi\norgmk-update-src-check-diff \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\"\n#+end_src\n\n** org2beamerpdf\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org2beamerpdf\n   :END:\n\nThe =org2beamerpdf= script converts an Org file to a Beamer presentation (PDF).\n\n#+begin_src shell\nTARGET_EXT=pdf\n. orgmk-init\n\neval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-beamer-export-to-pdf \\\n    || die \"Exported file wasn't produced\"\norgmk-update-src-check-diff \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\"\n#+end_src\n\n** org2odt\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org2odt\n   :END:\n\nThe =org2odt= script converts an Org file to ODT.\n\n#+begin_src shell\nTARGET_EXT=odt\n. orgmk-init\n\neval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-odt-export-to-odt \\\n    || die \"Exported file wasn't produced\"\norgmk-update-src-check-diff \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\"\n#+end_src\n\n** org2txt\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org2txt\n   :END:\n\nThe =org2txt= script converts an Org file to text.\n\n#+begin_src shell\nTARGET_EXT=txt\n. orgmk-init\n\neval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-ascii-export-to-ascii \\\n    || die \"Exported file wasn't produced\"\norgmk-update-src-check-diff \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\"\n#+end_src\n\n** org2gfm\n    :PROPERTIES:\n    :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org2gfm\n    :END:\n\nThe =org2gfm= script converts an Org file to Github Flavored Markdown.\n\n#+BEGIN_SRC shell\nTARGET_EXT=md\n. orgmk-init\n\neval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-gfm-export-to-markdown \\\n    || die \"Exported file wasn't produced\"\norgmk-update-src-check-diff \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\"\n#+END_SRC\n\n** Orgmk-update-src-check-diff\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/bash\\n\" :tangle bin/orgmk-update-src-check-diff\n   :END:\n\nCheck whether dynamic blocks and tables have been updated, and (if yes) propose\nto overwrite the source Org file.\n\n*** Functions\n\n#+begin_src shell\nask () {\n    while true; do\n        if [ \"${2:-}\" = \"Y\" ]; then\n            prompt=\"Y/n\"\n            default=Y\n        elif [ \"${2:-}\" = \"N\" ]; then\n            prompt=\"y/N\"\n            default=N\n        else\n            prompt=\"y/n\"\n            default=\n        fi\n\n        # ask the question (without the need to press RET)\n        printf \"$1 ($prompt): \"\n        read -n 1 -r REPLY\n        printf \"\\n\" # just a final linefeed\n\n        # default?\n        if [ -z \"$REPLY\" ]; then\n            REPLY=$default\n        fi\n\n        # check if the reply is valid\n        case \"$REPLY\" in\n            y*|Y*) return 0 ;;\n            n*|N*) return 1 ;;\n        esac\n    done\n}\n#+end_src\n\n*** Runtime\n\n#+begin_src shell\nFILE_SRC_ORIG=$1\nFILE_SRC_UPDT=$2\n\n# set a default value\n: ${UPDATE_SRC:=\"query\"}\n\nif [ ! -r \"$FILE_SRC_UPDT\" ]; then\n    printf \"Cannot read file $FILE_SRC_UPDT\\n\"\nelse\n    if diff -q \"$FILE_SRC_ORIG\" \"$FILE_SRC_UPDT\" \u003e /dev/null; then\n        rm \"$FILE_SRC_UPDT\"\n    else\n        if [[ \"$UPDATE_SRC\" = \"query\" ]]; then\n            ask \"Update source file?\" \u0026\u0026 UPDATE_SRC=\"yes\" || UPDATE_SRC=\"no\"\n        fi\n\n        if [[ \"$UPDATE_SRC\" = \"yes\" ]]; then\n            mv \"$FILE_SRC_UPDT\" \"$FILE_SRC_ORIG\"\n            printf \"${C_INFO}Dynamic blocks and tables in \\`$FILE_SRC_ORIG' successfully updated${C_RESET}\\n\"\n        else\n            printf \"Nothing gets updated...\\n\"\n        fi\n    fi\nfi\n#+end_src\n\nIn order to avoid \"file changed on disk\" messages (and be forced to revert\nopen buffers) when nothing changed, we save the file with another name, and\ndiff it with the original file. If there is no change, the new file is\ndropped.\n\n#+begin_note\nThe time stamps in \"Clock summary at ...\" will be different, each time dynamic\nblocks are updated (if not done during the same minute). In that case, =diff=\nwill always \"succeed\".\n#+end_note\n\n** org-tangle\n   :PROPERTIES:\n   :header-args+: :shebang \"#!/bin/sh\\n\" :tangle bin/org-tangle\n   :END:\n\nThe =org-tangle= tangles an Org file.\n\n#+begin_src shell\nTARGET_EXT=\n. orgmk-init\n\neval $ORGMK $FILE_SRC_ORIG $ORGMK_UPDATE_FLAGS -f org-babel-tangle \\\n    || die \"File wasn't tangled\"\n#+end_src\n\n* Orgmk\n\n** Orgmk.mk\n   :PROPERTIES:\n   :header-args+: :tangle bin/orgmk.mk\n   :END:\n\nHere is the \"ultimate\" Makefile to *automate the generation of HTML or PDF*\nversions from your Org mode files.\n\nIt is designed to solve tedious tasks nicely, such as updating:\n\n- [X] table of contents,\n- [X] cross-references,\n- [ ] index,\n- [ ] list of figures,\n- [ ] BibTeX references,\n- [X] Org dynamic blocks,\n- [X] tables with formulas, and\n- [ ] extracting (tangle) code blocks.\n\n*************** TODO Test whether Orgmk works with symbolic links\nDoes their modification time change to reflect the latest modification of the\nsource?\n*************** END\n\n*** Some system-dependent stuff\n\n#+begin_src makefile\n### -*- Makefile -*- definition file for Orgmk\n#+end_src\n\n**** Default shell\n\n#+begin_src makefile\nSHELL = /bin/sh\n#+end_src\n\n**** Exportation scripts\n\nBy default, the =orgmk.mk= will overwrite the Org source file if it has changed\nafter dblocks update and tables re-computation.\n\n#+begin_src makefile\nORG2_FLAGS=-y\n\nORG2HTML=org2html $(ORG2_FLAGS)\nORG2PDF=org2pdf $(ORG2_FLAGS)\n#+end_src\n\n**** Viewing stuff\n\n#+begin_src makefile\nVIEW_HTML ?= firefox\nVIEW_PDF ?= xpdf\n#+end_src\n\n**** Color output\n\n#+begin_src makefile :tangle no\nifdef NO_COLOR\n    tput =\nelse\n    tput = $(shell $(TPUT) $1)\nendif\n\nblack\t:= $(call tput,setaf 0)\nred\t:= $(call tput,setaf 1)\ngreen\t:= $(call tput,setaf 2)\nyellow\t:= $(call tput,setaf 3)\nblue\t:= $(call tput,setaf 4)\nmagenta\t:= $(call tput,setaf 5)\ncyan\t:= $(call tput,setaf 6)\nwhite\t:= $(call tput,setaf 7)\nbold\t:= $(call tput,bold)\nuline\t:= $(call tput,smul)\nreset\t:= $(call tput,sgr0)\n#+end_src\n\n#+begin_src makefile\nC_INFO=\"\\\\e[32m\"\nC_WARNING=\"\\\\e[35m\"\nC_SUCCESS=\"\\\\e[1\\;32m\"\nC_FAILURE=\"\\\\e[1\\;31m\"\nC_RESET=\"\\\\e[0m\"\n#+end_src\n\n*** Basic configuration\n\n**** Org Sources\n\nDiscover and process all Org files in the current directory (or in the current\nsubtree).\n\n#+begin_src makefile\nifeq ($(ALLSUBDIRS),yes)\n    TXT_FILES=$(shell find . -name \\*.txt)\n    ORG_FILES=$(shell find . -name \\*.org)\n    HTML_FILES=$(shell find . -name \\*.html)\n    PDF_FILES=$(shell find . -name \\*.pdf)\nelse\n    TXT_FILES=$(shell find . -maxdepth 1 -name \\*.txt)\n    ORG_FILES=$(shell find . -maxdepth 1 -name \\*.org)\n    HTML_FILES=$(shell find . -maxdepth 1 -name \\*.html)\n    PDF_FILES=$(shell find . -maxdepth 1 -name \\*.pdf)\nendif\n\nFILES_TO_TANGLE := $(join $(ORG_FILES), $(TXT_FILES))\n#+end_src\n\n*************** TODO Add Org_DIRS defaulting to .\nUse Org_DIRS with foreach (?) in the following lists\n*************** END\n\n*************** TODO Fix problem of Orgfile with .org/.txt extension\nIf an Org file exists with the 2 file extensions =.txt= and =.org= (same base\nname), then we get messages such as:\n\nMakefile:102: warning: overriding recipe for target `plot.html'\nMakefile:89: warning: ignoring old recipe for target `plot.html'\n*************** END\n\n**** HTML Targets\n\nList of HTML files which can be generated:\n\n#+begin_src makefile\nHTML_FILES_FROM_ORG = $(patsubst %.org,%.html,$(ORG_FILES))\nHTML_FILES_FROM_TXT = $(patsubst %.txt,%.html,$(TXT_FILES))\n#+end_src\n\nList of HTML files to be re-generated (if they have an Org counterpart):\n\n#+begin_src makefile\nCUR_HTML_FILES := $(HTML_FILES)\n#+end_src\n\n**** PDF Targets\n\nList of PDF files which can be generated:\n\n#+begin_src makefile\nPDF_FILES_FROM_ORG = $(patsubst %.org,%.pdf,$(ORG_FILES))\nPDF_FILES_FROM_TXT = $(patsubst %.txt,%.pdf,$(TXT_FILES))\n#+end_src\n\nList of PDF files to be re-generated (if they have an Org counterpart):\n\n#+begin_src makefile\nCUR_PDF_FILES := $(PDF_FILES)\n#+end_src\n\n**** Debugging\n\n#+begin_src makefile\n# turn command echo'ing back on with VERBOSE=1\nifndef VERBOSE\n    QUIET := @\nendif\n#+end_src\n\n*Everything* is echo'ed, even =$(shell ...)= invocations:\n\n#+begin_src makefile\n# turn on shell debugging with SHELL_DEBUG=1\nifdef SHELL_DEBUG\n    SHELL += -x\nendif\n#+end_src\n\n**** Commands\n\nDefine variables for each command used in targets:\n\n#+begin_src makefile\nPRINTF=$(QUIET)printf\nEGREP=$(QUIET)grep -E\nLS=$(QUIET)ls\n#+end_src\n\n*** All\n\n#+begin_src makefile\n.PHONY: all\nall: html pdf                           # Regenerate all HTML and PDF files\n#+end_src\n\n*** Help\n\nGet help.\n\n#+begin_src makefile\n.PHONY: help\nhelp:                                   # Display callable targets\n\t$(PRINTF) \"Usage: orgmk [OPTION]... [TARGET]...\\n\" \u003e /dev/stderr\n\t$(PRINTF) \"\\n\"\n\t$(PRINTF) \"What target do you want?\\n\" \u003e /dev/stderr\n\t$(EGREP) \"^[^\t#A-Z]+:\" [Mm]akefile \\\n\t| sed 's/:[^#]*//' | sed 's/^/\\n/g' | sed 's/# /\\n\\t/g' \u003e /dev/stderr\n#+end_src\n\n*** HTML\n\n=orgmk html= will regenerate all HTML files which *currently exist* in the\ndirectory, and whose source Org file has changed.\n\n#+begin_src makefile\n.PHONY: html\nhtml: $(CUR_HTML_FILES)                 # Regenerate all HTML documents from Org\n#+end_src\n\nTo create an HTML file for the *first time*, type =orgmk file.html=. It will\nignore other Org files in the directory.\n\n#+begin_src makefile\n$(HTML_FILES_FROM_ORG): %.html: %.org   # Export an Org document to HTML\n\u003c\u003crecipe-convert-to-html\u003e\u003e\n\n$(HTML_FILES_FROM_TXT): %.html: %.txt   # Export an Org document to HTML\n\u003c\u003crecipe-convert-to-html\u003e\u003e\n#+end_src\n\nThe recipe to *convert Org to HTML* is:\n\n#+name: recipe-convert-to-html\n#+begin_src makefile :tangle no\n\t$(PRINTF) \"$(C_INFO)Exporting \\`$(CURDIR)/$\u003c' to HTML...$(C_RESET)\\n\"\n\t$(ORG2HTML) $\u003c\n\t$(LS) -l -t $\u003c $@ | head -n 1 | grep -E \"\\.html\" \u003e /dev/null \\\n\t|| { printf \"$(C_FAILURE)\\`$(CURDIR)/$@' is NOT up to date$(C_RESET)\\n\"; exit 1; }\n\t$(PRINTF) \"$(C_SUCCESS)\\`$(CURDIR)/$@' successfully generated$(C_RESET)\\n\"\n#+end_src\n\nWhat about =org-export-as-html-batch= and =org-export-as-html-and-open=?\n\n#+begin_src makefile\nview-html:                              # Generate the HTML files, then show the result\n#+end_src\n\n*** PDF\n\n=orgmk pdf= will find out which PDF files have to be regenerated, and will\nregenerate all of them.\n\n#+begin_src makefile\n.PHONY: pdf\npdf: $(CUR_PDF_FILES)                   # Regenerate all PDF documents from Org\n#+end_src\n\nType =orgmk file.pdf= to generate only the specified PDF file.\n\n#+begin_src makefile\n$(PDF_FILES_FROM_ORG): %.pdf: %.org     # Export an Org document to PDF\n\u003c\u003crecipe-convert-to-pdf\u003e\u003e\n\n$(PDF_FILES_FROM_TXT): %.pdf: %.txt     # Export an Org document to PDF\n\u003c\u003crecipe-convert-to-pdf\u003e\u003e\n#+end_src\n\n#+begin_note\nThe drawback of updating the dblocks inside the the recipes for HTML and PDF\nmeans that, if we have a file that's *converted to both file formats*, the\nupdate will be done twice (so, once at least for nothing): once for HTML, then\nonce again for PDF. Though, this case is quite uncommon.\n#+end_note\n\nThe recipe to *convert Org to PDF* is:\n\n#+name: recipe-convert-to-pdf\n#+begin_src makefile :tangle no\n\t$(PRINTF) \"$(C_INFO)Exporting \\`$(CURDIR)/$\u003c' to PDF...$(C_RESET)\\n\"\n\t$(ORG2PDF) $\u003c\n\t$(LS) -l -t $\u003c $@ | head -n 1 | grep -E \"\\.pdf\" \u003e /dev/null \\\n\t|| { printf \"$(C_FAILURE)\\`$(CURDIR)/$@' is NOT up to date$(C_RESET)\\n\"; exit 1; }\n\t$(PRINTF) \"$(C_SUCCESS)\\`$(CURDIR)/$@' successfully generated$(C_RESET)\\n\"\n#+end_src\n\n*************** TODO Export as LaTeX?\nMaybe the export should be done to TeX, and then call (the minimum number of\ntimes) PDFLaTeX from the =orgmk.mk=? Check out if this is as robust as using Org\nto build the PDF... (which goes on, even with some errors occurring)\n*************** END\n\nI've observed cases where =orgmk pdf= was reporting that \"Exporting to\nPDF...done\", but I was left with the previous PDF file. Hence, every call to\n=orgmk= tried to redo them...\n\nOn deleting the PDF, and relaunching =orgmk= on that file, I had an error\nduring the \"Processing LaTeX file\".\n\nWorkaround, to be sure that an old PDF does not stay in the way, remove the\nPDF output upon startup of the recipe. The TeX file was well updated. Hence,\nno need to delete it at startup...\n\n*Problem*: when the PDF file is not generated anymore, it won't be remade with\n=orgmk pdf=. We then have to explicitly =orgmk file.pdf=.\n\n*** Clean\n\n#+begin_src makefile\n.PHONY: clean\nclean:                                  # Delete all temporary files created by Org export\n#+end_src\n\n*** TODO Orgmk init file\n\nHere, we should *make a symlink*, if it does not exist yet. Would then be used\njust once...\n\nThe only thing that's not done yet automatically is: tangling this file!\n\n*** Footer\n\n#+begin_src makefile\n### orgmk.mk ends here\n#+end_src\n\n** Makefile wrapper\n   :PROPERTIES:\n   :header-args+: :tangle bin/orgmk :shebang \"#!/bin/sh\\n\"\n   :END:\n\nAs you could want to run the batch scripts from a (development) directory\nwhere there is already a ~Makefile~, you must install the ~Makefile~ under a\ndifferent name: ~orgmk.mk~.\n\nAn addition is to create a symbolic link to the ~orgmk.mk~ into the\ndirectory of your Org files just for the duration of the script execution\n(on-the-fly install). The links can be safely removed after =make= has been run.\n\n#+begin_src shell\nUsage ()\n{\n    cat \u003c\u003c EOF 1\u003e\u00262\nUsage: $(basename $0) [OPTION] FILE\nExport Org source files whenever they are updated.\n\n  -h, --help          display this help and exit\n  -r, --recursive     export all Org files under each directory, recursively\n\nReport $(basename $0) bugs to fni@missioncriticalit.com\nEOF\n    exit 1\n}\n#+end_src\n\n#+begin_src shell\nCleanUp ()\n{\n    # remove the Makefile\n    rm orgmk.mk\n}\n\n# perform housekeeping on program exit or a variety of signals\n# (EXIT, HUP, INT, QUIT, TERM)\ntrap CleanUp 0 1 2 3 15\n#+end_src\n\n#+begin_src shell\n# install the Makefile where you are\norgmk-stow-orgmk.mk\n\nFLAGS=\"\"\nwhile true; do\n    case \"$1\" in\n        -h | --help ) Usage ;;\n        -r | --recursive) FLAGS=\"ALLSUBDIRS=yes\"; shift ;;\n        ,* ) break ;;\n    esac\ndone\n\nmake -f orgmk.mk $FLAGS $*\n#+end_src\n\n* Orgmk configuration file\n  :PROPERTIES:\n  :header-args+: :tangle site-lisp/orgmk.el\n  :END:\n\nI use a setup file =orgmk.el= to hold minimal customization.\n\n#+begin_info\nIn batch mode, [...] Emacs functions that normally print a message in the echo\narea will print to either the standard output stream (=stdout=) or the standard\nerror stream (=stderr=) instead. (To be precise, functions like =prin1=, =princ= and\n=print= print to =stdout=, while =message= and =error= print to =stderr=.)\n#+end_info\n\n** Common\n\n#+begin_src emacs-lisp\n;;; orgmk.el --- Emacs configuration file for `orgmk'\n\n;;; Commentary:\n\n;;; Code:\n#+end_src\n\n*** Library Search\n\nRemember current directory.\n\n#+begin_src emacs-lisp\n;; remember this directory\n(defconst orgmk-el-directory\n  (file-name-directory (or load-file-name (buffer-file-name)))\n  \"Directory path of Orgmk.\")\n#+end_src\n\n*** Feedback\n\n#+begin_src emacs-lisp\n;; ;; activate debugging\n;; (setq debug-on-error t)\n\n;; no limit when printing values\n(setq eval-expression-print-length nil)\n(setq eval-expression-print-level nil)\n#+end_src\n\n*** Auto Save\n\n#+begin_src emacs-lisp\n;; don't make a backup of files\n(setq backup-inhibited t)\n#+end_src\n\n*** Initialization for MS Windows\n\nWhen running an native Microsoft Windows version of Emacs:\n\n#+begin_src emacs-lisp\n;; ;; let Emacs recognize Cygwin paths (e.g. /usr/local/lib)\n;; (add-to-list 'load-path \"~/Downloads/emacs/site-lisp\") ;; \u003c- adjust\n;; (when (eq system-type 'windows-nt)\n;;   (when (try-require 'cygwin-mount)\n;;     (cygwin-mount-activate)))\n#+end_src\n\n*** Shell\n\nFix the shell to use: the *default value of shell-file-name* (that is the\nprogram =/bin/bash=) is not found under Windows Emacs.\n\n#+begin_src emacs-lisp\n;; shell\n(message \"Current value of `shell-file-name': %s\" shell-file-name)\n(unless (equal shell-file-name \"bash\")\n  (setq shell-file-name \"bash\")\n  (message \"... changed to: %s\" shell-file-name))\n#+end_src\n\nThis is important when launching external tools, such as ~PDFLaTeX~ or ~Latexmk~.\n\n*** Installation of version 8 or later\n\nEnsure that a recent version of Org mode is installed and loaded.\n\n#+begin_src emacs-lisp\n(when (locate-library \"package\")\n  (require 'package)\n  (add-to-list 'package-archives '(\"org\" . \"http://orgmode.org/elpa/\"))\n  (add-to-list 'package-archives '(\"melpa\" . \"http://melpa.milkbox.net/packages/\"))\n  (package-initialize)\n  (unless package-archive-contents\n    (package-refresh-contents)))\n#+end_src\n\n#+begin_src emacs-lisp\n(unless (locate-library \"ox\")           ; trick to detect the presence of Org 8\n  (ding)\n  (message \"The versions 6 and 7 of Org mode are no longer supported\")\n  (message \"Time to upgrade, don't you think?\")\n  (when (locate-library \"package\")\n    (let ((pkg 'org-plus-contrib))\n      (if (yes-or-no-p (format \"Install package `%s'? \" pkg))\n          (ignore-errors\n            (package-install pkg))\n        (setq debug-on-error nil)\n        (error \"Please upgrade to 8 or later\")))))\n#+end_src\n\n#+begin_src emacs-lisp\n(when (locate-library \"package\")\n  (unless (locate-library \"htmlize\")    ; for syntax highlighting in org2html\n    (let ((pkg 'htmlize))\n      (if (yes-or-no-p (format \"Install package `%s'? \" pkg))\n          (ignore-errors\n            (package-install pkg)))))\n  (unless (locate-library \"ox-gfm\")     ; for exporting to GFM\n    (let ((pkg 'ox-gfm))\n      (if (yes-or-no-p (format \"Install package `%s`? \" pkg))\n          (ignore-errors\n            (package-install pkg)))))\n  ;; (unless (locate-library \"ox-reveal\")     ; for exporting to Reveal\n  ;;   (let ((pkg 'ox-reveal))\n  ;;     (if (yes-or-no-p (format \"Install package `%s`? \" pkg))\n  ;;         (ignore-errors\n  ;;           (package-install pkg)))))\n  )\n#+end_src\n\n#+begin_src emacs-lisp\n;; version info\n(let ((org-install-dir (file-name-directory (locate-library \"org-loaddefs\")))\n      (org-dir (file-name-directory (locate-library \"org\")))) ; org.(el|elc)\n  (message \"Org mode version %s (org @ %s)\"\n           (org-version)\n           (if (string= org-dir org-install-dir)\n               org-install-dir\n             (concat \"mixed installation! \" org-install-dir \" and \" org-dir))))\n#+end_src\n\n*** Activation\n\n#+begin_src emacs-lisp\n(require 'org)\n(require 'org-clock)\n(require 'ox)\n;; (require 'ox-reveal)\n\n(add-to-list 'auto-mode-alist '(\"\\\\.txt\\\\'\" . org-mode))\n#+end_src\n\n*** Language Environment\n\n#+begin_src emacs-lisp\n;; make sure that timestamps appear in English\n(setq system-time-locale \"C\")           ; [default: nil]\n#+end_src\n\n*** Clock table\n\n#+begin_src emacs-lisp\n;; format string used when creating CLOCKSUM lines and when generating a\n;; time duration (avoid showing days)\n(setq org-time-clocksum-format\n      '(:hours \"%d\" :require-hours t :minutes \":%02d\" :require-minutes t))\n\n;; format string for the total time cells\n(setq org-clock-total-time-cell-format \"%s\")\n\n;; format string for the file time cells\n(setq org-clock-file-time-cell-format \"%s\")\n#+end_src\n\n*** Markup\n\n#+begin_src emacs-lisp\n;; hide the emphasis marker characters\n(setq org-hide-emphasis-markers t)      ; impact on table alignment!\n#+end_src\n\n*** Export options\n\n#+begin_src emacs-lisp\n;; don't insert a time stamp into the exported file\n(setq org-export-time-stamp-file nil)\n\n;; activate smart quotes during export (convert \" to \\og, \\fg in French)\n(setq org-export-with-smart-quotes t)   ; curly quotes in HTML\n\n;; interpret \"_\" and \"^\" for export when braces are used\n(setq org-export-with-sub-superscripts '{})\n\n;; allow #+BIND to define local variable values for export\n(setq org-export-allow-bind-keywords t)\n#+end_src\n\n*** Org-Babel\n\n#+begin_src emacs-lisp\n;; configure Babel to support most languages\n(add-to-list 'org-babel-load-languages '(R . t)) ; Requires R and ess-mode.\n(add-to-list 'org-babel-load-languages '(awk . t))\n(add-to-list 'org-babel-load-languages '(ditaa . t)) ; Sudo aptitude install openjdk-6-jre.\n(add-to-list 'org-babel-load-languages '(dot . t))\n(add-to-list 'org-babel-load-languages '(java . t))\n(add-to-list 'org-babel-load-languages '(perl . t))\n(add-to-list 'org-babel-load-languages '(latex . t)) ; Shouldn't you use #+begin/end_latex blocks instead?\n(add-to-list 'org-babel-load-languages '(ledger . t)) ; Requires ledger.\n(add-to-list 'org-babel-load-languages '(makefile . t))\n(add-to-list 'org-babel-load-languages '(org . t))\n(if (locate-library \"ob-shell\")         ; ob-sh renamed on 2013-12-13\n    (add-to-list 'org-babel-load-languages '(shell . t))\n  (add-to-list 'org-babel-load-languages '(sh . t)))\n(add-to-list 'org-babel-load-languages '(sql . t))\n\n(org-babel-do-load-languages            ; loads org, gnus-sum, etc...\n 'org-babel-load-languages org-babel-load-languages)\n\n;; accented characters on graphics\n(setq org-babel-R-command\n      (concat org-babel-R-command \" --encoding=UTF-8\"))\n\n;; don't require confirmation before evaluating code blocks\n(setq org-confirm-babel-evaluate nil)\n#+end_src\n\n*** Library of Babel\n\n#+begin_src emacs-lisp\n;; load up Babel libraries\n(let ((lob-file (concat (file-name-directory (locate-library \"org\"))\n                        \"../doc/library-of-babel.org\")))\n  (when (file-exists-p lob-file)\n    (org-babel-lob-ingest lob-file)))\n#+end_src\n\n** HTML export\n\n*************** TODO Understand the hidden xx used for spacing levels in column views\nDepending on interactive vs batch export to HTML, we still have the above\ndifference in the resulting HTML file.\n*************** END\n\n#+begin_src emacs-lisp\n(when (require 'ox-html)\n\n  ;; export the CSS selectors only, when formatting code snippets\n  (setq org-html-htmlize-output-type 'css)\n\n  ;; ;; XML encoding\n  ;; (setq org-html-xml-declaration\n  ;;       '((\"html\" . \"\u003c!-- \u003cxml version=\\\"1.0\\\" encoding=\\\"%s\\\"\u003e --\u003e\")))\n\n  ;; coding system for HTML export\n  (setq org-html-coding-system 'utf-8)\n\n  ;; ;; format for the HTML postamble\n  ;; (setq org-html-postamble\n  ;;       \"  \u003cdiv id=\\\"footer\\\"\u003e\u003cdiv id=\\\"copyright\\\"\u003e\\n    Copyright \u0026copy; %d %a\\n  \u003c/div\u003e\u003c/div\u003e\")\n\n  ;; don't include the JavaScript snippets in exported HTML files\n  (setq org-html-head-include-scripts nil)\n\n  ;; turn inclusion of the default CSS style off\n  (setq org-html-head-include-default-style nil)\n\n  (defun org-html-export-body-only-to-html ()\n    \"Export only code between between \\\"\u003cbody\u003e\\\" and \\\"\u003c/body\u003e\\\" tags to a HTML file.\"\n    (interactive)\n    (org-html-export-to-html nil nil nil t)))\n#+end_src\n\n** PDF LaTeX export\n\n*************** TODO Since [2012-10-26 Fri], the %b now means the real base name (no full part).\n*************** END\n\n#+begin_src emacs-lisp\n(when (require 'ox-latex)\n\n  ;; ;; This is disturbing when calling `org2html'.\n  ;; (when (executable-find \"latexmk\")\n  ;;   (message \"%s\" (shell-command-to-string \"latexmk --version\")))\n\n  (setq org-latex-pdf-process\n        (if (eq system-type 'cygwin) ;; running a Cygwin version of Emacs\n            ;; use Latexmk (if installed with LaTeX)\n            (if (executable-find \"latexmk\")\n                '(\"latexmk -CF -pdf $(cygpath -m %f) \u0026\u0026 latexmk -c\")\n              '(\"pdflatex -interaction=nonstopmode -output-directory=%o $(cygpath -m %f)\"\n                \"pdflatex -interaction=nonstopmode -output-directory=%o $(cygpath -m %f)\"\n                \"pdflatex -interaction=nonstopmode -output-directory=%o $(cygpath -m %f)\"))\n          (if (executable-find \"latexmk\")\n              '(\"latexmk -CF -pdf %f \u0026\u0026 latexmk -c\")\n            '(\"pdflatex -interaction=nonstopmode -output-directory=%o %f\"\n              \"pdflatex -interaction=nonstopmode -output-directory=%o %f\"\n              \"pdflatex -interaction=nonstopmode -output-directory=%o %f\"))))\n\n  (message \"LaTeX command: %S\" org-latex-pdf-process)\n\n  ;; tell org to use `listings' (instead of `verbatim') for source code\n  (setq org-latex-listings t)\n\n  ;; default packages to be inserted in the header\n  ;; include the `listings' package for fontified source code\n  (add-to-list 'org-latex-packages-alist '(\"\" \"listings\") t)\n\n  ;; include the `xcolor' package for colored source code\n  (add-to-list 'org-latex-packages-alist '(\"\" \"xcolor\") t)\n\n  ;; include the `babel' package for language-specific hyphenation and\n  ;; typography\n  (add-to-list 'org-latex-packages-alist '(\"english\" \"babel\") t)\n\n  ;; default position for LaTeX figures\n  (setq org-latex-default-figure-position \"!htbp\")\n\n  (defun org-latex-export-body-only-to-latex ()\n    \"Export only code between \\\"\\begin{document}\\\" and \\\"\\end{document}\\\" to a LaTeX file.\"\n    (interactive)\n    (org-latex-export-to-latex nil nil nil t)))\n#+end_src\n\n** Extra customization files\n\nTo allow you to easily add extra settings to the above \"standard\" ones, you can\ncreate several files in the =lisp= directory. All of them will be loaded at the\nend of =orgmk='s initialization.\n\n#+begin_src emacs-lisp\n;; require all files from `lisp' directory\n(dolist (file (directory-files\n               (concat orgmk-el-directory \"../lisp/\") t \".+\\\\.elc?$\"))\n  (load-file file))\n#+end_src\n\n#+begin_src emacs-lisp\n;;; orgmk.el ends here\n#+end_src\n\n* Sample parameters\n\n** Custom LaTeX classes\n   :PROPERTIES:\n   :header-args+: :tangle lisp/org-latex-classes.el\n   :END:\n\n#+begin_src emacs-lisp\n;;; org-latex-classes.el --- Sample configuration file for LaTeX\n\n;;; Commentary:\n\n;;; Code:\n\n(require 'ox-latex)\n\n(add-to-list 'org-latex-classes\n             '(\"koma-article\"\n               \"\\\\documentclass{scrartcl}\n               [NO-DEFAULT-PACKAGES]\n               [EXTRA]\"\n               (\"\\\\section{%s}\" . \"\\\\section*{%s}\")\n               (\"\\\\subsection{%s}\" . \"\\\\subsection*{%s}\")\n               (\"\\\\subsubsection{%s}\" . \"\\\\subsubsection*{%s}\")\n               (\"\\\\paragraph{%s}\" . \"\\\\paragraph*{%s}\")\n               (\"\\\\subparagraph{%s}\" . \"\\\\subparagraph*{%s}\")))\n\n;;; org-latex-classes.el ends here\n#+end_src\n\n* Contributing\n\n** Issues\n\nReport issues and suggest features and improvements on the [[https://github.com/fniessen/orgmk/issues/new][GitHub issue tracker]].\n\n** Patches\n\nI love contributions!  Patches under any form are always welcome!\n\n** Donations\n\nIf you like the Orgmk project, you can show your appreciation and help support\nfuture development by making a [[https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=VCVAS6KPDQ4JC\u0026lc=BE\u0026item_number=orgmk\u0026currency_code=EUR\u0026bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted][donation]] through PayPal.\n\nRegardless of the donations, Orgmk will always be free both as in beer and as in\nspeech.\n\n* License\n\nCopyright (C) 2011-2025 Fabrice Niessen. All rights reserved.\n\nAuthor: Fabrice Niessen \\\\\nKeywords: org mode export automation\n\nThis program is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free Software\nFoundation, either version 3 of the License, or (at your option) any later\nversion.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\nA PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with\nthis program. If not, see http://www.gnu.org/licenses/.\n\n* Standard disclaimer\n\nI am furnishing this item \"as is\". I do *NOT* provide *ANY WARRANTY* of the item\nwhatsoever, whether express, implied, or statutory, including, but not limited\nto, any warranty of *MERCHANTABILITY* or *FITNESS FOR A PARTICULAR PURPOSE* or any\nwarranty that the contents of the item will be error-free.\n\nIn no respect shall I incur any liability for any damages, including, but\nlimited to, direct, indirect, special, or consequential damages arising out of,\nresulting from, or any way connected to the use of the item, whether or not\nbased upon warranty, contract, tort, or otherwise; whether or not injury was\nsustained by persons or property or otherwise; and whether or not loss was\nsustained from, or arose out of, the results of, the item, or any services that\nmay be provided by me.\n\n#+begin_export html\n\u003ca href=\"http://opensource.org/licenses/GPL-3.0\"\u003e\n  \u003cimg src=\"http://img.shields.io/:license-gpl-blue.svg\" alt=\":license-gpl-blue.svg\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=VCVAS6KPDQ4JC\u0026lc=BE\u0026item_number=orgmk\u0026currency_code=EUR\u0026bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted\"\u003e\n  \u003cimg src=\"https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif\" alt=\"btn_donate_LG.gif\" /\u003e\n\u003c/a\u003e\n#+end_export\n\n# This is for the sake of Emacs.\n# Local Variables:\n# before-save-hook: nil\n# End:\n\n# README.org ends here\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffniessen%2Forgmk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffniessen%2Forgmk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffniessen%2Forgmk/lists"}