Skip to content

Commit

Permalink
fix: Quoted file names (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Chauvel committed Mar 9, 2021
1 parent 4bac760 commit 796649b
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
6 changes: 5 additions & 1 deletion flap/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ def _move(self, file, invocation):

@staticmethod
def _as_file_name(path):
return str(path).replace("../", "").replace("/", "_")
file_name = str(path).replace("../", "")\
.replace("/", "_")
if ' ' in file_name:
return "\"{}\"".format(file_name)
return file_name

def include_only(self, selection, invocation):
log(invocation,
Expand Down
4 changes: 3 additions & 1 deletion flap/util/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class Unit:
DRIVE = re.compile("\\w\\:")

def __init__(self, name):
self._name = name.replace("\n", "").strip()
self._name = name.replace("\n", "")\
.replace("\"", "")\
.strip()
self._match = re.match(Unit.NAMES, self._name)

def fullname(self):
Expand Down
81 changes: 81 additions & 0 deletions tests/acceptance/scenarios/quoted_file_names.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# This file is part of Flap.
#
# Flap is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Flap is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Flap. If not, see <http://www.gnu.org/licenses/>.
#

name: complex file names
description: |
Test that FLaP does properly file names that are quoted, typically
when they include spaces. See Issue \#33
# Describe the LaTeX projects, as found on the disk
project:
- path: main.tex
content: |
\documentclass{article}
\usepackage{graphicx}
\begin{document}
This is an example of graphic inclusion:
\begin{figure}
\begin{center}
\includegraphics[width=3cm]{"quoted"}
\includegraphics[width=3cm]{"with spaces"}
\end{center}
\caption{A sample graphic}
\end{figure}
\end{document}
- path: quoted.pdf
content: |
This is a PDF image!
- path: with spaces.pdf
content: |
This is a PDF image!
# Describe the LaTeX project, once flattened
expected:
- path: merged.tex
content: |
\documentclass{article}
\usepackage{graphicx}
\begin{document}
This is an example of graphic inclusion:
\begin{figure}
\begin{center}
\includegraphics[width=3cm]{quoted}
\includegraphics[width=3cm]{"with spaces"}
\end{center}
\caption{A sample graphic}
\end{figure}
\end{document}
- path: quoted.pdf
content: |
This is a PDF image!
- path: with spaces.pdf
content: |
This is a PDF image!
outputs:
- file: main.tex
line: 7
column: 5
code: \includegraphics[width=3cm]{"quoted"}
- file: main.tex
line: 8
column: 5
code: \includegraphics[width=3cm]{"with spaces"}

0 comments on commit 796649b

Please sign in to comment.