# Testing fenced code blocks markdown=yes I'm typing this page in Markdown. Will try to add my own support for this. Will make it available, regardless of what markup language that I'm using, similar to my other custom formatting commands. My custom fenced code block command `code. / code..` is available when I'm typing in Textile or Markdown/Multimarkdown. The feature limits the window size that displays the code. So if it's a large blob of code, a small read-only text window with vertical and horizontal scrollbars displays the code. A fence-code block like what's used by the Github Flavored Markdown or specified at [CommonMark](http://jgm.github.io/stmd/spec.html#fenced-code-blocks) would display the entire code blob on the web page. But instead of indenting the entire code blob four spaces on each line like with Markdown, the fenced block only needs to be surrounded by three tildes or three backticks. I also support a command called `code=yes` but this turns the entire web page into a code page. Sometimes, that's fine, but most of the time, code text is mixed with normal text on the same web page. Using my `code. / code..` command to display [my Perl module](https://github.com/jrsawvel/Yo-Perl/blob/master/lib/Yo.pm) that uses the Yo API. code.package Yo; use strict; use warnings; use LWP::UserAgent; my %URLS = ( 'all' => 'http://api.justyo.co/yoall/', 'user' => 'http://api.justyo.co/yo/', 'subscribers' => 'http://api.justyo.co/subscribers_count/' ); sub new { my ($class, $api_token) = @_; my $self = (); $self->{api_token} = $api_token; $self->{link} = undef; bless($self, $class); return $self; } sub set_link { my ($self, $link) = @_; $self->{link} = $link; } sub all { my ($self) = @_; my $ua = LWP::UserAgent->new(); my $response; if ( defined($self->{link}) ) { $response = $ua->post( $URLS{'all'}, { 'api_token' => $self->{api_token}, 'link' => $self->{link} } ); } else { $response = $ua->post( $URLS{'all'}, { 'api_token' => $self->{api_token} } ); } my $rc = $response->code; return $rc; } sub user { my ($self, $username) = @_; my $ua = LWP::UserAgent->new(); my $response; if ( defined($self->{link}) ) { $response = $ua->post( $URLS{'user'}, { 'api_token' => $self->{api_token}, 'username' => $username, 'link' => $self->{link} } ); } else { $response = $ua->post( $URLS{'user'}, { 'api_token' => $self->{api_token}, 'username' => $username } ); } my $rc = $response->code; return $rc; } sub subscribers { my ($self) = @_; my $ua = LWP::UserAgent->new(); my $url = $URLS{'subscribers'} . "?api_token=" . $self->{api_token}; my $response = $ua->get($url); my $content = $response->decoded_content(); return $content; # return json. example {"result": 123}. let client decode json. } sub DESTROY { my ($self) = @_; $self->{api_token} = undef; $self->{link} = undef; } 1; code.. With Markdown, I could indent the code four spaces on each line, but that's time consuming for a decently-sized block of code. Here's a snippet of the above code with each line indented four spaces: use strict; use warnings; use LWP::UserAgent; my %URLS = ( 'all' => 'http://api.justyo.co/yoall/', 'user' => 'http://api.justyo.co/yo/', 'subscribers' => 'http://api.justyo.co/subscribers_count/' ); sub new { my ($class, $api_token) = @_; my $self = (); $self->{api_token} = $api_token; $self->{link} = undef; bless($self, $class); return $self; } Now trying a fenced code block by surrounding the code text with -three tildes at the start of the code block and three tildes at the end of the code block.- For now, I'm using my new `fence. / fence..` command that works like my `code` command except `fence` will display all the text within the page and not in a limited textarea box. Example: code.fence.sub new { my ($class, $api_token) = @_; my $self = (); $self->{api_token} = $api_token; $self->{link} = undef; bless($self, $class); return $self; } fence.. code.. (Except the fence.. starts at the beginning of the line.) Produces: fence.sub new { my ($class, $api_token) = @_; my $self = (); $self->{api_token} = $api_token; $self->{link} = undef; bless($self, $class); return $self; } fence.. I don't understand why CommonMark's spec initiative supports two ways to define a fenced code block. One positive for Textile is that it limits the ways to create headings, bullet points, etc. Here are my custom formatting commands for block and single-line text with some dating back to my Parula code that I created in 2005, which powers ToledoTalk. * q. and q.. * tmpl. and tmpl.. * hr. * br. * more. * code. and code.. * fence. and fence.. Another think that I like about Textile is how it uses alpha characters to define some commands, which make more sense than punctuation marks. Textile commands use both punctuation and alpha-numeric commands, while Markdown uses only or mainly punctuation marks. It seems that h2. is more intuitive than two pound signs. A bq. for a blockquote also makes more sense than a greater-than symbol. And so on. Maybe that's the difference between the two markup languages. Markdown was created for geeks, and Textile was created for normal people. Obivously over the years, I created my custom formatting commands to read more like Textile commands with the periods. For block text, my opening and closing commands that use a single period and a double period respectively are easy to parse and substitute, regex-wise within my code. And the words "code" and "fence" make more sense to me than three backticks or three tildes. I guess that I'll continue on my own non-standard path of creating a markup language that works for me. I like aspects of Textile, and I like aspects of Markdown, which is why I support both markups in my Junco and Grebe codebases. I also support Multimarkdown in both too. For Grebe, it's either Textile or Multimarkdown. For Junco, I can specify whether to use only Markdown or Multimarkdown. And for my Grebe code, I've added to the Markdown module some Textile formatting commands that I've used for years. So my Grebe code contains my flavored Markdown. #junco - #testing - #markup - #markdown - #textile