Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #1631 -- make listings work on Windows
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 8, 2015
1 parent 704a720 commit dea2d09
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,14 @@
New in master
=============

Features
--------

Bugfixes
--------

* Listings in posts now work in Windows (Issue #1631)

New in v7.3.1
=============

Expand Down
7 changes: 4 additions & 3 deletions nikola/plugins/compile/rest/listing.py
Expand Up @@ -160,7 +160,8 @@ class Listing(Include):
option_spec = listing_spec

def run(self):
fname = self.arguments.pop(0)
_fname = self.arguments.pop(0)
fname = _fname.replace('/', os.sep)
lang = self.arguments.pop(0)
if len(self.folders) == 1:
listings_folder = next(iter(self.folders.keys()))
Expand All @@ -177,9 +178,9 @@ def run(self):
with io.open(fpath, 'r+', encoding='utf8') as fileobject:
self.content = fileobject.read().splitlines()
self.state.document.settings.record_dependencies.add(fpath)
target = urlunsplit(("link", 'listing', fpath, '', ''))
target = urlunsplit(("link", 'listing', fpath.replace('\\', '/'), '', ''))
generated_nodes = (
[core.publish_doctree('`{0} <{1}>`_'.format(fname, target))[0]])
[core.publish_doctree('`{0} <{1}>`_'.format(_fname, target))[0]])
generated_nodes += self.get_code_from_file(fileobject)
return generated_nodes

Expand Down
1 change: 1 addition & 0 deletions nikola/plugins/task/listings.py
Expand Up @@ -236,6 +236,7 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f
}, self.kw["filters"])

def listing_path(self, namep, lang):
namep = namep.replace('/', os.sep)
nameh = namep + '.html'
for name in (namep, nameh):
if name in self.proper_input_file_mapping:
Expand Down

0 comments on commit dea2d09

Please sign in to comment.