Skip to content
Permalink
Browse files

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 dea2d094838ba0d8e67b68ebdeb34f1d130db7c8
Showing with 16 additions and 3 deletions.
  1. +11 −0 CHANGES.txt
  2. +4 −3 nikola/plugins/compile/rest/listing.py
  3. +1 −0 nikola/plugins/task/listings.py
@@ -1,3 +1,14 @@
New in master
=============

Features
--------

Bugfixes
--------

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

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

@@ -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()))
@@ -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

@@ -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:

0 comments on commit dea2d09

Please sign in to comment.