Skip to content

Commit

Permalink
Merge branch 'release/v2.02a'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpiggi committed Oct 17, 2018
2 parents 3b55fa6 + 9091990 commit 7a60fcc
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 9 deletions.
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# package name
PACKAGE = svg

MAKESOURCE = $(MAKE) -C source

.PHONY: all $(PACKAGE) pdf mostlyclean clean dist distclean release releaseclean install uninstall

all:
$(MAKESOURCE) all
pdf:
$(MAKESOURCE) pdf
mostlyclean:
$(MAKESOURCE) mostlyclean
clean:
$(MAKESOURCE) clean
dist:
$(MAKESOURCE) dist
distclean:
$(MAKESOURCE) distclean
release:
$(MAKESOURCE) release
releaseclean:
$(MAKESOURCE) releaseclean
install:
$(MAKESOURCE) install
uninstall:
$(MAKESOURCE) uninstall

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Copyright (C) Philip Ilten <philten@cern.ch>, 2012-2016
Copyright (C) Falk Hanisch <hanisch.latex@outlook.com>, 2017-

svg 2018/09/08 v2.02
svg 2018/10/17 v2.02a

----------------------------------------------------------------------------

Expand Down Expand Up @@ -34,6 +34,9 @@ it is rendered within the LaTeX document using either ***ImageMagick*** or
Versions
--------

**v2.02a** (2018/10/17)
+ fix bug of package **polyglossia** which fakes **babel** poorly

**v2.02** (2018/09/08)
+ distortion of included and extracted graphics supported with options `distort`
(or `keepaspectratio`) and `extractdistort` as well as rotation for
Expand Down
11 changes: 7 additions & 4 deletions release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ cd %~dp0
echo =========================================================================
echo Set the version to create
echo =========================================================================
for /f "tokens=1,2 delims= " %%a in (
'findstr /r /c:"[ ][ ][0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]" source\svg.dtx'
set version=
for /f "delims=" %%a in (
'findstr /r /c:"^ [1-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]" source\svg.dtx'
) do (
set version=%%b
set version=%%a
)
set version=%version:~13%
set version=%version:\space%=%
echo.
echo Package svg and svg-extract %version%
Expand Down Expand Up @@ -38,6 +40,7 @@ pdflatex "\def\tudfinalflag{}\input{svg.dtx}"
pdflatex "\def\tudfinalflag{}\input{svg.dtx}"
pdflatex --shell-escape "\def\tudfinalflag{}\input{svg.dtx}"
move *.dtx source\latex\svg\
move examples source\latex\svg\examples
copy ..\*.md doc\latex\svg\
move svg.pdf doc\latex\svg\
move examples doc\latex\svg\examples
Expand Down Expand Up @@ -73,7 +76,7 @@ CScript ..\temp\winzip.vbs %cd%\svg.zip %cd%\CTAN\
move svg.zip CTAN\
echo.
echo =========================================================================
echo Loeschen aller temporaeren Dateien
echo Delete all temporary files
echo =========================================================================
echo.
pause.
Expand Down
118 changes: 118 additions & 0 deletions source/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# package name
PACKAGE = svg
# formatting tools
LATEX = pdflatex
TEX = tex

include osutils.mak
include texutils.mak

# source files and package version
SRC__FILE := $(PACKAGE).dtx
SRC_FILES := $(sort $(SRC__FILE) $(wildcard *.dtx))
EXM_FILES := $(wildcard examples/*.tex) $(wildcard examples/*.svg) $(wildcard examples/*.C)
AUX_FILES := $(wildcard Makefile*) $(wildcard *.mak) $(wildcard *.mk) $(wildcard *.bat)
SRC_DIRS := $(sort $(dir $(SRC_FILES) $(EXM_FILES) $(AUX_FILES)))
SRC_DIRS := $(filter-out ./, $(SRC_DIRS))

# created files
OUT_FILES := $(PACKAGE).sty $(PACKAGE)-extract.sty
DOC__FILE := $(PACKAGE).pdf
DOC_FILES := $(DOC__FILE)

VERSION := $(strip $(call get_version, $(SRC__FILE)))
$(info ------------------------------------------------)
$(info This is version $(VERSION) of package $(PACKAGE))
$(info ------------------------------------------------)

# release files and folders
MD_FILES := $(wildcard ../*.md)
RLS_DIR := ../release_$(VERSION)/
GIT_DIR := $(RLS_DIR)GitHub/
CTAN_DIR := $(RLS_DIR)CTAN/
# TDS folders
TDS_SUFFIX := latex/$(PACKAGE)/
TDS_DOC_DIR := doc/$(TDS_SUFFIX)
TDS_SRC_DIR := source/$(TDS_SUFFIX)
TDS_EXM_DIR := source/$(TDS_SUFFIX)examples/
TDS_TEX_DIR := tex/$(TDS_SUFFIX)
TDS_DIRS := $(TDS_DOC_DIR) $(TDS_SRC_DIR) $(TDS_EXM_DIR) $(TDS_TEX_DIR)
# installation folder
TEXMF_HOME := $(shell kpsewhich --var-value=TEXMFHOME)/


# temporary directories which can be deleted in any case
TMP_DIRS := $(sort $(dir $(wildcard */)))
TMP_DIRS := $(filter-out $(SRC_DIRS), $(TMP_DIRS))
# temporary files which are created within source directories
TMP_FILES := $(wildcard *.* $(TMP_FILES))
TMP_FILES += $(foreach DIR,$(SRC_DIRS),$(wildcard $(DIR)*.*))
TMP_FILES := $(filter-out $(SRC_FILES) $(EXM_FILES) $(AUX_FILES) $(OUT_FILES) $(DOC_FILES), $(TMP_FILES))

.PHONY: all $(PACKAGE) pdf mostlyclean clean dist distclean release releaseclean install uninstall

# creates package files only
all: $(PACKAGE)

$(PACKAGE): $(OUT_FILES)

%.sty: $(SRC__FILE)
$(TEX) $<

# creates documentation only
pdf: $(DOC__FILE)

%.pdf: $(SRC__FILE) $(SRC_FILES)
$(MAKE) mostlyclean
$(LATEX) --shell-escape "\def\tudfinalflag{}\input{$<}"
$(LATEX) "\def\tudfinalflag{}\input{$<}"
$(LATEX) --shell-escape "\def\tudfinalflag{}\input{$<}"
$(LATEX) "\def\tudfinalflag{}\input{$<}"
$(LATEX) "\def\tudfinalflag{}\input{$<}"
$(LATEX) --shell-escape "\def\tudfinalflag{}\input{$<}"

# removes all temporary files created with all or doc
mostlyclean:
$(call rm_dirs,$(TMP_DIRS))
$(call rm_files,$(TMP_FILES))

# addtionally removes package files and documentation
clean: mostlyclean
$(call rm_files,$(OUT_FILES))
$(call rm_files,$(DOC_FILES))

# creates TDS folder structure with generated files
dist: $(PACKAGE) pdf
$(call rm_dirs,$(RLS_DIR))
$(call copy_tds,$(RLS_DIR))

# removes TDS folder structure
distclean:
$(call rm_tds,$(RLS_DIR))
$(call rm_tds,$(GIT_DIR))
$(call rm_dirs,$(CTAN_DIR)$(PACKAGE)/)

# creates zip files for CTAN and GitHub from TDS folder structure
release: $(PACKAGE) pdf
$(call rm_dirs,$(GIT_DIR))
$(call copy_tds,$(GIT_DIR))
$(call rm_dirs,$(CTAN_DIR))
$(call copy_tds,$(CTAN_DIR)$(PACKAGE)/,$(TDS_SUFFIX))
$(call cp_files,$(CTAN_DIR)$(PACKAGE)/$(subst $(TDS_SUFFIX),,$(TDS_DOC_DIR))README.md,$(CTAN_DIR)$(PACKAGE))
cd $(GIT_DIR) && zip -r $(PACKAGE)_$(VERSION).zip *
cd $(CTAN_DIR) && zip -r -D $(PACKAGE).zip * \
-x "$(PACKAGE)/$(subst $(TDS_SUFFIX),,$(TDS_TEX_DIR))*.*" "$(PACKAGE)/$(subst $(TDS_SUFFIX),,$(TDS_DOC_DIR))README.md"
$(MAKE) distclean

releaseclean:
$(call rm_dirs,$(RLS_DIR))

# installs all files in TDS folder structur in TEXMF_HOME
install: $(PACKAGE) pdf
$(call copy_tds,$(TEXMF_HOME))
texhash

# removes all installed files from TEXMF_HOME
uninstall:
$(call rm_dirs,$(addprefix $(TEXMF_HOME),$(TDS_DIRS)))
texhash
2 changes: 2 additions & 0 deletions source/clearsource.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@echo off
attrib +h "Makefile*" /s
attrib +h "*.bat" /s
attrib +h "*.dtx" /s
attrib +h "*.mak" /s
attrib +h "examples\*.*" /s
del "*.*" /s /q> nul
if exist svg-inkscape rmdir svg-inkscape /s /q > nul
Expand Down
54 changes: 54 additions & 0 deletions source/osutils.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ifeq ($(OS),Windows_NT)
RM = del /Q /F
RD = rmdir /Q /S
MD = mkdir
CP = copy /Y
#MV = move /Y
define rm_dirs
$(foreach DIR,$(subst /,\,$(1)),
$(shell if exist $(DIR) $(RD) $(DIR))
)
endef
define mk_dirs
$(foreach DIR,$(subst /,\,$(1)),
$(shell if not exist $(DIR) $(MD) $(DIR))
)
endef
define rm_files
$(foreach FILE,$(subst /,\,$(1)),
$(shell if exist $(FILE) $(RM) $(FILE))
)
endef
define cp_files
$(foreach FILE,$(subst /,\,$(1)),
$(shell echo $(CP) $(FILE) $(subst /,\,$(2)))
)
endef
#define mv_files
# $(foreach FILE,$(subst /,\,$(1)),
# $(shell echo $(MV) $(FILE) $(subst /,\,$(2)))
# )
#endef
else
RM = rm -f
RD = rm -f -r
MD = mkdir -p
CP = cp
#MV = mv
define rm_dirs
$(RD) $(1)
endef
define mk_dirs
$(MD) $(1)
endef
define rm_files
$(RM) $(1)
endef
define cp_files
$(CP) $(1) $(2)
endef
#define mv_files
# $(MV) $(1) $(2)
#endef
endif

16 changes: 12 additions & 4 deletions source/svg.dtx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% \CheckSum{3809}
% \CheckSum{3811}
% \iffalse meta-comment
%
% svg and svg-extract -- Include and extract SVG pictures in LaTeX documents
Expand Down Expand Up @@ -115,7 +115,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
%<package&option&base>\ProvidesPackage{svg}[%
%<package&option&extract>\ProvidesPackage{svg-extract}[%
%<*driver|package&option>
2018/09/08 v2.02\space%
2018/10/17 v2.02a\space%
%<package&option&base> (include SVG pictures)%
%<package&option&extract> (extract independent graphics from SVG pictures)%
]
Expand All @@ -141,7 +141,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
\xpretocmd{\includeinkscape}{\MakePercentComment}{}{}
\xapptocmd{\includeinkscape}{\MakePercentIgnore}{}{}
\fi
\pdfsuppresswarningpagegroup=1
\ifdefined\pdfsuppresswarningpagegroup
\pdfsuppresswarningpagegroup=1
\fi

\usepackage{listings}
\lstset{%
Expand Down Expand Up @@ -248,6 +250,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \opt{distort} (or \opt{keepaspectratio}) and \opt{extractdistort}
% as well as rotation for extractions (\opt{extractangle})
% }^^A
% \changes{v2.02a}{2018/10/17}{%
% fix bug of package \pkg{polyglossia} which fakes \pkg{babel} poorly%
% }^^A
% \ToDo{Workaround for missing \cs{transparent} (Lua\TeX lacks support)}[v2.03]
%
%
%
Expand Down Expand Up @@ -1982,12 +1988,14 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
% \begin{macro}{\svg@deactivate@dq}
% \changes{v2.02}{2018/09/07}{new}^^A
% \changes{v2.02a}{2018/10/17}{bug fix for \pkg{polyglossia}}^^A
% In order to avoid errors concerning file names with package \pkg{babel} and
% it's active double quotes, this command is defined.
% \begin{macrocode}
\newcommand*\svg@deactivate@dq{}
\AfterPackage*{babel}{%
\AfterPackage+{babel}{%
\renewcommand*\svg@deactivate@dq{\bbl@deactivate{"}}%
\providecommand*\bbl@deactivate[1]{}%
}
% \end{macrocode}
% \end{macro}^^A \svg@deactivate@dq
Expand Down
27 changes: 27 additions & 0 deletions source/texutils.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ifeq ($(OS),Windows_NT)
define get_rawversion
$(shell findstr /r /c:"^ [1-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]" $(1))
endef
else
define get_rawversion
$(shell grep "^ [1-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]" $(1))
endef
endif

define get_version
$(subst %,,$(subst \space,,$(word 2, $(call get_rawversion,$(1)))))
endef

define copy_tds
$(call mk_dirs,$(addprefix $(1),$(subst $(2),,$(TDS_DIRS))))
$(call cp_files,$(DOC_FILES),$(addprefix $(1),$(subst $(2),,$(TDS_DOC_DIR))))
$(call cp_files,$(MD_FILES),$(addprefix $(1),$(subst $(2),,$(TDS_DOC_DIR))))
$(call cp_files,$(SRC_FILES),$(addprefix $(1),$(subst $(2),,$(TDS_SRC_DIR))))
$(call cp_files,$(EXM_FILES),$(addprefix $(1),$(subst $(2),,$(TDS_EXM_DIR))))
$(call cp_files,$(OUT_FILES),$(addprefix $(1),$(subst $(2),,$(TDS_TEX_DIR))))
endef

define rm_tds
$(call rm_dirs,$(addprefix $(1),$(subst $(TDS_SUFFIX),,$(TDS_DIRS))))
endef

0 comments on commit 7a60fcc

Please sign in to comment.