Permalink
Browse files

change 'lang' option to 'info'. removed POD.

  • Loading branch information...
0racle committed Nov 27, 2016
1 parent a515b5a commit a0a9dd0e1f9e8917c04c5af9868c92965f9de775
Showing with 6 additions and 85 deletions.
  1. +4 −4 README.md
  2. +2 −81 lib/Pod/To/Markdown/Fenced.pm6
View
@@ -12,9 +12,9 @@ If so, this module is for you.
This module overrides `Pod::To::Markdown`'s multi-sub that handles code blocks. In the resulting output, that code block will now be fenced rather than indented. In this case, it is no longer strict Markdown, but something closer to CommonMark.
If that all it did this module would be pretty useless, so in addition, you can define a `lang` config option, which will be set as the "info string" on the code block. This will allow syntax highlighting of the code block where supported (like Github).
If that all it did this module would be pretty useless, so in addition, you can define a `info` config option, which will be set as the [info string](http://spec.commonmark.org/0.12/#info-string) on the code block. This will allow syntax highlighting of the code block where supported (like Github).
Usage
USAGE
=====
From command line:
@@ -26,13 +26,13 @@ From Perl 6:
Here is some perl
=begin code :lang<perl6>
=begin code :info<perl6>
say [>] ('apples', 'oranges')».chars;
=end code
Some not perl
=begin code :lang<javascript>
=begin code :info<javascript>
console.log('apples'.length > 'oranges'.length)
=end code
@@ -3,8 +3,8 @@ unit class Pod::To::Markdown::Fenced;
use Pod::To::Markdown;
multi sub pod2markdown(Pod::Block::Code $pad) is export is default {
my $lang = $pad.config<lang> // '';
return "```$lang\n" ~
my $info = $pad.config<info> // '';
return "```$info\n" ~
$pad.contents».&pod2markdown.join.trim-trailing
~ "\n```"
}
@@ -13,82 +13,3 @@ method render($pod) {
pod2markdown($pod);
}
=begin pod
=head1 NAME
Pod::To::Markdown::Fenced - Render POD code blocks as fenced (```) code blocks
=head1 SYNOPSIS
Do you like syntax highlighting?
Do you hate maintaining POD and Markdown seperately if you want language specific fenced code blocks in your README so GitHub (GFM) does syntax highlighting.
If so, this module is for you.
This module overrides `Pod::To::Markdown`'s multi-sub that handles code blocks. In the resulting output, that code block will now be fenced rather than indented. In this case, it is no longer strict Markdown, but something closer to CommonMark.
If that all it did this module would be pretty useless, so in addition, you can define a `lang` config option, which will be set as the "info string" on the code block. This will allow syntax highlighting of the code block where supported (like Github).
=head1 Usage
From command line:
=begin code
$ perl6 --doc=Markdown::Fenced lib/MyClass.pm
=end code
From Perl 6:
=begin code :lang<perl6>
Use Pod::To::Markdown::Fenced;
Here is some perl
=begin code :lang<perl6>
Foo.new( :$bar = 1, :$baz = False )
=end code
Some not perl
=begin code :lang<javascript>
console.log(['apple', 'orange'].length);
=end code
And a normal code block
=begin code
I'm just normal
=end code
say pod2markdown($=pod);
=end code
Which produces the following output
=begin code :lang<markdown>
Here is some perl
```perl6
Foo.new( :$bar = 1, :$baz = False )
```
And some not perl
```javascript
console.log(['apple', 'orange'].length);
```
And a normal code block
```
I'm just normal
```
=end code
For another example, refer to my `Net::Netmask` module on Github. The README.md file is generated completely by this module;
=end pod

0 comments on commit a0a9dd0

Please sign in to comment.