public String convert ( String input , String type ) { // set necessary header: request per form HttpHeaders headers = new HttpHeaders ( ) ; headers . setContentType ( MediaType . APPLICATION_FORM_URLENCODED ) ; // pack the latex string as the parameter q (q for query ;) ) MultiValueMap < String , String > map = new LinkedMultiValueMap <> ( ) ; map . add ( "q" , input ) ; if ( ! type . isEmpty ( ) ) { map . add ( "type" , type ) ; } HttpEntity < MultiValueMap < String , String > > request = new HttpEntity <> ( map , headers ) ; try { String rep = new RestTemplate ( ) . postForObject ( mathoidConfig . getUrl ( ) , request , String . class ) ; logger . info ( rep ) ; return rep ; } catch ( HttpClientErrorException e ) { logger . error ( e . getResponseBodyAsString ( ) ) ; throw e ; } }
Request against Mathoid to receive an enriched MathML . Input format can be chosen .