Skip to content

Commit dea2d09

Browse files
committedMar 8, 2015
fix #1631 -- make listings work on Windows
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 704a720 commit dea2d09

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
 

‎CHANGES.txt

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
New in master
2+
=============
3+
4+
Features
5+
--------
6+
7+
Bugfixes
8+
--------
9+
10+
* Listings in posts now work in Windows (Issue #1631)
11+
112
New in v7.3.1
213
=============
314

‎nikola/plugins/compile/rest/listing.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class Listing(Include):
160160
option_spec = listing_spec
161161

162162
def run(self):
163-
fname = self.arguments.pop(0)
163+
_fname = self.arguments.pop(0)
164+
fname = _fname.replace('/', os.sep)
164165
lang = self.arguments.pop(0)
165166
if len(self.folders) == 1:
166167
listings_folder = next(iter(self.folders.keys()))
@@ -177,9 +178,9 @@ def run(self):
177178
with io.open(fpath, 'r+', encoding='utf8') as fileobject:
178179
self.content = fileobject.read().splitlines()
179180
self.state.document.settings.record_dependencies.add(fpath)
180-
target = urlunsplit(("link", 'listing', fpath, '', ''))
181+
target = urlunsplit(("link", 'listing', fpath.replace('\\', '/'), '', ''))
181182
generated_nodes = (
182-
[core.publish_doctree('`{0} <{1}>`_'.format(fname, target))[0]])
183+
[core.publish_doctree('`{0} <{1}>`_'.format(_fname, target))[0]])
183184
generated_nodes += self.get_code_from_file(fileobject)
184185
return generated_nodes
185186

‎nikola/plugins/task/listings.py

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f
236236
}, self.kw["filters"])
237237

238238
def listing_path(self, namep, lang):
239+
namep = namep.replace('/', os.sep)
239240
nameh = namep + '.html'
240241
for name in (namep, nameh):
241242
if name in self.proper_input_file_mapping:

0 commit comments

Comments
 (0)
Please sign in to comment.