Skip to content

Commit

Permalink
allow spaces in paths, #81 #66
Browse files Browse the repository at this point in the history
  • Loading branch information
gimsieke committed Mar 8, 2021
1 parent a048b71 commit 31f06b0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion calabash
Submodule calabash updated 1 files
+6 −3 calabash.bat
20 changes: 16 additions & 4 deletions d2t.bat
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
@echo off
@setlocal ENABLEDELAYEDEXPANSION
REM The percent sign needs to be escaped in the first place, therefore %%20
REM But when the arguments are passed to Calabash, each percent sign that they
REM contain needs to be escaped again. Therefore %%%%20.
@set escapedspace=%%%%20

REM command line parameters
@set FILE=%~dpnx1
@set CONF=%~dpnx2
@set OUT_DIR=%~dpnx3

IF [%FILE%] == [] GOTO usage
IF ["%FILE%"] == [] GOTO usage

REM get basename
@set BASENAME=%~n1
@set BASENAME_FOR_URI=%BASENAME: =!escapedspace!%

REM script directory
@set sd=%~dp0
@set DIR=%sd:\=/%
@set DIR_URI=file:///%DIR: =!escapedspace!%

IF [%CONF%] == [] @set CONF=%DIR%/conf/conf.xml

Expand All @@ -26,19 +33,24 @@ REM script parameters

REM convert backward slash to slash
@set FILE=%FILE:\=/%
@set FILE_URI=file:///%FILE: =!escapedspace!%
@set CONF=%CONF:\=/%
@set CONF_URI=file:///%CONF: =!escapedspace!%
@set OUT_DIR=%OUT_DIR:\=/%
@set OUT_DIR_URI=file:///%OUT_DIR: =!escapedspace!%

REM path to fontmaps dir
@set FONTMAPS=file://%DIR%/fontmaps/
@set FONTMAPS=%DIR_URI%/fontmaps/

REM debugging
@set DEBUGDIR_URI=file:/%OUT_DIR%/%BASENAME%.debug
@set DEBUGDIR_URI=%OUT_DIR_URI%/%BASENAME_FOR_URI%.debug
@set LOG=%OUT_DIR%%BASENAME%.log

echo %LOG%

REM start
echo starting docx2tex
call %CALABASH% -o result=%OUT_DIR%/%BASENAME%.tex -o hub=%OUT_DIR%/%BASENAME%.xml %DIR%/xpl/docx2tex.xpl docx=%FILE% conf=%CONF% custom-font-maps-dir=%FONTMAPS% debug=yes debug-dir-uri=%DEBUGDIR_URI% 2>&1 2>>%LOG% || GOTO exitonerror
call "%CALABASH%" -o result=%OUT_DIR_URI%/%BASENAME_FOR_URI%.tex -o hub=%OUT_DIR_URI%/%BASENAME_FOR_URI%.xml %DIR_URI%/xpl/docx2tex.xpl docx=%FILE_URI% conf=%CONF_URI% custom-font-maps-dir=%FONTMAPS% debug=yes debug-dir-uri=%DEBUGDIR_URI% 2>&1 2>"%LOG%" || GOTO exitonerror

goto finish

Expand Down
4 changes: 2 additions & 2 deletions xpl/docx2tex.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<p:serialization port="result" method="text" media-type="text/plain" encoding="utf8"/>

<p:option name="conf" select="'../conf/conf.csv'">
<p:documentation>The input port expects either a xml2tex-mapping file
<p:documentation>OS path or URI of either an xml2tex mapping file
or a csv configuration file.</p:documentation>
</p:option>

Expand Down Expand Up @@ -118,7 +118,7 @@

<p:option name="custom-font-maps-dir" required="false">
<p:documentation>
Path to a directory containing fontmaps for docx2hub and mathtype-extension.
Path (file URI) to a directory containing fontmaps for docx2hub and the mathtype-extension.
</p:documentation>
</p:option>

Expand Down

0 comments on commit 31f06b0

Please sign in to comment.