WebService::GFM - A GFM-Service Markdown Client
WebService::GFM is a Perl client for the GFM-Service Markdown API. You can find information on the GFM-Service Markdown API at https://github.com/symkat/GFM-Service.
By using the GFM-Service and WebService::GFM projects one can use GitHub Flavored Markdown from within Perl applications.
#!/usr/bin/perl
use warnings;
use strict;
use WebService::GFM;
my $gfm = WebService::GFM->new({
endpoint => "http://markdown.symkat.com/",
fenced_code_blocks => 1,
autolink => 1,
tables => 1,
});
my $response = $gfm->markdown( "# Hello World" );
if ( $response->is_success ) {
print $response->reply->{document};
}
Each constructor argument can be accessed after the object is created, and set to new values.
my $endpoint = $gfm->endpoint ; # Get Value $gfm->endpoint( $new_endpoint ); # Set Value.
For useragent
and timeout
a new LWP::Request
instance
will be built. For all others, the options to send to the endpoint
will be rebuilt. The options and LWP::UserAgent
instance are
cached between markdown
calls to allow faster use in persistently
run applications.
The endpoint
takes the HTTP location for the API call. If you have
GFM-Service running at http://markdown.mydomain.com:8085/ then you would
provide endpoint => "http://markdown.mydomain.com:8085/".
For the LWP::UserAgent
, how long to wait before giving up on the
HTTP request.
For the LWP::UserAgent
, the useragent string to send with the request.
Default: WebService::GFM/$VERSION
When set to true, strings with _ between them will not generate tags. Such that $my_random_scalar won't become $myrandomscalar.
Default: False
When set to true, Markdown style tables will be parsed.
Default: False
When set to true, blocks begining with three backticks or tildas will be treated as a codeblock without having to indent. Optionally, the language may be specified to enable syntax hilighting with Albino.
Example: ```perl #!/usr/bin/perl use warnings; use strict;
print "Hello World!\n";
```
Default: False
When set to true, create links even when they are not within <>. This will work for email addresses, http, https and ftp protocols, and for domain names starting with www and leaving out the http.
Default: False
When set to true, two tildas around a word strike the word.
Example: This is weird great!
Default: False
When set to true, HTML blocks do not require being surrounded by an empty line to be treated as HTML.
Default: False
When set to true a space is always required between the hash and header text.
Example: #this is invalid when enabled.
Default: False
When set to true, ^ begins superscript, values can be enclosed in parenthesis.
Example: This is the 3^(rd) time this week.
Default: False
The markdown
method takes the document to markdown as a single
scalar value, and returns a WebService::GFM::Response
object. The
API response is stored in reply
. WebService::GFM::Response
is a
subclass of the LWP Response Object.
SymKat symkat@symkat.com ( Blog: http://symkat.com/ )
Copyright (c) 2012 the WebService::GFM "AUTHOR" and "CONTRIBUTORS" as listed above.
This library is free software and may be distributed under the same terms as perl itself.
The most current version of WebService::GFM can be found at https://github.com/symkat/WebService-GFM