/itexToMML

To download this project, use:
bzr branch http://golem.ph.utexas.edu/~distler/code/itexToMML/

« back to all changes in this revision

Viewing changes to itex-src/perl/t/test.t

  • Committer: Jacques Distler
  • Date: 2019-01-03 19:26:23 UTC
  • Revision ID: distler@golem.ph.utexas.edu-20190103192623-k4p7dta8r62qwyr2
Perl bindings

Show diffs side-by-side

added added

removed removed

 
1
#!/usr/bin/perl -w
 
2
use strict;
 
3
use warnings;
 
4
use Test::Simple tests => 4;
 
5
use MathML::itex2MML;
 
6
 
 
7
my $text = 'This is an inline equation: $\sin(\pi/2)=1$.';
 
8
 
 
9
ok(itex_html_filter($text) eq "This is an inline equation: <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>&pi;</mi><mo stretchy=\"false\">/</mo><mn>2</mn><mo stretchy=\"false\">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\\sin(\\pi/2)=1</annotation></semantics></math>.", 'html_filter');
 
10
ok(itex_filter($text) eq "<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>&pi;</mi><mo stretchy=\"false\">/</mo><mn>2</mn><mo stretchy=\"false\">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\\sin(\\pi/2)=1</annotation></semantics></math>", 'html_filter');
 
11
 
 
12
$text = '\sin(\pi/2)=1';
 
13
 
 
14
ok(itex_inline_filter($text) eq "<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>&pi;</mi><mo stretchy=\"false\">/</mo><mn>2</mn><mo stretchy=\"false\">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\\sin(\\pi/2)=1</annotation></semantics></math>", 'inline_filter');
 
15
ok(itex_block_filter($text) eq "<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'><semantics><mrow><mi>sin</mi><mo stretchy=\"false\">(</mo><mi>&pi;</mi><mo stretchy=\"false\">/</mo><mn>2</mn><mo stretchy=\"false\">)</mo><mo>=</mo><mn>1</mn></mrow><annotation encoding='application/x-tex'>\\sin(\\pi/2)=1</annotation></semantics></math>", 'block_filter');