$VERSION
{
''
.__FILE__} =
'$Revision$'
;
%DEFAULT_LANG_STYLE
= (
'c'
,
'I'
,
'a'
,
'I'
,
's'
,
'C'
,
'l'
,
'C'
,
'kw'
,
'B'
,
);
%_ALIGN_NAMES
= (
'L'
,
'Left'
,
'C'
,
'Center'
,
'R'
,
'Right'
,
);
%_VALIGN_NAMES
= (
'T'
,
'Top'
,
'M'
,
'Middle'
,
'B'
,
'Bottom'
,
'L'
,
'Baseline'
,
);
%_TABLE_ALIASES
= (
'Columns'
,
'columns'
,
'Rows'
,
'rows'
,
'Grid'
,
'grid'
,
'Plain'
,
'plain'
,
'Shade'
,
'shade'
,
);
$validate
= 0;
@topics
= ();
@levels
= ();
%topic_label
= ();
%topic_level
= ();
%topic_prev
= ();
%topic_next
= ();
%topic_up
= ();
%jump
= ();
%jump_label
= ();
%sdf_attrs
= ();
@sdf_attr_stk
= ();
%languages
= ();
%lang_aliases
= ();
%lang_style
=
%DEFAULT_LANG_STYLE
;
%lang_keywords
= ();
%lang_tokens
= ();
%docstyles_name
= ();
%docstyles_to
= ();
%docstyles_vars
= ();
%variables_name
= ();
%variables_type
= ();
%variables_rule
= ();
%parastyles_name
= ();
%parastyles_category
= ();
%parastyles_to
= ();
%parastyles_attrs
= ();
%paraattrs_name
= ();
%paraattrs_type
= ();
%paraattrs_rule
= ();
%paraattrs_to
= ();
%paraattrs_map
= ();
%paraattrs_attrs
= ();
%phrasestyles_name
= ();
%phrasestyles_category
= ();
%phrasestyles_to
= ();
%phrasestyles_attrs
= ();
%phraseattrs_name
= ();
%phraseattrs_type
= ();
%phraseattrs_rule
= ();
%phraseattrs_to
= ();
%phraseattrs_map
= ();
%phraseattrs_attrs
= ();
%tablestyles_name
= ();
%tablestyles_to
= ();
%tablestyles_params
= ();
%tableparams_name
= ();
%tableparams_type
= ();
%tableparams_rule
= ();
%tableparams_to
= ();
%tableparams_map
= ();
%tableparams_params
= ();
%rowparams_name
= ();
%rowparams_type
= ();
%rowparams_rule
= ();
%rowparams_to
= ();
%rowparams_map
= ();
%rowparams_params
= ();
%cellparams_name
= ();
%cellparams_type
= ();
%cellparams_rule
= ();
%cellparams_to
= ();
%cellparams_map
= ();
%cellparams_params
= ();
sub
InitFilters {
@topics
= ();
@levels
= ();
%topic_label
= ();
%topic_level
= ();
%topic_prev
= ();
%topic_next
= ();
%topic_up
= ();
%jump
= ();
%jump_label
= ();
$validate
= $'verbose;
%sdf_attrs
= ();
@sdf_attr_stk
= ();
%languages
= ();
%lang_aliases
= ();
%lang_style
=
%DEFAULT_LANG_STYLE
;
%docstyles_name
= ();
%docstyles_to
= ();
%docstyles_vars
= ();
%variables_name
= ();
%variables_type
= ();
%variables_rule
= ();
%parastyles_name
= ();
%parastyles_to
= ();
%parastyles_attrs
= ();
%parastyles_category
= ();
%paraattrs_name
= ();
%paraattrs_type
= ();
%paraattrs_rule
= ();
%paraattrs_to
= ();
%paraattrs_map
= ();
%paraattrs_attrs
= ();
%phrasestyles_name
= ();
%phrasestyles_category
= ();
%phrasestyles_to
= ();
%phrasestyles_attrs
= ();
%phraseattrs_name
= ();
%phraseattrs_type
= ();
%phraseattrs_rule
= ();
%phraseattrs_to
= ();
%phraseattrs_map
= ();
%phraseattrs_attrs
= ();
%tablestyles_name
= ();
%tablestyles_to
= ();
%tablestyles_params
= ();
%tableparams_name
= ();
%tableparams_type
= ();
%tableparams_rule
= ();
%tableparams_to
= ();
%tableparams_map
= ();
%tableparams_params
= ();
%rowparams_name
= ();
%rowparams_type
= ();
%rowparams_rule
= ();
%rowparams_to
= ();
%rowparams_map
= ();
%rowparams_params
= ();
%cellparams_name
= ();
%cellparams_type
= ();
%cellparams_rule
= ();
%cellparams_to
= ();
%cellparams_map
= ();
%cellparams_params
= ();
}
sub
_FilterValidate {
local
(
*data
,
*model
) =
@_
;
local
(
@parsed_model
);
@parsed_model
= &'TableParse(
@model
);
&'TableValidate(
*data
,
*parsed_model
);
}
sub
_SkipHeader {
local
(
*text
,
$lang
) =
@_
;
$lang
=
'sdf'
if
$lang
eq
''
;
&_SetLang
(
$lang
);
my
$start1
=
$lang_tokens
{
'cb'
};
my
$end1
=
$lang_tokens
{
'ce'
};
my
$start2
=
$lang_tokens
{
'ab'
};
my
$end2
=
$lang_tokens
{
'ae'
};
my
$init_line
=
shift
(
@text
)
if
$text
[0] =~ /^\!init/;
if
(
$end1
eq
"\n"
) {
while
(
$text
[0] =~ /^
$start1
/) {
shift
(
@text
);
}
}
elsif
(
$end2
eq
"\n"
) {
while
(
$text
[0] =~ /^
$start2
/) {
shift
(
@text
);
}
}
elsif
(
$text
[0] =~ /^
$start1
/) {
while
(
@text
&&
$text
[0] !~ /
$end1
/) {
shift
(
@text
);
}
shift
(
@text
)
if
@text
;
}
elsif
(
$text
[0] =~ /^
$start2
/) {
while
(
@text
&&
$text
[0] !~ /
$end2
/) {
shift
(
@text
);
}
shift
(
@text
)
if
@text
;
}
unshift
(
@text
,
$init_line
)
if
$init_line
;
}
sub
_Pure {
local
(
*text
) =
@_
;
local
(
$line
);
for
$line
(
@text
) {
$line
=~ s/[<>]/$& eq
'>'
?
'E<gt>'
:
'E<lt>'
/eg;
if
(
$line
=~ s/\[\[/E<2[>/g) {
$line
=~ s/\]\]/E<2]>/g;
}
if
(
$line
=~ s/\{\{/E<2{>/g) {
$line
=~ s/\}\}/E<2}>/g;
}
}
}
sub
_SetLang {
local
(
$lang
) =
@_
;
local
(
$x
,
$name
,
$value
);
%lang_tokens
= ();
foreach
$x
(
split
(
':'
,
$languages
{
$lang_aliases
{
$lang
}})) {
(
$name
,
$value
) =
split
(
'='
,
$x
, 2);
$value
=~ s/\\d/\\b/g;
$value
=~ s/\\a/.*/g;
$value
=~ s/\\p/\\w+/g;
$value
=~ s/\\e/[^\\\\]?/g;
$value
=~ s/\*/\\*/g;
$value
=
"\n"
if
$value
eq
'$'
;
$lang_tokens
{
$name
} =
$value
;
}
%lang_keywords
= ();
foreach
$x
(
split
(/\s+/,
$lang_tokens
{
'kw'
})) {
$lang_keywords
{
$x
} = 1;
}
}
sub
_FmtLang {
local
(
*text
,
$lang
) =
@_
;
local
(
$line
);
local
(
$state
);
local
(
$prefix
);
&_SetLang
(
$lang
);
$state
=
''
;
for
$line
(
@text
) {
$prefix
=
$state
?
"$lang_style{$state}<"
:
''
;
$line
=~ s/([^ \r\t\f\(\)\[\]\,\;\=\+\:]+)/
&_WordFmt
($1,
*state
)/eg;
if
(
$state
) {
$line
.=
'>'
;
$state
=
''
if
$lang_tokens
{
$state
.
'e'
} eq
"\n"
;
}
$line
=~ s/(\S)/
$prefix
$1/
if
$prefix
;
}
}
sub
_WordFmt {
local
(
$word
,
*state
) =
@_
;
local
(
$result
);
local
(
$start
,
$token
);
local
(
$keyword
);
if
(
$state
) {
if
((
$word
=~ /
$lang_tokens
{
$state
.
'e'
}$/)) {
$word
.=
'>'
;
$state
=
''
;
}
return
$word
;
}
return
"$lang_style{'c'}<$word>"
if
defined
$lang_tokens
{
'cb'
} &&
$word
=~ /^
$lang_tokens
{
'cb'
}.
*$lang_tokens
{
'ce'
}$/;
return
"$lang_style{'a'}<$word>"
if
defined
$lang_tokens
{
'ab'
} &&
$word
=~ /^
$lang_tokens
{
'ab'
}.
*$lang_tokens
{
'ae'
}$/;
return
"$lang_style{'s'}<$word>"
if
defined
$lang_tokens
{
'sb'
} &&
$word
=~ /^
$lang_tokens
{
'sb'
}.
*$lang_tokens
{
'se'
}$/;
return
"$lang_style{'l'}<$word>"
if
defined
$lang_tokens
{
'lb'
} &&
$word
=~ /^
$lang_tokens
{
'lb'
}.
*$lang_tokens
{
'le'
}$/;
for
$start
(
'c'
,
'a'
,
's'
,
'l'
) {
$token
=
$lang_tokens
{
$start
.
'b'
};
if
(
defined
$token
&&
$word
=~ /^
$token
/) {
$state
=
$start
;
return
"$lang_style{$start}<$word"
;
}
}
$keyword
=
$word
;
$keyword
=~
tr
/A-Z/a-z/
if
$lang_tokens
{
'oc'
};
return
"$lang_style{'kw'}<$word>\n"
if
$word
=~ s/\n$// &&
$lang_keywords
{
$word
};
return
"$lang_style{'kw'}<$word>"
if
$lang_keywords
{
$word
};
return
$word
;
}
sub
_DefineLang {
local
(
*lang_def
) =
@_
;
local
(
$i
,
$_
,
$virtual_line
);
local
(
$langs
,
$rest
,
$main
,
@aliases
);
$virtual_line
=
''
;
for
(
$i
= 0;
$i
<=
$#lang_def
;
$i
++) {
$_
=
$lang_def
[
$i
];
chop
;
$_
=~ s/\s*\\$//;
$_
=~ s/^\s+/ /;
$virtual_line
.=
$_
;
}
@lang_def
= ();
(
$langs
,
$rest
) =
split
(
':'
,
$virtual_line
, 2);
(
$main
,
@aliases
) =
split
(
'\|'
,
$langs
);
$languages
{
$main
} =
$rest
;
for
$_
(
$main
,
@aliases
) {
$lang_aliases
{
$_
} =
$main
;
}
}
@_sdf_FilterParams
= (
'ANY'
);
sub
sdf_Filter {
local
(
*text
,
%param
) =
@_
;
if
(
%param
) {
push
(
@sdf_attrs_stk
,
join
(
"\000"
,
%sdf_attrs
));
%sdf_attrs
=
%param
;
unshift
(
@text
,
"!on paragraph ''; __sdf; &DefaultAttrs(%sdf_attrs)"
);
push
(
@text
,
'!off paragraph __sdf'
,
'!script %sdf_attrs = split("\000", pop(@sdf_attrs_stk))'
);
}
}
@_front_FilterParams
= ();
sub
front_Filter {
local
(
*text
,
%param
) =
@_
;
}
@_about_FilterParams
= ();
sub
about_Filter {
local
(
*text
,
%param
) =
@_
;
unshift
(
@text
,
'!on paragraph \'H\d\'; __about;'
.
'$style =~ s/H(\d)/"P" . ($1 + 1)/e;'
.
'if ($1 == 1) { $attr{"component"} = "prechapter" }'
.
'else { $attr{"notoc"} = 1 }'
);
push
(
@text
,
'!off paragraph __about'
);
}
@_appendix_FilterParams
= ();
sub
appendix_Filter {
local
(
*text
,
%param
) =
@_
;
unshift
(
@text
,
'!on paragraph \'H\d\'; __appendix; $style =~ s/H/A/'
);
push
(
@text
,
'!off paragraph __appendix'
);
}
@_plain_FilterParams
= ();
sub
plain_Filter {
local
(
*text
,
%param
) =
@_
;
unshift
(
@text
,
'!on paragraph \'H\d\'; __plain; $style =~ s/H/P/'
);
push
(
@text
,
'!off paragraph __plain'
);
}
@_verbatim_FilterParams
= (
'Name Type Rule'
,
'skipheader boolean'
,
'lang string'
,
'wide boolean'
,
'listitem integer'
,
);
sub
verbatim_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$style
,
$attrs
,
$line
);
my
$lang
=
$param
{
'lang'
};
&_SkipHeader
(
*text
,
$lang
)
if
$param
{
'skipheader'
};
$style
=
"V"
;
if
(
$param
{
'wide'
} &&
$param
{
'listitem'
}) {
$attrs
=
"[wide;in=$param{'listitem'}]"
;
}
elsif
(
$param
{
'wide'
}) {
$attrs
=
'[wide]'
;
}
else
{
$attrs
=
$param
{
'listitem'
} ?
"[in=$param{'listitem'}]"
:
':'
;
}
for
$line
(
@text
) {
$line
=
"$style$attrs$line"
;
}
}
@_example_FilterParams
= (
'Name Type Rule'
,
'skipheader boolean'
,
'lang string'
,
'wide boolean'
,
'listitem integer'
,
'pure boolean'
,
);
sub
example_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$style
,
$attrs
,
$line
);
my
$lang
=
$param
{
'lang'
};
$lang
=
"\L$lang"
;
&_SkipHeader
(
*text
,
$lang
)
if
$param
{
'skipheader'
};
&_Pure
(
*text
)
if
$param
{
'pure'
} ||
$lang
ne
''
;
&_FmtLang
(
*text
,
$lang
)
if
$lang
ne
''
;
$style
=
$param
{
'wide'
} ?
'E80'
:
'E'
;
$attrs
=
$param
{
'listitem'
} ?
"[in=$param{'listitem'}]"
:
':'
;
for
$line
(
@text
) {
$line
=
$line
=~ /^\f/ ?
"PB:$'"
:
"$style$attrs$line"
;
}
}
@_note_FilterParams
= (
'Name Type Rule'
,
'label string'
,
);
sub
note_Filter {
local
(
*text
,
%param
) =
@_
;
unshift
(
@text
,
$param
{
'label'
} ?
"NB[label='$param{'label'}']"
:
"NB:"
);
push
(
@text
,
'NE:'
);
}
@_table_FilterParams
= (
'Name Type Rule'
,
'align string'
,
'bgcolor string'
,
'bmargin integer'
,
'cellpadding integer'
,
'cellspacing integer'
,
'colaligns string'
,
'coltags string'
,
'colvaligns string'
,
'delete string'
,
'footings integer'
,
'format string'
,
'groups string'
,
'headings integer'
,
'keepindents boolean'
,
'landscape string'
,
'listitem integer'
,
'lmargin integer'
,
'narrow boolean'
,
'niceheadings boolean'
,
'nocalcs boolean'
,
'noheadings boolean'
,
'objects string'
,
'oncell string'
,
'parseline string'
,
'placement string'
,
'rmargin integer'
,
'select string'
,
'sort string'
,
'style string'
,
'tags string'
,
'title string'
,
'tmargin integer'
,
'type string'
,
'where string'
,
'wide boolean'
,
'wrap integer'
,
);
sub
table_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$style
,
@tbl
);
local
(
$grp_search
,
@body_tags
,
$noheadings
,
$nocalcs
,
$nice_hdgs
,
$on_cell
);
local
(
$tbl_header
,
@flds
);
local
(
@sort_by
);
local
(
@delete
,
@select
);
local
(
@col_aligns
,
$align
);
local
(
@col_valigns
,
$valign
);
local
(
$bgcolor
);
local
(
$body_start
,
$footing_count
,
$footing_start
,
%default_heading
);
local
(
@headings
,
@footings
);
local
(
$row_type
,
$row_text
);
local
(
$format
,
$tbl_cols
,
$fmt_cols
);
local
(
@sdf
,
%values
,
$tag
,
$cell
,
%cell
);
local
(
$fld
,
$width
,
$height
,
$row
,
$col
,
$last_row
,
$last_col
);
local
(
%cover
,
$hidden
,
$rowspan
,
$colspan
,
$i
,
$j
);
local
(
$wrap
,
$wrap_counter
);
local
(
$actual_cols
);
local
(
$keepindents
);
$style
=
$param
{
'style'
} ne
''
?
$param
{
'style'
} :
$param
{
'type'
};
delete
$param
{
'type'
};
$style
=
$_TABLE_ALIASES
{
$style
}
if
$_TABLE_ALIASES
{
$style
};
$style
=
&Var
(
'DEFAULT_TABLE_STYLE'
)
if
$style
eq
''
;
$param
{
'style'
} =
$style
;
&ReportEvents
(
'table'
)
if
@'sdf_report_names;
&ExecEventsStyleMask
(
*evcode_table
,
*evmask_table
);
&ReportEvents
(
'table'
,
'Post'
)
if
@'sdf_report_names;
if
(
defined
$param
{
'parseline'
}) {
unshift
(
@text
,
$param
{
'parseline'
});
delete
$param
{
'parseline'
};
}
@tbl
= &'TableParse(
@text
);
if
(
$param
{
'where'
} ne
''
) {
@tbl
= &
'TableFilter(*tbl, $param{'
where'},
*var
);
delete
$param
{
'where'
};
}
if
(
$param
{
'sort'
} ne
''
) {
@sort_by
=
$param
{
'sort'
} == 1 ? () :
split
(/,/,
$param
{
'sort'
});
@tbl
= &'TableSort(
*tbl
,
@sort_by
);
delete
$param
{
'sort'
};
}
if
(
$param
{
'delete'
} ne
''
) {
@delete
=
split
(/,/,
$param
{
'delete'
});
@tbl
= &'TableDeleteFields(
*tbl
,
@delete
);
delete
$param
{
'delete'
};
}
if
(
$param
{
'select'
} ne
''
) {
@select
=
split
(/,/,
$param
{
'select'
});
@tbl
= &'TableSelectFields(
*tbl
,
@select
);
delete
$param
{
'select'
};
}
if
(
$param
{
'groups'
} ne
''
) {
$grp_search
=
$param
{
'groups'
};
$grp_search
=
':$'
if
$grp_search
== 1;
delete
$param
{
'groups'
};
}
@body_tags
=
split
(
","
,
$param
{
'coltags'
} ||
$param
{
'tags'
} ||
$param
{
'objects'
});
delete
$param
{
'coltags'
};
delete
$param
{
'tags'
};
delete
$param
{
'objects'
};
if
(
$param
{
'colaligns'
} =~ /^[LCR]+$/) {
@col_aligns
= ();
for
$align
(
split
(//,
$param
{
'colaligns'
})) {
push
(
@col_aligns
,
$_ALIGN_NAMES
{
$align
});
}
$param
{
'colaligns'
} =
join
(
','
,
@col_aligns
);
}
else
{
@col_aligns
=
split
(/,/,
$param
{
'colaligns'
});
}
if
(
$param
{
'colvaligns'
} =~ /^[TMBL]+$/) {
@col_valigns
= ();
for
$valign
(
split
(//,
$param
{
'colvaligns'
})) {
push
(
@col_valigns
,
$_VALIGN_NAMES
{
$valign
});
}
}
else
{
@col_valigns
=
split
(/,/,
$param
{
'colvaligns'
});
}
delete
$param
{
'colvaligns'
};
$noheadings
=
$param
{
'noheadings'
};
delete
$param
{
'noheadings'
};
$nocalcs
=
$param
{
'nocalcs'
};
delete
$param
{
'nocalcs'
};
$nice_hdgs
=
defined
(
$param
{
'niceheadings'
}) ?
$param
{
'niceheadings'
} : 1;
delete
$param
{
'niceheadings'
};
$keepindents
=
$param
{
'keepindents'
};
delete
$param
{
'keepindents'
};
$bgcolor
=
$param
{
'bgcolor'
};
delete
$param
{
'bgcolor'
};
$oncell
=
$param
{
'oncell'
};
delete
$param
{
'oncell'
};
if
(
defined
$param
{
'wrap'
}) {
$wrap
=
$param
{
'wrap'
};
$wrap_counter
=
$wrap
;
delete
$param
{
'wrap'
};
}
else
{
$wrap
= 0;
}
$tbl_header
=
shift
@tbl
;
@flds
= &'TableFieldsCheck(
$tbl_header
);
$tbl_cols
=
scalar
(
@flds
);
if
(
defined
$param
{
'headings'
}) {
$body_start
=
$param
{
'headings'
};
delete
$param
{
'headings'
};
}
elsif
(
$noheadings
) {
$body_start
= 0;
}
else
{
%default_heading
= ();
for
$fld
(
@flds
) {
$cell
=
$fld
;
$cell
=~ s/_(_*)/$& eq
'_'
?
' '
: $1/eg
if
$nice_hdgs
;
$default_heading
{
$fld
} =
$cell
;
}
unshift
(
@tbl
, &'TableRecJoin(
*flds
,
%default_heading
));
$body_start
= 1;
}
if
(
$wrap
&&
$body_start
) {
@headings
= ();
for
$rec
(
@tbl
[0 ..
$body_start
- 1]) {
for
$i
(1 ..
$wrap
) {
push
(
@headings
,
$rec
);
}
}
splice
(
@tbl
, 0,
$body_start
,
@headings
);
$body_start
=
scalar
(
@headings
);
}
$footing_start
=
scalar
(
@tbl
);
if
(
defined
$param
{
'footings'
}) {
$footing_count
=
$param
{
'footings'
};
delete
$param
{
'footings'
};
if
(
$footing_count
>= 1) {
$i
=
$footing_count
;
for
(
$row
=
$#tbl
;
$row
> 0;
$row
--) {
next
if
$tbl
[
$row
] =~ /^!/;
$i
--;
last
if
$i
== 0;
}
}
$footing_start
=
$row
;
}
if
(
$wrap
&&
$footing_count
) {
@footings
= ();
for
$rec
(
@tbl
[
$footing_start
..
$#tbl
]) {
for
$i
(1 ..
$wrap
) {
push
(
@footings
,
$rec
);
}
}
splice
(
@tbl
,
$footing_start
,
$footing_count
,
@footings
);
}
$last_col
=
$tbl_cols
- 1;
$last_row
=
scalar
(
@tbl
) - 1;
$row
= 0;
$col
= 0;
%cover
= ();
$actual_cols
=
$tbl_cols
;
$actual_cols
*=
$wrap
if
$wrap
;
@sdf
= (
"!table $actual_cols;"
. &'SdfAttrJoin(
*param
));
for
$rec
(
@tbl
) {
if
(
$rec
=~ /^!/) {
push
(
@sdf
,
$rec
);
next
;
}
%values
= &'TableRecSplit(
*flds
,
$rec
);
cell:
for
(
$col
= 0;
$col
<=
$#flds
;
$col
++) {
$fld
=
$flds
[
$col
];
$hidden
=
$cover
{
$row
,
$col
};
$cell
=
$values
{
$fld
};
if
(
$col
== 0) {
if
(
$row
<
$body_start
) {
$row_type
=
'Heading'
;
}
elsif
(
$row
==
$footing_start
) {
$wrap_counter
=
$wrap
;
$row_type
=
'Footing'
;
}
elsif
(
$row
>
$footing_start
) {
$row_type
=
'Footing'
;
}
elsif
(
$grp_search
ne
''
&&
$cell
=~ /
$grp_search
/) {
$row_type
=
'Group'
;
$wrap_counter
=
$wrap
;
}
else
{
$wrap_counter
=
$wrap
if
$row_type
eq
'Group'
;
$row_type
=
''
;
}
$row_text
=
$row_type
?
"!row '$row_type'"
:
"!row"
;
if
(
$wrap
) {
if
(
$wrap_counter
++ >=
$wrap
) {
$wrap_counter
= 1;
}
else
{
$row_text
=
''
;
}
}
push
(
@sdf
,
$row_text
)
if
$row_text
;
}
if
(
$hidden
&&
$cell
ne
''
) {
&
'AppMsg("warning", "ignoring hidden cell ($row,$col)='
$cell
'");
}
%cell
= ();
if
(
substr
(
$cell
, 0, 1) eq
"\n"
) {
(
$cell
,
%cell
) = &'SdfParseCell(
substr
(
$cell
, 1));
$cell
{
'sdf'
} = 1;
}
else
{
(
$cell
,
%cell
) = &'SdfParseCell(
$cell
);
}
&calc_table
()
unless
$nocalcs
;
if
(
$hidden
) {
push
(
@sdf
,
"!cell hidden"
);
next
cell;
}
unless
(
defined
(
$cell
{
'align'
})) {
$cell
{
'align'
} =
$col_aligns
[
$col
]
if
$col_aligns
[
$col
];
}
unless
(
defined
(
$cell
{
'valign'
})) {
$cell
{
'valign'
} =
$col_valigns
[
$col
]
if
$col_valigns
[
$col
];
}
unless
(
defined
(
$cell
{
'tag'
})) {
$cell
{
'tag'
} =
$row_type
eq
''
?
$body_tags
[
$col
] : 2;
}
unless
(
defined
(
$cell
{
'bgcolor'
})) {
$cell
{
'bgcolor'
} =
$bgcolor
if
$bgcolor
ne
''
;
}
$cell
{
'cols'
} = 1
unless
defined
(
$cell
{
'cols'
});
$cell
{
'rows'
} = 1
unless
defined
(
$cell
{
'rows'
});
if
(
$oncell
) {
eval
$oncell
;
if
($@) {
&'AppMsg(
"error"
,
"oncell processing failed: $@"
);
}
}
$rowspan
=
$cell
{
'rows'
};
$colspan
=
$cell
{
'cols'
};
for
(
$i
= 0;
$i
<
$rowspan
;
$i
++) {
for
(
$j
= 0;
$j
<
$colspan
;
$j
++) {
$cover
{
$row
+
$i
,
$col
+
$j
} = 1;
}
}
if
(
$cell
{
"sdf"
}) {
delete
$cell
{
"sdf"
};
}
else
{
if
(
$keepindents
) {
$cell
=~ s/^([ ]+)/
'E<nbspace>'
x
length
($1)/eg;
}
if
(
$cell
{
'tag'
} ne
''
) {
$cell
=
"{{"
.
$cell
{
'tag'
} .
":$cell}}"
;
}
$cell
=
":$cell"
;
}
delete
$cell
{
'tag'
};
push
(
@sdf
,
"!cell "
. &'SdfAttrJoin(
*cell
),
split
(
"\n"
,
$cell
));
}
$row
++;
}
push
(
@sdf
,
"!endtable"
);
@text
=
scalar
(
@sdf
) > 2 ?
@sdf
: ();
}
sub
ascii_graphic_Filter {
local
(
*text
,
%param
) =
@_
;
@text
=
grep
(s/^/E80:/,
@text
);
}
@_abstract_FilterParams
= ();
sub
abstract_Filter {
local
(
*text
,
%param
) =
@_
;
unshift
(
@text
,
'!on paragraph \'\'; __abstract; '
.
'@attr{"left", "right", "first", "obj"} = (18, 18, 18, 1)'
);
push
(
@text
,
'!off paragraph __abstract'
);
if
(
$var
{
'OPT_TARGET'
} eq
'html'
||
$var
{
'OPT_TARGET'
} eq
'hlp'
) {
unshift
(
@text
,
'P1: Abstract'
);
}
}
sub
quote_Filter {
local
(
*text
,
%param
) =
@_
;
if
(
$var
{
'OPT_DRIVER'
} eq
'html'
) {
unshift
(
@text
,
'!on paragraph \'\'; __quote; $attr{"obj"} = 1'
);
}
else
{
unshift
(
@text
,
'!on paragraph \'\'; __quote; '
.
'@attr{"left", "right", "first", "obj"} = (18, 18, 18, 1)'
);
}
push
(
@text
,
'!off paragraph __quote'
);
}
sub
address_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$line
);
for
$line
(
@text
) {
$line
=
"Addr:$line"
;
}
}
sub
nofill_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$para
);
$para
=
join
(
'{{CHAR:nl}}'
,
@text
);
@text
= (
$para
);
}
@_sections_FilterParams
= ();
sub
sections_Filter {
local
(
*text
,
%param
) =
@_
;
if
(
$var
{
'OPT_TARGET'
} eq
'html'
||
$var
{
'OPT_TARGET'
} eq
'hlp'
) {
unshift
(
@text
,
'!on paragraph \'\'; __sections; $attr{"obj"} = "SECT"'
);
push
(
@text
,
'!off paragraph __sections'
);
}
}
@_topics_FilterParams
= (
'Name Type Rule'
,
'intro string'
,
'noslide boolean'
,
'data boolean'
,
);
@_topics_FilterModel
= (
'Field Category Rule'
,
'Topic mandatory'
,
'Label optional'
,
'Level optional'
,
'Next optional'
,
'Prev optional'
,
'Up optional'
,
);
sub
topics_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$topic
);
local
(
$label
);
local
(
$file
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_topics_FilterModel
)
if
$validate
;
@flds
= &'TableFields(
shift
@tbl
);
if
(
$param
{
'data'
}) {
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$file
=
$values
{
'Topic'
};
$topic_label
{
$file
} =
$values
{
'Label'
};
$topic_level
{
$file
} =
$values
{
'Level'
};
$topic_next
{
$file
} =
$values
{
'Next'
};
$topic_prev
{
$file
} =
$values
{
'Prev'
};
$topic_up
{
$file
} =
$values
{
'Up'
};
}
return
;
}
if
(
$var
{
'HTML_SUBTOPICS_MODE'
}) {
push
(
@text
,
$param
{
'intro'
})
if
$param
{
'intro'
} ne
''
;
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$topic
=
$values
{
'Topic'
};
$file
=
$topic
;
$label
=
$values
{
'Label'
} ?
$values
{
'Label'
} :
$topic_label
{
$file
};
$label
=
$topic
if
$label
eq
''
;
push
(
@text
,
"!include '$topic.sdf'"
);
}
}
else
{
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$topic
=
$values
{
'Topic'
};
push
(
@text
,
"!include '$topic.sdf'"
);
}
}
unless
(
$param
{
'noslide'
}) {
unshift
(
@text
,
"!slide_down"
);
push
(
@text
,
"!slide_up"
);
}
}
@_jumps_FilterParams
= ();
@_jumps_FilterModel
= (
'Field Category Rule'
,
'Jump key'
,
'Physical mandatory'
,
);
sub
jumps_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$jump
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_jumps_FilterModel
)
if
$validate
;
@flds
= &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$jump
=
$values
{
'Jump'
};
$jump
{
$jump
} =
$values
{
'Physical'
};
}
}
@_title_FilterParams
= (
'Name Type Rule'
,
'type string'
,
'toc integer'
,
'format string'
,
);
sub
title_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$format
);
local
(
$params
);
local
(
$target
);
local
(
$title
);
local
(
$logo
);
$format
=
defined
(
$param
{
'format'
}) ?
$param
{
'format'
} :
'28'
;
$params
=
"format=$format"
;
@text
= (
"!block namevalues; $params"
,
@text
,
'!endblock'
);
$target
=
$var
{
'OPT_TARGET'
};
$title
=
$param
{
'type'
} ||
$var
{
'DOC_TYPE'
};
if
(
$title
ne
''
) {
if
(
$target
eq
'html'
) {
unshift
(
@text
,
'P2[notoc]'
.
$title
);
}
else
{
$title
=
'{{B[family="Helvetica";size=14]'
.
$title
.
'}}'
;
unshift
(
@text
,
'!block box; narrow; wide'
,
$title
,
'!endblock'
,
'E:'
);
}
}
$logo
=
$var
{
'DOC_ADMIN_LOGO'
} ||
$var
{
'DOC_LOGO'
};
$base
=
$var
{
'DOC_ADMIN_LOGO_BASE'
} ||
$var
{
'DOC_LOGO_BASE'
};
if
(
$logo
ne
''
) {
unshift
(
@text
,
"!import '$logo'; wide; wrap_text; align=Right; base='$base'"
);
}
if
(
$param
{
'toc'
}) {
push
(
@text
,
"!default DOC_TOC $param{'toc'}"
);
if
(
$target
eq
'html'
) {
push
(
@text
,
"!block inline; target='html'"
,
"<!-- TOC -->"
,
"<!-- ENDTOC -->"
,
"!endblock"
);
}
}
push
(
@text
,
"Line[wide]"
);
}
@_box_FilterParams
= (
'Name Type Rule'
,
'align string'
,
'listitem integer'
,
'narrow boolean'
,
'wide boolean'
,
'lines boolean'
,
'bgcolor string'
,
'fill integer'
,
);
sub
box_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$line
);
local
(
$params
);
$params
=
'noheadings; nocalcs; style="columns"; tmargin=6'
;
if
(
$param
{
'lines'
}) {
for
(
$line
= 0;
$line
<
$#text
;
$line
++) {
$text
[
$line
] .=
"[[nl]]"
;
}
delete
$param
{
'lines'
};
$params
.=
'; colaligns="C"'
;
}
if
(
$param
{
'fill'
}) {
unshift
(
@text
,
'[fill='
.
$param
{
'fill'
} .
']'
);
delete
$param
{
'fill'
};
}
if
(
%param
) {
$params
.=
'; '
. &'SdfAttrJoin(
*param
);
}
@text
= (
"!block table; $params"
,
'Dummy'
,
'<<'
,
@text
,
'>>'
,
'!endblock'
);
}
@_namevalues_FilterParams
= (
'Name Type Rule'
,
'format string'
,
);
@_namevalues_FilterModel
= (
'Field Category Rule'
,
'Name optional'
,
'Value optional'
,
);
sub
namevalues_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$target
);
local
(
$format
);
local
(
$width
);
@tbl
= &'TableParse(
@text
);
&_FilterValidate
(
*tbl
,
*_namevalues_FilterModel
)
if
$validate
;
if
(
$param
{
'format'
}) {
$format
=
$param
{
'format'
};
}
else
{
$width
=
$var
{
'OPT_SIDEHEAD_WIDTH'
} +
$var
{
'OPT_SIDEHEAD_GAP'
} - 2;
if
(
$var
{
'OPT_LIST_INDENT'
} > 0) {
$width
+=
$var
{
'OPT_LIST_INDENT'
}
while
$width
<= 90;
}
$format
=
$width
.
'pt'
;
}
$target
=
$var
{
'OPT_TARGET'
};
if
(
$target
eq
'html'
||
$target
eq
'hlp'
||
$target
eq
'txt'
||
$target
eq
'pod'
) {
unshift
(
@text
,
"!block table; noheadings; style='plain'; tags='B,,B,,B'; wide; format='$format'"
);
push
(
@text
,
"!endblock"
);
}
else
{
@text
= ();
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
push
(
@text
,
"NV[label='$values{'Name'}\\t']$values{'Value'}"
);
}
}
}
@_define_FilterParams
= (
'Name Type Rule'
,
'family string <\w+>'
,
'export boolean'
,
);
@_define_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'Value optional'
,
);
sub
define_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$family
,
$export
,
$name
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_define_FilterModel
)
if
$validate
;
$family
=
$param
{
'family'
};
$family
.=
'_'
if
$family
ne
''
;
$export
=
$param
{
'export'
};
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$family
.
$values
{
'Name'
};
push
(
@text
,
"!define $name $values{'Value'}"
);
push
(
@text
,
"!export $name"
)
if
$export
;
}
}
@_default_FilterParams
= (
'Name Type Rule'
,
'family string <\w+>'
,
'export boolean'
,
);
@_default_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'Value optional'
,
);
sub
default_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$family
,
$export
,
$name
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_default_FilterModel
)
if
$validate
;
$family
=
$param
{
'family'
};
$family
.=
'_'
if
$family
ne
''
;
$export
=
$param
{
'export'
};
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$family
.
$values
{
'Name'
};
push
(
@text
,
"!default $name $values{'Value'}"
);
push
(
@text
,
"!export $name"
)
if
$export
&& !
$export
{
$name
};
}
}
@_script_FilterParams
= ();
sub
script_Filter {
local
(
*text
,
%param
) =
@_
;
eval
join
(
"\n"
,
@text
);
if
($@) {
&'AppMsg(
"error"
,
"script failed: $@"
);
}
@text
= ();
}
@_pod_FilterParams
= (
'Name Type Rule'
,
'main boolean'
,
);
sub
pod_Filter {
local
(
*text
,
%param
) =
@_
;
@text
= pod2sdf(\
@text
, \
%param
);
}
@_get_FilterParams
= (
'Name Type Rule'
,
'report string'
,
'rule string'
,
'filename string'
,
'inverse boolean'
,
);
sub
get_Filter {
local
(
*text
,
%param
) =
@_
;
$param
{
'filename'
} ||=
$var
{
'FILE_PATH'
};
my
$opts
=
"-g$param{'rule'} -f$param{'filename'} "
;
$opts
.=
$param
{
'inverse'
} ?
"-i"
:
"-r$param{'report'}"
;
&CommandFilter
(
*text
,
"sdfget $opts -"
,
"get"
);
}
@_inline_FilterParams
= (
'Name Type Rule'
,
'target string <\w+>'
,
'expand boolean'
,
);
sub
inline_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$line
);
$target
=
$param
{
'target'
} ||
'html'
;
for
$line
(
@text
) {
if
(
$param
{
'expand'
}) {
next
if
$line
=~ /^\s*\!/;
$line
=
&main::_SdfParaExpand
(
$line
);
}
$line
=
"__inline[target='$target']$line"
;
}
}
@_end_FilterParams
= ();
sub
end_Filter {
local
(
*text
,
%param
) =
@_
;
unshift
(@
'sdf_end, '
',
@text
);
@text
= ();
}
@_comment_FilterParams
= (
'ANY'
);
sub
comment_Filter {
local
(
*text
,
%param
) =
@_
;
@text
= ();
}
@_toc_html_FilterParams
= ();
sub
toc_html_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$toc_text
,
$toc_tag
);
$toc_text
=
$var
{
'DOC_TOC_TITLE'
};
$toc_text
=
'Table of Contents'
unless
$toc_text
;
$toc_tag
=
$parastyles_to
{
'TOCT'
};
$toc_tag
=
"P2"
unless
$toc_tag
;
unshift
(
@text
,
"!HTML_PRE_SECTION"
,
$toc_tag
.
"[noevents;notoc]$toc_text"
);
}
@_offices_FilterParams
= (
'Name Type Rule'
,
'style string'
,
);
sub
offices_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@result
);
local
(
$line
,
$cell_count
);
$style
=
$param
{
'style'
} ||
'plain'
;
@result
= (
"!table 2; format=55; wide; tmargin=12; bmargin=4; style='$style'"
);
$cell_count
= 0;
for
$line
(
@text
) {
$line
=~ s/\s+$//;
next
if
$line
eq
''
;
next
if
$line
=~ /^\s*
if
(
$line
=~ /^GROUP:\s*/) {
$cell_count
= 0;
push
(
@result
,
"!row 'Group'"
,
"!cell cols=2; tmargin=14; bmargin=6; truling=Thin; bruling=Thin"
,
"N[size='11pt';bold]$'"
);
}
elsif
(
$line
=~ /:$/) {
push
(
@result
,
"!row"
)
if
$cell_count
++ % 2 == 0;
push
(
@result
,
"!cell"
);
push
(
@result
,
"N[size='10pt']{{B:$line}}"
);
}
elsif
(
$line
=~ /^Ph:\s*/) {
push
(
@result
,
"N[size='10pt';tabs='36pt']Ph:[[tab]]$'"
);
}
elsif
(
$line
=~ /^Fax:\s*/) {
push
(
@result
,
"[[nl]]Fax:[[tab]]$'"
);
}
else
{
push
(
@result
,
"[[nl]]$line"
);
}
}
@text
= (
@result
,
"!endtable"
);
}
@_hlp_header_FilterParams
= ();
@_hlp_header_FilterModel
= (
'Field Category Rule'
,
'Text key'
,
'Kind optional <popup|jump>'
);
sub
hlp_header_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$item
,
@items
,
$thetext
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_hlp_header_FilterModel
)
if
$validate
;
return
unless
$var
{
'OPT_TARGET'
} eq
'hlp'
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$thetext
=
$values
{
'Text'
};
if
(
$values
{
'Kind'
} eq
'jump'
) {
$item
=
"{{N[jump='#jump_${topic}_$thetext';size='8 pt'] $thetext}}"
;
}
else
{
$item
=
"{{N[hlp.popup='#jump_${topic}_$thetext';size='8 pt'] $thetext}}"
;
}
push
(
@items
,
$item
);
}
@text
= (
"[hlp.header]"
.
join
(
"{{E: }}"
,
@items
));
}
@_hlp_window_FilterParams
= ();
sub
hlp_window_Filter {
local
(
*text
,
%param
) =
@_
;
unshift
(
@text
,
'!on paragraph ; __window_filter; $attr{"hlp.window"} = "1"'
);
push
(
@text
,
"!off paragraph __window_filter"
,
"[hlp.endwindow=1]"
);
}
@_langdefs_FilterParams
= ();
sub
langdefs_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
$_
,
@language_definition
);
@language_definition
= ();
for
$_
(
@text
) {
next
if
(/^
push
(
@language_definition
,
$_
);
&_DefineLang
(
*language_definition
)
unless
/\\$/;
}
@text
= ();
}
@_docstyles_FilterParams
= ();
@_docstyles_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'To optional'
,
'Variables optional'
,
);
sub
docstyles_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$name
);
local
(
$to
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_docstyles_FilterModel
)
if
$validate
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$values
{
'Name'
};
$docstyles_name
{
$name
} = 1;
$to
=
$values
{
'To'
};
if
(
$to
ne
''
) {
$docstyles_to
{
$name
} =
$to
;
$docstyles_vars
{
$name
} =
$values
{
'Variables'
};
}
}
}
@_variables_FilterParams
= (
'Name Type Rule'
,
'family string <[\w,]+>'
,
'export boolean'
,
);
@_variables_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'Type mandatory <\w+>'
,
'Rule optional'
,
);
sub
variables_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
@family
,
$export
);
local
(
$name
);
local
(
$type
,
$rule
);
local
(
$family
,
@fullname
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_variables_FilterModel
)
if
$validate
;
@family
=
split
(/,/,
$param
{
'family'
});
$export
=
$param
{
'export'
};
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$values
{
'Name'
};
$type
=
$values
{
'Type'
};
$rule
=
$values
{
'Rule'
};
if
(
@family
) {
for
$family
(
@family
) {
$fullname
=
"${family}_$name"
;
$variables_name
{
$fullname
} = 1;
$variables_type
{
$fullname
} =
$type
;
$variables_rule
{
$fullname
} =
$rule
if
$rule
ne
''
;
push
(
@text
,
"!export $fullname"
)
if
$export
;
}
}
else
{
$variables_name
{
$name
} = 1;
$variables_type
{
$name
} =
$type
;
$variables_rule
{
$name
} =
$rule
if
$rule
ne
''
;
push
(
@text
,
"!export $name"
)
if
$export
;
}
}
}
@_parastyles_FilterParams
= ();
@_parastyles_FilterModel
= (
'Field Category Rule'
,
'Name key <[A-Z_0-9]\w*>'
,
'Category optional <example>'
,
'To optional <[\w ]+>'
,
'Attributes optional'
,
);
sub
parastyles_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$name
,
$category
);
local
(
$to
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_parastyles_FilterModel
)
if
$validate
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$values
{
'Name'
};
$category
=
$values
{
'Category'
};
$parastyles_name
{
$name
} = 1;
$parastyles_category
{
$name
} =
$category
if
$category
ne
''
;
$to
=
$values
{
'To'
};
if
(
$to
ne
''
) {
$parastyles_to
{
$name
} =
$to
;
$parastyles_attrs
{
$name
} =
$values
{
'Attributes'
};
}
}
}
@_paraattrs_FilterParams
= (
'Name Type Rule'
,
'family string <\w+>'
,
);
@_paraattrs_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'To optional <\w+>'
,
'Map optional <[\%\&]\w+>'
,
'Attributes optional'
,
'Type optional <\w+>'
,
'Rule optional'
,
);
sub
paraattrs_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$family
);
local
(
$name
);
local
(
$type
,
$rule
);
local
(
$to
,
$map
,
$attrs
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_paraattrs_FilterModel
)
if
$validate
;
$family
=
$param
{
'family'
} ne
''
?
"$param{'family'}."
:
''
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$family
.
$values
{
'Name'
};
$type
=
$values
{
'Type'
};
$rule
=
$values
{
'Rule'
};
$paraattrs_name
{
$name
} = 1;
$paraattrs_type
{
$name
} =
$type
if
$type
ne
''
;
$paraattrs_rule
{
$name
} =
$rule
if
$rule
ne
''
;
$to
=
$values
{
'To'
};
$map
=
$values
{
'Map'
};
$attrs
=
$values
{
'Attributes'
};
if
(
$to
||
$map
||
$attrs
) {
$paraattrs_to
{
$name
} =
$to
;
$paraattrs_map
{
$name
} =
$map
;
$paraattrs_attrs
{
$name
} =
$attrs
;
}
}
}
@_phrasestyles_FilterParams
= ();
@_phrasestyles_FilterModel
= (
'Field Category Rule'
,
'Name key <[A-Z_0-9]\w*>'
,
'Category optional <example|special>'
,
'To optional <\=?\w+>'
,
'Attributes optional'
,
);
sub
phrasestyles_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$name
,
$category
);
local
(
$to
);
local
(
$proxy
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_phrasestyles_FilterModel
)
if
$validate
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$values
{
'Name'
};
$category
=
$values
{
'Category'
};
$phrasestyles_name
{
$name
} = 1;
$phrasestyles_category
{
$name
} =
$category
if
$category
ne
''
;
$to
=
$values
{
'To'
};
if
(
$to
ne
''
) {
if
(
$to
=~ /^\=/) {
$proxy
= $';
if
(
$phrasestyles_name
{
$proxy
}) {
$to
=
$phrasestyles_to
{
$proxy
};
}
else
{
&
'AppMsg("warning", "unknown phrase style $proxy '
$proxy
");
$to
=
$proxy
;
}
}
$phrasestyles_to
{
$name
} =
$to
;
$phrasestyles_attrs
{
$name
} =
$values
{
'Attributes'
};
}
}
}
@_phraseattrs_FilterParams
= (
'Name Type Rule'
,
'family string <\w+>'
,
'para string'
,
);
@_phraseattrs_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'To optional <\w+>'
,
'Map optional <[\%\&]\w+>'
,
'Attributes optional'
,
'Type optional <\w+>'
,
'Rule optional'
,
);
sub
phraseattrs_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$family
,
$para
);
local
(
$name
,
$paraname
);
local
(
$type
,
$rule
);
local
(
$to
,
$map
,
$attrs
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_phraseattrs_FilterModel
)
if
$validate
;
$family
=
$param
{
'family'
} ne
''
?
"$param{'family'}."
:
''
;
$para
=
$param
{
'para'
};
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$family
.
$values
{
'Name'
};
$paraname
=
$family
.
$para
.
$values
{
'Name'
};
$type
=
$values
{
'Type'
};
$rule
=
$values
{
'Rule'
};
$phraseattrs_name
{
$name
} = 1;
$phraseattrs_type
{
$name
} =
$type
if
$type
ne
''
;
$phraseattrs_rule
{
$name
} =
$rule
if
$rule
ne
''
;
$paraattrs_name
{
$paraname
} = 1;
$paraattrs_type
{
$paraname
} =
$type
if
$type
ne
''
;
$paraattrs_rule
{
$paraname
} =
$rule
if
$rule
ne
''
;
$to
=
$values
{
'To'
};
$map
=
$values
{
'Map'
};
$attrs
=
$values
{
'Attributes'
};
if
(
$to
||
$map
||
$attrs
) {
$phraseattrs_to
{
$name
} =
$to
;
$phraseattrs_map
{
$name
} =
$map
;
$phraseattrs_attrs
{
$name
} =
$attrs
;
$paraattrs_to
{
$paraname
} =
$to
;
$paraattrs_map
{
$paraname
} =
$map
;
$paraattrs_attrs
{
$paraname
} =
$attrs
;
}
}
}
@_tablestyles_FilterParams
= ();
@_tablestyles_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'To optional <\w+>'
,
'Parameters optional'
,
);
sub
tablestyles_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$name
);
local
(
$to
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_tablestyles_FilterModel
)
if
$validate
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$values
{
'Name'
};
$tablestyles_name
{
$name
} = 1;
$to
=
$values
{
'To'
};
if
(
$to
ne
''
) {
$tablestyles_to
{
$name
} =
$to
;
$tablestyles_params
{
$name
} =
$values
{
'Parameters'
};
}
}
}
@_tableparams_FilterParams
= (
'Name Type Rule'
,
'family string <\w+>'
,
);
@_tableparams_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'To optional <\w+>'
,
'Map optional <[\%\&]\w+>'
,
'Parameters optional'
,
'Type optional <\w+>'
,
'Rule optional'
,
);
sub
tableparams_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$family
);
local
(
$name
);
local
(
$type
,
$rule
);
local
(
$to
,
$map
,
$params
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_tableparams_FilterModel
)
if
$validate
;
$family
=
$param
{
'family'
} ne
''
?
"$param{'family'}."
:
''
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$family
.
$values
{
'Name'
};
$type
=
$values
{
'Type'
};
$rule
=
$values
{
'Rule'
};
$tableparams_name
{
$name
} = 1;
$tableparams_type
{
$name
} =
$type
if
$type
ne
''
;
$tableparams_rule
{
$name
} =
$rule
if
$rule
ne
''
;
$to
=
$values
{
'To'
};
$map
=
$values
{
'Map'
};
$params
=
$values
{
'Parameters'
};
if
(
$to
||
$map
||
$params
) {
$tableparams_to
{
$name
} =
$to
;
$tableparams_map
{
$name
} =
$map
;
$tableparams_params
{
$name
} =
$params
;
}
}
}
@_rowparams_FilterParams
= (
'Name Type Rule'
,
'family string <\w+>'
,
);
@_rowparams_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'To optional <\w+>'
,
'Map optional <[\%\&]\w+>'
,
'Parameters optional'
,
'Type optional <\w+>'
,
'Rule optional'
,
);
sub
rowparams_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$family
);
local
(
$name
);
local
(
$type
,
$rule
);
local
(
$to
,
$map
,
$params
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_rowparams_FilterModel
)
if
$validate
;
$family
=
$param
{
'family'
} ne
''
?
"$param{'family'}."
:
''
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$family
.
$values
{
'Name'
};
$type
=
$values
{
'Type'
};
$rule
=
$values
{
'Rule'
};
$rowparams_name
{
$name
} = 1;
$rowparams_type
{
$name
} =
$type
if
$type
ne
''
;
$rowparams_rule
{
$name
} =
$rule
if
$rule
ne
''
;
$to
=
$values
{
'To'
};
$map
=
$values
{
'Map'
};
$params
=
$values
{
'Parameters'
};
if
(
$to
||
$map
||
$params
) {
$rowparams_to
{
$name
} =
$to
;
$rowparams_map
{
$name
} =
$map
;
$rowparams_params
{
$name
} =
$params
;
}
}
}
@_cellparams_FilterParams
= (
'Name Type Rule'
,
'family string <\w+>'
,
);
@_cellparams_FilterModel
= (
'Field Category Rule'
,
'Name key <\w+>'
,
'To optional <\w+>'
,
'Map optional <[\%\&]\w+>'
,
'Parameters optional'
,
'Type optional <\w+>'
,
'Rule optional'
,
);
sub
cellparams_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$family
);
local
(
$name
);
local
(
$type
,
$rule
);
local
(
$to
,
$map
,
$params
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_cellparams_FilterModel
)
if
$validate
;
$family
=
$param
{
'family'
} ne
''
?
"$param{'family'}."
:
''
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$name
=
$family
.
$values
{
'Name'
};
$type
=
$values
{
'Type'
};
$rule
=
$values
{
'Rule'
};
$cellparams_name
{
$name
} = 1;
$cellparams_type
{
$name
} =
$type
if
$type
ne
''
;
$cellparams_rule
{
$name
} =
$rule
if
$rule
ne
''
;
$to
=
$values
{
'To'
};
$map
=
$values
{
'Map'
};
$params
=
$values
{
'Parameters'
};
if
(
$to
||
$map
||
$params
) {
$cellparams_to
{
$name
} =
$to
;
$cellparams_map
{
$name
} =
$map
;
$cellparams_params
{
$name
} =
$params
;
}
}
}
@_targetobjects_FilterParams
= (
'Name Type Rule'
,
'type string <\w+>'
,
);
@_targetobjects_FilterModel
= (
'Field Category Rule'
,
'Name key'
,
'Parent optional'
,
'Attributes optional'
,
);
sub
targetobjects_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$type
);
local
(
%attrs
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_targetobjects_FilterModel
)
if
$validate
;
$type
=
$param
{
'type'
};
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
%attrs
= &
'SdfAttrSplit($values{'
Attributes'});
$attrs
{
'Name'
} =
$values
{
'Name'
};
$attrs
{
'Parent'
} =
$values
{
'Parent'
};
push
(
@text
, &'SdfJoin(
"__object"
,
$type
,
%attrs
));
}
}
@_datestrings_FilterParams
= (
);
@_datestrings_FilterModel
= (
'Field Category Rule'
,
'Symbol key <month|smonth|weekday|sweekday|ampm|AMPM>'
,
'Values optional'
,
);
sub
datestrings_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
local
(
$strings
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_datestrings_FilterModel
)
if
$validate
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$strings
= [
split
(/\s+/,
eval
$values
{
'Values'
}) ];
$main::misc_date_strings
{
$values
{
'Symbol'
}} =
$strings
;
}
}
@_meta_FilterParams
= (
);
@_meta_FilterModel
= (
'Field Category Rule'
,
'Name key'
,
'Content optional'
,
);
sub
meta_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_meta_FilterModel
)
if
$validate
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
push
(
@text
, &'SdfJoin(
"__object"
,
"meta"
,
%values
));
}
}
@_links_FilterParams
= (
);
@_links_FilterModel
= (
'Field Category Rule'
,
'Jump key'
,
'Type optional'
,
'Relationship optional'
,
);
sub
links_Filter {
local
(
*text
,
%param
) =
@_
;
local
(
@tbl
,
@flds
,
$rec
,
%values
);
@tbl
= &'TableParse(
@text
);
@text
= ();
&_FilterValidate
(
*tbl
,
*_links_FilterModel
)
if
$validate
;
(
@flds
) = &'TableFields(
shift
@tbl
);
for
$rec
(
@tbl
) {
%values
= &'TableRecSplit(
*flds
,
$rec
);
$values
{
'Type'
} =
'text/css'
if
$values
{
'Type'
} eq
''
;
$values
{
'Relationship'
} =
'stylesheet'
if
$values
{
'Relationship'
} eq
''
;
push
(
@text
, &'SdfJoin(
"__object"
,
"link"
,
%values
));
}
}
@_stylesheet_FilterParams
= (
);
@_stylesheet_FilterModel
= (
);
sub
stylesheet_Filter {
local
(
*text
,
%param
) =
@_
;
@text
= (&'SdfJoin(
"__stylesheet"
,
join
(
"\n"
,
@text
),
%param
));
}
1;