runemadsen / Magic-Book-Project

DEPRECATED: We are reviving the Magic Book project as a node package: https://github.com/magicbookproject/magicbook
http://itp.nyu.edu
621 stars 59 forks source link

//[bold] fails if line of code contains brackets #139

Closed shiffman closed 12 years ago

shiffman commented 12 years ago
[source,java]
----
particles[i] = 10; //[bold]
----

renders as:

i] = 10; //[bold">particles[i] = 10;

stevenklise commented 12 years ago

Fixed this issue by looking for //[_____] and not just [______] see commit 3da584c for specific regex.

shiffman commented 12 years ago

Should the regex /\/\/\[(.*)\]/ include an arbitrary amount of spaces so that // [bold] or // [bold] or //[bold] works?

In ruby would this be:

/\/\/\s*\[(.*)\]/ ?

stevenklise commented 12 years ago

It could. Though in case you wanted to have an inline comment like // [i] refers to the ith element of an array the "[i]" would get removed. Though I'm not sure how often that would happen.

If inline comments will only be used for formatting then it's safe to put \s* in there, otherwise requiring the brackets to be directly next to the slashes is preferable (by me, the person who is not writing the book).

On Fri, Aug 10, 2012 at 10:54 AM, Daniel Shiffman notifications@github.comwrote:

Should the regex /\/\/[(.*)]/ include an arbitrary amount of spaces so that // [bold] or // [bold] or //[bold] works?

In ruby would this be:

/\/\/\s[(.)]/

— Reply to this email directly or view it on GitHubhttps://github.com/runemadsen/Magic-Book-Project/issues/139#issuecomment-7646874.

http://skli.se/ @stevenklise

shiffman commented 12 years ago

Got it, let's keep it for now and I will have to fix it in the book where there are spaces. Closing this issue and will make a new one in Nature of Code repo to remind me to check for this.