forked from apache/daffodil-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Makefile to create docx documents from the wiki
- Loading branch information
1 parent
c860008
commit f35b32f
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Requires: make, git, sed, and pandoc | ||
|
||
# Directory containing the wiki markdown files | ||
SRCDIR := .wiki/ | ||
|
||
# Filter out .md files starting with underscore and generate corresponding .docx filenames | ||
DOCX = $(addsuffix .docx, $(filter-out _%, $(basename $(notdir $(wildcard $(SRCDIR)*.md))))) | ||
|
||
# Function to sanitize filenames | ||
sanitize = $(shell echo $(1) | sed -e 's/[^a-zA-Z0-9.\-]/_/g' -e 's/__*/_/g' -e 's/_\-/-/g') | ||
|
||
# Target to clone the git wiki repository | ||
$(SRCDIR): | ||
git clone https://github.com/apache/daffodil-vscode.wiki.git $(SRCDIR) | ||
|
||
# Target to generate docx from md | ||
%.docx: | ||
@# Convert img tags to markdown syntax for pandoc | ||
sed -r 's!<img[^>]* src="([^"]+)"[^>]*>!\![](\1)!g' "$(SRCDIR)$(addsuffix .md,$(basename $@))" | pandoc -t docx -f gfm --resource-path=$(SRCDIR) --toc=true -o "$(call sanitize,$@)" - | ||
|
||
# Target to update the wiki repository | ||
update: $(SRCDIR) | ||
git -C $(SRCDIR) pull | ||
|
||
# Main target to update the repo and then generate the docx files | ||
all: update | ||
${MAKE} $(DOCX) | ||
|
||
# Cleanup target | ||
clean: | ||
rm -rf *.docx $(SRCDIR) | ||
|
||
.PHONY: update all clean | ||
|