Drop Blog Update: Strange Regex Handling

I've finally got enough of the application put together that I can start using it. This very article was written locally in a simple Markdown editor and upon saving, is updated to the associated project, which in this case, is the DropBox Powered Blog Project.

One curious thing I noticed while deploying, was a puzzling bug between my local development environment and the Heroku production environment. Namely, my regex parsing of the title line worked fine locally, but not on Heroku. Once I pull out the title, I want to strip it out of the render-able content so I can do things with it and not have it double render. This was the culprit:

content.gsub!(/^#\s?.+\n/, '').strip!

This seems like it should replace something like this: # The Title and not this: ## Some Subheading, and it appears to do so locally. But on Heroku, it stripped out every heading. Fortunately, it was just a matter of changing the above to:

content.sub!(/^#\s?.+\n/, '').strip!

That is turning the gsub which is global, to the sub method. This must mean there is something with the way the Regex handles the # character in the expressions that differs between the two environments. For now, I'm glad I fixed the issue, but if anyone knows what the deeper problem is, please let me know.

I'm pleased with the progress. At this point, it will be worth doing a bit of refactoring so that I can easily add features that apply to both articles and projects, as well I also want to tackle some style updates that will get this closer to being "improved in production". The final obstacle now, is really the image handling.

If you enjoyed reading this or learned something, please consider sharing via , , or . Thanks!