Back to index

texmacs  1.0.7.15
Functions
tree_correct.hpp File Reference
#include "drd_std.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

tree drd_correct (drd_info drd, tree t)
tree with_correct (tree t)
tree superfluous_with_correct (tree t)
tree superfluous_invisible_correct (tree t)
tree missing_invisible_correct (tree t, int force=-1)
tree upgrade_brackets (tree t, string mode="text")
tree upgrade_big (tree t)
tree downgrade_brackets (tree t, bool del_miss=false, bool big_dot=true)
tree downgrade_big (tree t)
tree move_brackets (tree t)
int count_math_errors (tree t, int mode=0)
void math_status_cumul (tree t)
void math_status_print ()
void math_status_reset ()
tree latex_correct (tree t)
tree automatic_correct (tree t, string version)
tree manual_correct (tree t)

Function Documentation

tree automatic_correct ( tree  t,
string  version 
)

Definition at line 895 of file tree_correct.cpp.

                                           {
  if (version_inf_eq (version, "1.0.7.9")) {
    t= misc_math_correct (t);
    if (enabled_preference ("remove superfluous invisible"))
      t= superfluous_invisible_correct (t);
    if (enabled_preference ("homoglyph correct"))
      t= homoglyph_correct (t);
    if (enabled_preference ("remove superfluous invisible"))
      t= superfluous_invisible_correct (t);
    if (enabled_preference ("insert missing invisible"))
      t= missing_invisible_correct_twice (t);
    if (enabled_preference ("zealous invisible correct"))
      t= missing_invisible_correct (t, 1);
  }
  t= downgrade_big (t);
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int count_math_errors ( tree  t,
int  mode = 0 
)

Definition at line 741 of file tree_correct.cpp.

                                     {
  if (is_atomic (t)) return 0;
  else {
    int sum= 0;
    for (int i=0; i<N(t); i++) {
      tree cmode= the_drd->get_env_child (t, i, MODE, "text");
      if (cmode != "math") sum += count_math_errors (t[i], mode);
      else {
        tree u= t[i];
        while (is_func (u, DOCUMENT, 1) ||
               is_func (u, TFORMAT) ||
               is_func (u, WITH))
          u= u[N(u)-1];
        if (is_func (u, TABLE)) sum += count_math_table_errors (u, mode);
        else sum += count_math_formula_errors (u, mode);
      }
    }
    return sum;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 570 of file tree_brackets.cpp.

                       {
  if (is_atomic (t)) return t;
  int i, n= N(t);
  tree r (t, n);
  for (i=0; i<n; i++)
    r[i]= downgrade_big (t[i]);
  if (is_func (r, BIG_AROUND, 2)) {
    tree op= downgrade_bracket (r[0], true);
    r= concat (tree (BIG, op), r[1]);
  }
  if (is_concat (r)) r= concat_recompose (concat_decompose (r));
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree downgrade_brackets ( tree  t,
bool  del_miss = false,
bool  big_dot = true 
)

Definition at line 537 of file tree_brackets.cpp.

                                                               {
  if (is_atomic (t)) return t;
  int i, n= N(t);
  tree r (t, n);
  for (i=0; i<n; i++)
    r[i]= downgrade_brackets (t[i], delete_missing, big_dot);
  if (is_func (r, AROUND, 3)) {
    if (delete_missing && r[0] == "<nobracket>" && r[2] == "<nobracket>")
      return concat (r[0], r[1], r[2]);
    tree lb= downgrade_bracket (r[0], false);
    tree rb= downgrade_bracket (r[2], false);
    r= concat (lb, r[1], rb);
  }
  if (is_func (r, VAR_AROUND, 3)) {
    tree lb= tree (LEFT, downgrade_bracket (r[0], true));
    tree rb= tree (RIGHT, downgrade_bracket (r[2], true));
    if (delete_missing) {
      if (lb == tree (LEFT, ".") && rb == tree (RIGHT, "."));
      else if (lb == tree (LEFT, ".")) lb= "";
      else if (rb == tree (RIGHT, ".")) rb= "";
    }
    r= concat (lb, r[1], rb);
  }
  if (is_func (r, BIG_AROUND, 2)) {
    tree op= downgrade_bracket (r[0], true);
    if (big_dot) r= concat (tree (BIG, op), r[1], tree (BIG, "."));
    else r= concat (tree (BIG, op), r[1]);
  }
  if (is_concat (r)) r= concat_recompose (concat_decompose (r));
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree drd_correct ( drd_info  drd,
tree  t 
)

Definition at line 22 of file tree_correct.cpp.

                                   {
  if (is_atomic (t)) return t;
  else {
    int i, n= N(t);
    if (drd->contains (as_string (L(t))) &&
       !drd->correct_arity (L(t), n))
      return "";
    tree r (t, n);
    for (i=0; i<n; i++)
      r[i]= drd_correct (drd, t[i]);
    return r;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 877 of file tree_correct.cpp.

                       {
  // NOTE: matching brackets corrected in upgrade_tex
  t= misc_math_correct (t);
  //if (enabled_preference ("remove superfluous invisible"))
  t= superfluous_invisible_correct (t);
  //if (enabled_preference ("homoglyph correct"))
  t= homoglyph_correct (t);
  //if (enabled_preference ("remove superfluous invisible"))
  t= superfluous_invisible_correct (t);
  //if (enabled_preference ("insert missing invisible"))
  t= missing_invisible_correct_twice (t);
  //if (enabled_preference ("insert missing invisible"))
  t= missing_invisible_correct (t, 1);
  t= downgrade_big (t);
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 914 of file tree_correct.cpp.

                        {
  t= with_correct (t);
  t= superfluous_with_correct (t);
  t= upgrade_brackets (t);
  t= misc_math_correct (t);
  if (enabled_preference ("manual remove superfluous invisible"))
    t= superfluous_invisible_correct (t);
  if (enabled_preference ("manual homoglyph correct"))
    t= homoglyph_correct (t);
  if (enabled_preference ("manual remove superfluous invisible"))
    t= superfluous_invisible_correct (t);
  if (enabled_preference ("manual insert missing invisible"))
    t= missing_invisible_correct_twice (t);
  if (enabled_preference ("manual zealous invisible correct"))
    t= missing_invisible_correct (t, 1);
  t= downgrade_big (t);
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void math_status_cumul ( tree  t)

Definition at line 788 of file tree_correct.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 841 of file tree_correct.cpp.

                     {
  cout << "Formulas       : " << count_formula << "\n";
  cout << "Initial errors : " << count_initial_errors << "\n";
  cout << "Final errors   : " << count_final_errors << "\n";
  cout << "\n";
  cout << "With corrected                  : "
       << corrected_with << "\n";
  cout << "Superfluous with corrected      : "
       << corrected_superfluous_with << "\n";
  cout << "Upgraded brackets               : "
       << corrected_brackets << "\n";
  cout << "Moved brackets                  : "
       << corrected_move_brackets << "\n";
  cout << "Miscellaneous corrected         : "
       << corrected_misc << "\n";
  cout << "Superfluous invisible corrected : "
       << corrected_superfluous_invisible << "\n";
  cout << "Homoglyphs corrected            : "
       << corrected_homoglyph << "\n";
  cout << "Missing invisible corrected     : "
       << corrected_missing_invisible << "\n";
  cout << "Zealous invisible corrected     : "
       << corrected_zealous_invisible << "\n";
  cout << "\n";
}

Here is the caller graph for this function:

tree missing_invisible_correct ( tree  t,
int  force = -1 
)

Definition at line 621 of file tree_correct.cpp.

                                              {
  // force = -1, only correct when sure, and when old markup is incorrect
  // force = 0 , only correct when pretty sure
  // force = 1 , correct whenever reasonable (used for LaTeX import)
  with_drd drd (get_document_drd (t));
  invisible_corrector corrector (t, force);
  //cout << "Times before " << corrector.times_before << "\n";
  //cout << "Space before " << corrector.space_before << "\n";
  //cout << "Times after  " << corrector.times_after  << "\n";
  //cout << "Space after  " << corrector.space_after  << "\n";
  return corrector.correct (t, "text");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 694 of file tree_brackets.cpp.

                       {
  return move_brackets_sub (move_brackets_sub (t, true), false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 330 of file tree_correct.cpp.

                                       {
  with_drd drd (get_document_drd (t));
  return superfluous_invisible_correct (t, "text");
}

Here is the call graph for this function:

Definition at line 119 of file tree_correct.cpp.

                                  {
  with_drd drd (get_document_drd (t));
  return superfluous_with_correct (t, tree (WITH, MODE, "text"));
}

Here is the call graph for this function:

Definition at line 515 of file tree_brackets.cpp.

                     {
  with_drd drd (get_document_drd (t));
  return upgrade_big_bis (t);
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree upgrade_brackets ( tree  t,
string  mode = "text" 
)

Definition at line 490 of file tree_brackets.cpp.

                                       {
  //cout << "Upgrade " << t << "\n";
  with_drd drd (get_document_drd (t));
  t= upgrade_above_below (t);
  return upgrade_brackets_bis (t, mode);
}

Here is the call graph for this function:

Definition at line 41 of file tree_correct.cpp.

                      {
  if (is_atomic (t)) return t;
  else {
    //cout << "Correcting " << t << LF << INDENT;
    tree u (t, N(t));
    for (int k=0; k<N(t); k++)
      u[k]= with_correct (t[k]);
    array<tree> a= concat_decompose (u);
    int i, n= N(a);
    array<tree> r;
    for (i=0; i<n; i++) {
      if (is_with_like (a[i])) {
       array<tree> b= with_decompose (a[i], with_body (a[i]));
       int p= N(b), k1, k2;
       for (k1=0; k1<p ; k1++)
         if (is_with_like (b[k1]) && with_similar_type (a[i], b[k1]));
         else break;
       for (k2=p; k2>k1; k2--)
         if (is_with_like (b[k2-1]) && with_similar_type (a[i], b[k2-1]));
         else break;
       array<tree> x;
       if (0  < k1) x << range (b, 0, k1);
       if (k1 < k2) x << with_recompose (a[i], range (b, k1, k2));
       if (k2 < p ) x << range (b, k2, p);
       if (N(x) == 0) continue;
       if (N(r) != 0 &&
           is_with_like (r[N(r)-1]) &&
           with_same_type (r[N(r)-1], x[0]))
         {
           array<tree> c= concat_decompose (with_body (r[N(r)-1]));
           c << concat_decompose (with_body (x[0]));
           r[N(r)-1]= with_recompose (x[0], c);
           r << range (x, 1, N(x));
         }
       else r << x;
      }
      else r << a[i];
    }
    //cout << UNINDENT << "Corrected " << t << " -> "
    //<< concat_recompose (r) << LF;
    return concat_recompose (r);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: