aosabook/500lines

preprocessor.py inserts leading '/' in code block for template engine chapter

Closed this issue · 4 comments

See first code block under 'Helper Functions' section. There is a /self and /msg, which I guess has something to do with the leading paren to its left.

Running preprocessor.py on the source markdown inserts these slashes, so there must be a regexp in there that is misbehaving.

This also is happening in the object model chapter: #158

Also happening in the link for StarLogo in the blockcode chapter

xakon commented

The responsible code for this mis-behavior is the root_paths() in preprocessor.py,
which is activated using the --html-paths from the build.py script. In particular,
if the replacement string is changed to r'(\1)', it will stop adding the extra slash on the
code snippet.

I have no idea, though, what is the purpose of this command-line parameter and the function.
There are no comments nor any help message. I think it is better that the author to decide if he needs to update the code or slightly change it.

Thanks, @xakon! You've saved me some detective work :)