Merge branch 'release-0.1.2'

This commit is contained in:
Kolan Sh 2014-12-12 10:19:18 +06:30
commit 853b996f8a
18 changed files with 122 additions and 64 deletions

View File

@ -7,7 +7,7 @@ SET (PROJECT_DESCRIPTION "LaTeX representation in the memory.")
SET (MAJOR 0)
SET (MINOR 1)
SET (PATCH 1)
SET (PATCH 2)
LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/backbone)

View File

@ -1,6 +1,5 @@
SET (CONTACT "backbone@backbone.ws")
SET (DEBIAN_DEPENDENCIES "valac (>= 0.24), libglib2.0-bin (>= 2.33), libgee (>=
0.16)")
SET (DEBIAN_DEPENDENCIES "valac (>= 0.24), libglib2.0-bin (>= 2.33), libgee (>= 0.16)")
SET (DEBIAN_SECTION "Libraries")
SET (REDHAT_DEPENDENCIES "vala >= 0.24, glib >= 2.33, libgee >= 0.16")
SET (REDHAT_SECTION "Applications/Text")

View File

@ -13,7 +13,7 @@ namespace LAview {
* Possible values: [0-9]+{bp,cc,cm,dd,em,ex,in,mm,pc,pt,sp} <<BR>>
* or [0-9]+.[0-9][0-9]{\textwidth,columnwidth,paperwidth,linewidth,textheight,paperheight}
*/
public string height = "";
public string height { get; set; default = ""; }
/**
* Constructs a new ``AddSpace`` based on value.

View File

@ -26,7 +26,7 @@ namespace LAview {
/**
* Style of the {@link AddSpace}/{@link Subtable}.
*/
public Style style = Style.DEFAULT;
public Style style { get; set; default = Style.DEFAULT; }
/**
* Constructs a new empty ``AddSpaces``.

View File

@ -10,49 +10,49 @@ namespace LAview {
/**
* Number of occupied cells.
*/
public uint ncells = 1;
public uint ncells { get; set; default = 1; }
/**
* Cell's alignment.
*
* Possible values: "c", "r", "l", ">{\centering}p{0.07\paperwidth}", etc.
*/
public string align = "";
public string align { get; set; default = ""; }
/**
* Number of left lines.
*/
public uint nllines;
public uint nllines { get; set; }
/**
* Number of right lines.
*/
public uint nrlines;
public uint nrlines { get; set; }
/**
* Number of top lines.
*/
public uint noverlines;
public uint noverlines { get; set; }
/**
* Number of bottom lines.
*/
public uint nunderlines;
public uint nunderlines { get; set; }
/**
* Contents of the cell.
*/
public Glob contents = new Glob ();
public Glob contents { get; set; default = new Glob (); }
/**
* Any text before the cell.
*/
public string before = "";
public string before { get; set; default = ""; }
/**
* Any text after the cell.
*/
public string after = "";
public string after { get; set; default = ""; }
/**
* Type of a cell indicates how much columns/rows does it occupy.

View File

@ -12,17 +12,17 @@ namespace LAview {
*
* Possible values: "c", "r", "l", ">{\centering}p{0.07\paperwidth}", etc.
*/
public string align = "c";
public string align { get; set; default = "c"; }
/**
* Number of left lines.
*/
public uint nllines = 1;
public uint nllines { get; set; default = 1; }
/**
* Number of right lines.
*/
public uint nrlines;
public uint nrlines { get; set; }
/**
* Constructs a new ``ColParam`` by it's properties.

View File

@ -10,19 +10,19 @@ namespace LAview {
/**
* All unknown parameters.
*/
public string rest_params = "";
public string rest_params { get; set; default = ""; }
/**
* Path to the image on the disk.
*/
public string path = "";
public string path { get; set; default = ""; }
/**
* Width of the image.
*
* For ex: 3.22, 128
*/
public double width;
public double width { get; set; }
/**
* Width units of the image.
@ -31,14 +31,14 @@ namespace LAview {
* or \textwidth, \columnwidth, \pagewidth,
* \linewidth, \textwidth, \paperwidth
*/
public string width_unit = "";
public string width_unit { get; set; default = ""; }
/**
* Height of the image.
*
* For ex: 3.22, 128
*/
public double height;
public double height { get; set; }
/**
* Height units of the image.
@ -47,7 +47,7 @@ namespace LAview {
* or \textwidth, \columnwidth, \pagewidth,
* \linewidth, \textwidth, \paperwidth
*/
public string height_unit = "";
public string height_unit { get; set; default = ""; }
/**
* Constructs a new ``Graphics`` by it's properties.

View File

@ -21,7 +21,10 @@ namespace LAview {
this.position = position;
/* get parameters string */
var param_regex = "^(\\[(c|l|r)])?\\{[^{}]*([^{}]*\\{[^{}]*\\}[^{}]*)*\\}";
var PAR_REG = "\\|*((>\\{[^{}*]+\\})?[^{}*]+\\{[^{}*]+\\}|[^{}*]+)\\|*";
// Bug #94: Parse Multiple defined columns in the tabular/longtable.
var param_regex = "^(\\[(c|l|r)])?" + "\\{((\\*\\{[0-9]+\\}\\{"
+ PAR_REG + "\\}|" + PAR_REG + "))*\\}";
string params = "";
@ -59,16 +62,27 @@ namespace LAview {
/* match reversed params so '|' will be snapped to the right column */
try {
var regex = new Regex ("("
+ "\\|*}[^{}]+{(p\\|*|m\\|*|b\\|*)(}[^{}]+{>(\\|+$|\\||)|\\|)?"
+ "|"
+ "\\|*(r|c|l)(}[^{}]+{@(p\\|*|m\\|*|b\\|*) (r|c|l))?(\\|+$|\\||)"
+ ")");
var col_reg1 = "\\|*}[^{}]+{(p\\|*|m\\|*|b\\|*)(}[^{}]+{>(\\|+$|\\||)|\\|)?";
var col_reg2 = "\\|*(r|c|l)(}[^{}]+{@(p\\|*|m\\|*|b\\|*) (r|c|l))?(\\|+$|\\||)";
var regex = new Regex ("(" + col_reg1 + "|" + col_reg2
// Bug #94: Parse Multiple defined columns...
+ "|\\}" + col_reg1 + "\\{\\}[0-9]+\\{\\*"
+ "|\\}" + col_reg2 + "\\{\\}[0-9]+\\{\\*)");
MatchInfo match_info;
regex.match_full (params, -1, 0, 0, out match_info);
while (match_info.matches ()) {
var col_param = new ColParam.with_params (0, "", 0);
var word = match_info.fetch (0).reverse ().compress ();
// Bug #94: Parse Multiple defined columns in the tabular/longtable.
int count = 1;
if (word[0] == '*') {
count = int.parse (word.offset(2));
int start;
for (start = 2; word[start] != '{'; ++start);
word = word[start + 1:word.length - 1];
}
int nllines, nrlines;
for (nllines = 0; '|' == word[nllines]; ++nllines);
for (nrlines = word.length - 1; nrlines != 0 && '|' == word[nrlines]; --nrlines);
@ -77,7 +91,10 @@ namespace LAview {
col_param.align = word.offset (nllines);
col_param.nllines = nllines;
col_param.nrlines = wlen - 1 - nrlines;
col_params.insert (0, col_param);
// Bug #94: Parse Multiple defined columns in the tabular/longtable.
while (count-- > 0) col_params.insert (0, col_param);
match_info.next ();
}
} catch (RegexError e) {}

View File

@ -6,9 +6,9 @@ namespace LAview {
class Link {
public string[] begin;
public string[] end;
public unowned ParserDelegate create;
public string[] begin { get; set; }
public string[] end { get; set; }
public unowned ParserDelegate create { get; set; }
public Link (string[] begin, string[] end, ParserDelegate? create = null) {
this.begin = begin; this.end = end; this.create = create;
@ -17,7 +17,7 @@ namespace LAview {
class ParserFactory {
public Array<Link> group = new Array<Link> ();
public Array<Link> group { get; set; default = new Array<Link> (); }
public virtual TextParser make_text_parser (Array<Link> links) {
return new TextParser (links);

View File

@ -88,28 +88,28 @@ namespace LAview {
/**
* Any text before the ``Row``.
*/
public string before = "";
public string before { get; set; default = ""; }
/**
* Style of any operation on {@link ATable}/{@link Subtable} or ``Row``
* for lines preserving/creation.
*/
public Style style;
public Style style { get; set; }
/**
* Top vertical spaces.
*/
public AddSpaces top = new AddSpaces ();
public AddSpaces top { get; set; default = new AddSpaces (); }
/**
* Bottom vertical spaces.
*/
public AddSpace bottom = new AddSpace.with_params ("");
public AddSpace bottom { get; set; default = new AddSpace.with_params (""); }
/**
* Vertical spaces inside the {@link Subtable}
*/
public AddSpaces between = new AddSpaces ();
public AddSpaces between { get; set; default = new AddSpaces (); }
/**
* Type of horizontal lines for the ``Row``.

View File

@ -10,22 +10,22 @@ namespace LAview {
/**
* Caption of the table.
*/
public string caption = "";
public string caption { get; set; default = ""; }
/**
* Any text before the ``Subtable``.
*/
public string before = "";
public string before { get; set; default = ""; }
/**
* Any text after the ``Subtable``.
*/
public string after = "";
public string after { get; set; default = ""; }
/**
* Style of the table (Default/Formal).
*/
public AddSpaces.Style style;
public AddSpaces.Style style { get; set; }
protected override ADocList create_default_instance () { return new Subtable (); }

View File

@ -36,42 +36,42 @@ namespace LAview {
*
* Possible values: 't', 'b'.
*/
public char align;
public char align { get; set; }
/**
* Style of the {@link AddSpace}/{@link Subtable}.
*/
public AddSpaces.Style style;
public AddSpaces.Style style { get; set; }
/**
* Parameters of columns.
*/
public ColParams params = new ColParams ();
public ColParams params { get; set; default = new ColParams (); }
/**
* Main sutable.
*/
public Subtable table = new Subtable ();
public Subtable table { get; set; default = new Subtable (); }
/**
* First Header.
*/
public Subtable first_header = new Subtable ();
public Subtable first_header { get; set; default = new Subtable (); }
/**
* Header.
*/
public Subtable header = new Subtable ();
public Subtable header { get; set; default = new Subtable (); }
/**
* Footer.
*/
public Subtable footer = new Subtable ();
public Subtable footer { get; set; default = new Subtable (); }
/**
* Last Footer.
*/
public Subtable last_footer = new Subtable ();
public Subtable last_footer { get; set; default = new Subtable (); }
protected ATable () {}

View File

@ -21,7 +21,7 @@ namespace LAview {
* \textwidth,\columnwidth,\pagewidth,\linewidth,
* \textheight,\columnheight,\pageheight,\lineheight}.
*/
public string width = "";
public string width { get; set; default = ""; }
/**
* Gets a copy of the ``Tabular``.

View File

@ -21,9 +21,10 @@ namespace LAview {
this.position = position;
/* get parameters string */
var PARAM_REGEX_FIGBRANCHES = "\\{[^{}]*([^{}]*\\{[^{}]*\\}[^{}]*)*\\}";
var param_regex = "^(\\[(t|b)])?" + PARAM_REGEX_FIGBRANCHES + "("
+ PARAM_REGEX_FIGBRANCHES + ")?";
var PAR_REG = "\\|*((>\\{[^{}*]+\\})?[^{}*]+\\{[^{}*]+\\}|[^{}*]+)\\|*";
// Bug #94: Parse Multiple defined columns in the tabular/longtable.
PAR_REG = "\\{((\\*\\{[0-9]+\\}\\{" + PAR_REG + "\\}|" + PAR_REG + "))*\\}";
var param_regex = "^(\\[(t|b)])?" + PAR_REG + "(" + PAR_REG + ")?";
string params = "";
uint start_pos = 0, stop_pos = 0;
@ -55,8 +56,8 @@ namespace LAview {
/* width */
try {
if (Regex.match_simple (PARAM_REGEX_FIGBRANCHES + PARAM_REGEX_FIGBRANCHES, params)) {
var regex = new Regex (PARAM_REGEX_FIGBRANCHES);
if (Regex.match_simple ("^" + PAR_REG + PAR_REG + "$", params)) {
var regex = new Regex (PAR_REG);
MatchInfo match_info;
regex.match (params, 0, out match_info);
match_info.fetch_pos (0, out start_pos, out stop_pos);
@ -74,17 +75,28 @@ namespace LAview {
/* match reversed params so '|' will be snapped to the right column */
try {
var regex = new Regex ("("
+ "\\|*}[^{}]+{(p\\|*|m\\|*|b\\|*)(}[^{}]+{>(\\|+$|\\||)|\\|)?"
+ "|"
+ "\\|*(r|c|l)(}[^{}]+{@(p\\|*|m\\|*|b\\|*) (r|c|l))?(\\|+$|\\||)"
+ ")");
var col_reg1 = "\\|*}[^{}]+{(p\\|*|m\\|*|b\\|*)(}[^{}]+{>(\\|+$|\\||)|\\|)?";
var col_reg2 = "\\|*(r|c|l)(}[^{}]+{@(p\\|*|m\\|*|b\\|*) (r|c|l))?(\\|+$|\\||)";
var regex = new Regex ("(" + col_reg1 + "|" + col_reg2
// Bug #94: Parse Multiple defined columns...
+ "|\\}" + col_reg1 + "\\{\\}[0-9]+\\{\\*"
+ "|\\}" + col_reg2 + "\\{\\}[0-9]+\\{\\*)");
params = params.reverse ();
MatchInfo match_info;
regex.match_full (params, -1, 0, 0, out match_info);
while (match_info.matches ()) {
var col_param = new ColParam.with_params (0, "", 0);
var word = match_info.fetch (0).reverse ().compress ();
// Bug #94: Parse Multiple defined columns in the tabular/longtable.
int count = 1;
if (word[0] == '*') {
count = int.parse (word.offset(2));
int start;
for (start = 2; word[start] != '{'; ++start);
word = word[start + 1:word.length - 1];
}
int nllines, nrlines;
for (nllines = 0; '|' == word[nllines]; ++nllines);
for (nrlines = word.length - 1; nrlines != 0 && '|' == word[nrlines]; --nrlines);
@ -93,7 +105,10 @@ namespace LAview {
col_param.align = word.offset (nllines);
col_param.nllines = nllines;
col_param.nrlines = wlen - 1 - nrlines;
col_params.insert (0, col_param);
// Bug #94: Parse Multiple defined columns in the tabular/longtable.
while (count-- > 0) col_params.insert (0, col_param);
match_info.next ();
}
} catch (RegexError e) {}

View File

@ -8,7 +8,7 @@ namespace LAview {
/**
* Plain text in UTF-8 string.
*/
public string text = "";
public string text { get; set; default = ""; }
/**
* Constructs a new ``Text``.

View File

@ -322,5 +322,12 @@ do_parse_test (back_slashes_in_a_table ${PROJECT_SOURCE_DIR}/test/tex/back_slash
"Original and generated text are EQUAL .-.")
SET_TESTS_PROPERTIES(ParseTest-back_slashes_in_a_table PROPERTIES ENVIRONMENT "LANG=en")
# test multiply_defined_columns.tex
do_parse_test (multiply_defined_columns
${PROJECT_SOURCE_DIR}/test/tex/multiply_defined_columns.tex
${PROJECT_SOURCE_DIR}/test/tex/multiply_defined_columns.etalon.tex
"Original and generated text are EQUAL .-.")
SET_TESTS_PROPERTIES(ParseTest-multiply_defined_columns PROPERTIES ENVIRONMENT "LANG=en")
# enable testing
ENABLE_TESTING ()

View File

@ -0,0 +1,10 @@
\begin{tabular}{l|>{\centering}p{0.11\linewidth}||>{\centering}p{0.11\linewidth}||>{\centering}p{0.11\linewidth}|c}
a & b & c \tabularnewline
\hline
a & b & c & d & e & f & g \tabularnewline
\end{tabular}
\begin{longtable}{l|>{\centering}p{0.11\linewidth}||>{\centering}p{0.11\linewidth}||>{\centering}p{0.11\linewidth}|c}
a & b & c \tabularnewline
\hline
a & b & c & d & e & f & g \tabularnewline
\end{longtable}

View File

@ -0,0 +1,10 @@
\begin{tabular}{l*{3}{|>{\centering}p{0.11\linewidth}|}c}
a & b & c \tabularnewline
\hline
a & b & c & d & e & f & g \tabularnewline
\end{tabular}
\begin{longtable}{l*{3}{|>{\centering}p{0.11\linewidth}|}c}
a & b & c \tabularnewline
\hline
a & b & c & d & e & f & g \tabularnewline
\end{longtable}