Skip to content

Commit

Permalink
Naive rewriting of local style files (Issue #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
fchauvel committed Jan 19, 2017
1 parent 329f6db commit 6fb04f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions flap/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def flattened(self):
return self.output_directory / "merged.tex"

def execute(self):
flattened = self._rewrite(self.read_root_tex, str(self.root_tex_file.resource()))
self._write(flattened)
tokens = self._rewrite(self.read_root_tex, str(self.root_tex_file.resource()))
self._write(tokens, self.flattened)

def _rewrite(self, text, source, symbol_table=SymbolTable.default()):
factory = Factory(symbol_table)
Expand All @@ -87,9 +87,9 @@ def _rewrite(self, text, source, symbol_table=SymbolTable.default()):
Context(definitions=macros.all()))
return parser.rewrite()

def _write(self, tokens):
def _write(self, tokens, destination):
latex_code = "".join(str(each_token) for each_token in tokens)
self._file_system.create_file(self.flattened, latex_code)
self._file_system.create_file(destination, latex_code)

def end_of_input(self, source, invocation):
self._show_invocation(invocation)
Expand All @@ -100,12 +100,12 @@ def relocate_dependency(self, dependency, invocation):
self._analysed_dependencies.append(dependency)
try:
file = self._find(dependency, [self.root_directory], ["sty", "cls"], TexFileNotFound(None))
new_path = self._move(file, invocation)

new_path = file._path.relative_to(self.root_directory._path)
self._show_invocation(invocation)
symbol_table = SymbolTable.default()
symbol_table.CHARACTER += '@'
self._rewrite(file.content(), file.fullname(), symbol_table)
tokens = self._rewrite(file.content(), file.fullname(), symbol_table)
self._write(tokens, self.output_directory / self._as_file_name(new_path))
return self._as_file_name(new_path.without_extension())

except TexFileNotFound:
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/scenarios/local_package_rewriting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# along with Flap. If not, see <http://www.gnu.org/licenses/>.
#

name: local package rewritting
name: local package rewriting
skipped: False
description: >
Test that FLaP properly rewritte local packages, as they may include local
Test that FLaP properly rewrite local packages, as they may include local
graphics for instance.
# Describe the LaTeX projects, as found on the disk
Expand Down

0 comments on commit 6fb04f8

Please sign in to comment.