lib/polytexnic/literal.rb in polytexnic-1.8.0 vs lib/polytexnic/literal.rb in polytexnic-1.8.1

- old
+ new

@@ -17,20 +17,22 @@ # Returns supported math environments. # Note that the custom AMS-TeX environments are supported # in addition to the LaTeX defaults. def math_environments - %w[align align* - eqnarray eqnarray* equation equation* - gather gather* gathered - multline multline* - ] + %w[align eqnarray equation gather gathered multline] + + %w[align* eqnarray* equation* gather* multline*] end + def math_environments_starred + %w[align* eqnarray* equation* gather* multline*] + end + # Returns a list of all literal types. def literal_types - %w[verbatim Vertatim code metacode] + math_environments + %w[verbatim Vertatim code metacode] + + math_environments end # Handles environments that should be passed through the pipeline intact. # The includes verbatim environments ('verbatim', 'Verbatim') and all the # equation environments handled by MathJax ('equation', 'align', etc.). @@ -79,12 +81,18 @@ elsif line.begin_literal? in_verbatim = true literal_type = line.literal_type skip = line.math_environment? || latex if line.math_environment? && !latex + # puts line + # puts "****" output << '\begin{xmlelement*}{equation}' - output << '\begin{equation}' + if line.starred? + output << '\begin{equation*}' + else + output << '\begin{equation}' + end end math = line.math_environment? label = nil output << xmlelement(element(literal_type), skip) do count = 1 @@ -288,9 +296,14 @@ end # Returns true if self matches a valid math environment. def math_environment? match(/(?:#{math_environment_regex})/) + end + + # Returns true if the environment is starred. + def starred? + self[-2..-1] == '*}' end private # Returns a regex matching valid math environments.