|
| 1 | + |
1 | 2 | # VARIABLES # |
2 | 3 |
|
3 | | -REMARK_RUNNER ?= $(BIN_DIR)/remark |
| 4 | +# Define the path to the [remark][1] executable. |
| 5 | +# |
| 6 | +# To install remark: |
| 7 | +# $ npm install remark-cli |
| 8 | +# |
| 9 | +# [1]: https://github.com/wooorm/remark/ |
| 10 | + |
| 11 | +REMARK ?= $(BIN_DIR)/remark |
4 | 12 |
|
5 | 13 | # Define the path to the remark ignore file: |
6 | 14 | REMARK_IGNORE ?= $(CONFIG_DIR)/.remarkignore |
7 | 15 |
|
8 | | -# Define plugins: |
| 16 | +# Define the path to the local remark plugins directory: |
| 17 | +REMARK_LOCAL_PLUGINS_DIR ?= $(TOOLS_DIR)/remark/plugins |
9 | 18 |
|
10 | | -PLUGIN_FOLDER ?= $(TOOLS_DIR)/remark/plugins |
11 | | -REMARK_HTML_EQUATIONS_PLUGIN ?= $(PLUGIN_FOLDER)/remark-html-equations |
12 | | -REMARK_SVG_EQUATIONS_PLUGIN ?= $(PLUGIN_FOLDER)/remark-svg-equations |
| 19 | +# Define paths to local plugins: |
| 20 | +REMARK_HTML_EQUATIONS_PLUGIN ?= $(REMARK_LOCAL_PLUGINS_DIR)/remark-html-equations |
| 21 | +REMARK_SVG_EQUATIONS_PLUGIN ?= $(REMARK_LOCAL_PLUGINS_DIR)/remark-svg-equations |
13 | 22 |
|
14 | 23 | # Define Markdown extensions: |
15 | 24 | REMARK_EXT ?= md |
16 | 25 |
|
17 | 26 | # Define the command-line options when invoking the remark executable: |
18 | | -GENERATE_EQUATIONS_FLAGS ?= \ |
| 27 | +REMARK_FLAGS ?= \ |
19 | 28 | --ext $(REMARK_EXT) \ |
20 | | - --ignore-path $(REMARK_IGNORE) \ |
21 | | - --use $(REMARK_HTML_EQUATIONS_PLUGIN) \ |
22 | | - --use $(REMARK_SVG_EQUATIONS_PLUGIN) |
| 29 | + --ignore-path $(REMARK_IGNORE) |
23 | 30 |
|
24 | 31 | # Define output option: |
25 | | -OUTPUT ?= --output |
| 32 | +REMARK_OUTPUT_FLAG ?= --output |
| 33 | + |
26 | 34 |
|
27 | 35 | # TARGETS # |
28 | 36 |
|
29 | | -# Generate equations. |
| 37 | +# Generate HTML equation elements. |
| 38 | +# |
| 39 | +# This target transforms Markdown files containing equation comment markup to include HTML equation elements. |
| 40 | + |
| 41 | +markdown-html-equations: $(NODE_MODULES) |
| 42 | + $(REMARK) $(MARKDOWN_FILES) \ |
| 43 | + $(REMARK_FLAGS) \ |
| 44 | + --use $(REMARK_HTML_EQUATIONS_PLUGIN) \ |
| 45 | + $(REMARK_OUTPUT_FLAG) |
| 46 | + |
| 47 | +.PHONY: markdown-html-equations |
| 48 | + |
| 49 | + |
| 50 | +# Generate SVG equation files. |
| 51 | +# |
| 52 | +# This target generates SVG equations files from Markdown equation elements. |
| 53 | + |
| 54 | +markdown-svg-equations: $(NODE_MODULES) |
| 55 | + $(REMARK) $(MARKDOWN_FILES) \ |
| 56 | + $(REMARK_FLAGS) \ |
| 57 | + --use $(REMARK_SVG_EQUATIONS_PLUGIN) |
| 58 | + |
| 59 | +.PHONY: markdown-svg-equations |
| 60 | + |
| 61 | + |
| 62 | +# Processes Markdown files containing equations. |
30 | 63 | # |
31 | | -# This target generates SVG files for all equations in Markdown file. |
| 64 | +# This target processes Markdown files in search for Markdown equation elements. Files containing equation elements are transformed to include HTML equation elements. SVG files are also generated for each equation. |
32 | 65 |
|
33 | | -generate-equations: $(NODE_MODULES) |
34 | | - $(REMARK_RUNNER) $(GENERATE_EQUATIONS_FLAGS) $(MARKDOWN_FILES) $(OUTPUT) |
| 66 | +markdown-equations: $(NODE_MODULES) |
| 67 | + $(REMARK) $(MARKDOWN_FILES) \ |
| 68 | + $(REMARK_FLAGS) \ |
| 69 | + --use $(REMARK_HTML_EQUATIONS_PLUGIN) \ |
| 70 | + --use $(REMARK_SVG_EQUATIONS_PLUGIN) \ |
| 71 | + $(REMARK_OUTPUT_FLAG) |
35 | 72 |
|
36 | | -.PHONY: generate-equations |
| 73 | +.PHONY: markdown-equations |
0 commit comments