Class: Javascript2latex

Inherits:
Object
  • Object
show all
Defined in:
lib/javascript2latex.rb

Overview

Utility class for creating a latex expression from a JavaScript expression.

Defined Under Namespace

Classes: ExpressionNode

Class Method Summary collapse

Class Method Details

.make_tex(javascript_expression) ⇒ string

Converts the given mathematical expression written in JavaScript into latex syntax.

Parameters:

  • javascript_expression (string)

Returns:

  • (string)

    latex_expression



259
260
261
262
263
264
265
266
267
# File 'lib/javascript2latex.rb', line 259

def self.make_tex(javascript_expression)
  begin
    root = ExpressionNode.new(javascript_expression)
    return "$#{root}$"
  rescue
    return '$$'
    Rails.logger.error 'Invalid JavaScript expression'
  end
end