API-Mathpix

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


Version 0.01

# SYNOPSIS

    my $mathpix = API::Mathpix->new({
      app_id  => $ENV{MATHPIX_APP_ID},
      app_key => $ENV{MATHPIX_APP_KEY},
    });

    my $response = $mathpix->process({
      src     => 'https://mathpix.com/examples/limit.jpg',
    });

    print $response->text;

# EXPORT

A list of functions that can be exported.  You can delete this section
if you don't export anything, such as for a purely object-oriented module.

# SUBROUTINES/METHODS

## process

# AUTHOR

Eriam Schaffter, `<eriam at mediavirtuel.com>`

# BUGS & SUPPORT

Please go directly to Github

    https://github.com/eriam/API-Mathpix

lib/API/Mathpix.pm  view on Meta::CPAN

our $VERSION = '0.01';


=head1 SYNOPSIS

    my $mathpix = API::Mathpix->new({
      app_id  => $ENV{MATHPIX_APP_ID},
      app_key => $ENV{MATHPIX_APP_KEY},
    });

    my $response = $mathpix->process({
      src     => 'https://mathpix.com/examples/limit.jpg',
    });

    print $response->text;


=head1 EXPORT

A list of functions that can be exported.  You can delete this section
if you don't export anything, such as for a purely object-oriented module.

lib/API/Mathpix.pm  view on Meta::CPAN


  $self->_bucket(
    Algorithm::LeakyBucket->new(
      ticks   => 200,
      seconds => 60
    )
  );

}

=head2 process

=cut

sub process {
  my ($self, $opt) = @_;


  if (-f $opt->{src}) {

    my $contents = do {
      open my $fh, $opt->{src} or die '...';
      local $/;
      <$fh>;
    };

t/01-api.t  view on Meta::CPAN


if ($ENV{MATHPIX_APP_ID} && $ENV{MATHPIX_APP_KEY}) {

  plan tests => 2;

  my $mathpix = API::Mathpix->new({
    app_id  => $ENV{MATHPIX_APP_ID},
    app_key => $ENV{MATHPIX_APP_KEY},
  });

  my $response = $mathpix->process({
    src     => 'https://mathpix.com/examples/limit.jpg',
  });

  ok($response->text eq "\\( \\lim _{x \\rightarrow 3}\\left(\\frac{x^{2}+9}{x-3}\\right) \\)", "Ok !");

  $response = $mathpix->process({
    src     => 't/test.png',
  });

  ok($response->text eq '\\( \\sum_{i=1}^{m} q_{i}(n)=1 \\)', "Ok !");


}



( run in 0.250 second using v1.01-cache-2.11-cpan-8d75d55dd25 )