[TxMt] Re: Regex For Markdown Fenced Code Blocks

Robert J. Rockefeller bob at bobrockefeller.com
Tue Feb 10 23:26:45 UTC 2015


I’ve taken another failed run at this.

My patterns are now:

{	patterns = (
		{	name = 'source.yaml.front-matter';
			begin = '\A-{3}';
			end = '-{3}';
			patterns = ( { include = 'source.yaml'; } );
		},
		{	name = 'text.html.markdown.classes';
			begin = '{';
			end = '}';
		},
		{	name = 'markup.raw.inline.markdown';
			begin = ' `';
			end = '`(?=[ .,;-=+])';
		},
		{	name = 'markup.raw.block.markdown';
			begin = '^`{3}';
			while = '^[^`{3}]';
		},
	);
}

And I’m still trying in the same Markdown to match the code block between the ```s.

There are a wide variety of Vagrant Boxes available on [Vagrant Cloud](https://vagrantcloud.com/boxes/search <https://vagrantcloud.com/boxes/search>); you can search there for whatever features you need in a Vagrant Box. I found that [Scotch Box](https://github.com/scotch-io/scotch-box <https://github.com/scotch-io/scotch-box>) works great for me because it is pre-provisioned (all the pieces are already downloaded as part of the box) and includes a full LAMP (Linux, Apache, MySQL, PHP) stack. We don't need the MySQL part for Grav, but it's there. The [Scotch Box Documention](https://box.scotch.io <https://box.scotch.io/>) provides plenty of information to get it running (just scroll their web page down).

After getting all that done, my project folder for Grav is shown on the right. My Vagrantfile is:
```
Vagrant.configure("2") do |config|

  config.vm.box = "scotch/box"
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.hostname = "scotchbox"
  config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]

end
```

When I'm ready to work, I open iTerm2 to `grav/public` and type `vagrant up`, wait a bit for Vagrant to do its thing and report that it's done, send my browser to `http://192.168.33.10` <http://192.168.33.10`>, and go to town.

My use of Vagrant is at the low end of the complexity spectrum. There is so much more that Vagrant can do and I'm still moving slowly towards more advanced uses such as sharing the server across the local network so that other devices (my iPad and iPhone) can access the server. Or even sharing it across the Internet so that other people can see what I'm working on.

The name = 'markup.raw.block.markdown’ begin pattern finds the first ```.

And the while pattern matches on Vagrant.configure("2") do |config| as it should.

But the while pattern fails on the empty line (a newline) and the match stops.

Why wouldn’t ^[^`{3}] succeed in matching a newline? ^[^`{3}]|\n doesn’t match either.

How should I be setting up the patterns?

Bob
-------------------
Robert J. Rockefeller
Richmond Hill, GA
www.bobrockefeller.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20150210/e17d66ca/attachment-0001.html>


More information about the textmate mailing list