7 |
|
|
8 |
} |
} |
9 |
|
|
10 |
|
<Caption::Supported element types> |
11 |
|
|
12 |
|
- SuikaWiki/0.9 Structure::: |
13 |
|
<XE::sw09|document>, <XE::xhtml2|head>, <XE::xhtml2|body>, |
14 |
|
<XE::sw09|parameter> (deprecated), <XE::sw09|value> (deprecated), |
15 |
|
<XE::sw09|replace> (deprecated), <XE::sw09|text> (deprecated) |
16 |
|
|
17 |
|
- SuikaWikiImage/0.9 Structure::: |
18 |
|
<XE::sw09|image> (deprecated) |
19 |
|
|
20 |
|
- SuikaWiki/0.9 Block-level::: |
21 |
|
<XE::xhtml2|section>, <XE::xhtml2|blockquote>, <XE::html3|bodytext>, |
22 |
|
<XE::sw09|insert>, <XE::sw09|delete>, |
23 |
|
<XE::xhtml2|ul>, <XE::xhtml2|ol>, <XE::xhtml2|dl>, |
24 |
|
<XE::xhtml2|li>, <XE::sw09|dr>, <XE::xhtml2|dt>, <XE::xhtml2|dd>, |
25 |
|
<XE::xhrml2|p>, <XE::xhtml2|pre> |
26 |
|
|
27 |
|
- SuikaWiki/0.10 Block-level::: |
28 |
|
<XE::sw010|ed>, <XE::sw010|comment-p> |
29 |
|
|
30 |
|
- SuikaWiki/0.9 Table::: |
31 |
|
<XE::xhtml2|table>, <XE::xhtml2|tbody>, |
32 |
|
<XE::xhtml2|tr>, <XE::xhtml2|td> |
33 |
|
|
34 |
|
- SuikaWiki/0.9 Hyperlink::: |
35 |
|
<XE::sw09|anchor-external>, <XE::sw09|anchor-internal>, |
36 |
|
<XE::sw09|anchor-end>, <XE::sw09|form> |
37 |
|
|
38 |
|
- SuikaWiki/0.9 Phrase::: |
39 |
|
<XE::xhtml2|dfn>, <XE::xhtml2|q>, <XE::xhtml2|sub>, <XE::xhtml2|sup>, |
40 |
|
<XE::xhtml2|abbr>, <XE::xhtml2|ruby>, <XE::sw09|rubyb>, |
41 |
|
<XE::xhtml2|rb>, <XE::xhtml2|rt>, <XE::xhtml2|var>, |
42 |
|
<XE::xhtml2|code>, <XE::xhtml2|kbd>, <XE::xhtml2|samp> (deprecated), |
43 |
|
<XE::xhtml2|del>, <XE::xhtml2|ins>, <XE::sw09|anchor>, |
44 |
|
<XE::xhtml2|em>, <XE::xhtml2|strong>, <XE::sw09|weak> |
45 |
|
|
46 |
|
- SuikaWiki/0.10 Phrase:: |
47 |
|
<XE::sw010|aa>, <XE::sw010|key>, <XE::xhtml2|span>, |
48 |
|
<XE::xhtml2|cite>, <XE::sw010|csection>, <XE::sw010|src>, |
49 |
|
<XE::sw010|qn>, <XE::sw010|qname>, <XE::sw010|nsuri> |
50 |
|
|
51 |
@Namespace: |
@Namespace: |
52 |
http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup/SuikaWiki/ |
http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup/SuikaWiki/ |
53 |
|
|
746 |
$self->{char} = [0x000A]; |
$self->{char} = [0x000A]; |
747 |
$self->{token} = []; |
$self->{token} = []; |
748 |
$self->{source} = $sourceText; |
$self->{source} = $sourceText; |
749 |
|
pos ($self->{source}) = 0; |
750 |
$self->{location} = {}; |
$self->{location} = {}; |
751 |
$self->{doc} = $self->{<H::f|implementation>} |
$self->{doc} = $self->{<H::f|implementation>} |
752 |
->create_document (<Q::sw09|>, 'document'); |
->create_document (<Q::sw09|>, 'document'); |
894 |
startTagLang : value := ['['] [U+0041..U+005A]+ ['@'] $ltagchar* ['[']; |
startTagLang : value := ['['] [U+0041..U+005A]+ ['@'] $ltagchar* ['[']; |
895 |
termStartTag := ['['] ['[']; |
termStartTag := ['['] ['[']; |
896 |
midTag : value := [']'] $wsp* ['[']; |
midTag : value := [']'] $wsp* ['[']; |
897 |
|
midTagLang : value := [']'] $wsp* ['@'] $ltagchar* ['[']; |
898 |
endTag := [']'] [']']; |
endTag := [']'] [']']; |
899 |
endTagAnchorNumberRef : value := [']'] ['>'] ['>'] $digit+ [']']; |
endTagAnchorNumberRef : value := [']'] ['>'] ['>'] $digit+ [']']; |
900 |
endTagExternalRefStart := [']'] ['<'] -> EndTagExternalRefBody; |
endTagExternalRefStart := [']'] ['<'] -> EndTagExternalRefBody; |
901 |
preEndTag := $rs [']'] ['P'] ['R'] ['E'] [']'] $wsp* $re; |
preStartTag : value := $rs ['['] ['P'] ['R'] ['E'] ['['] $wsp* $re; |
902 |
insEndTag := $rs [']'] ['I'] ['N'] ['S'] [']'] $wsp* $re; |
preStartTagClass : value := $rs ['['] ['P'] ['R'] ['E'] |
903 |
delEndTag := $rs [']'] ['D'] ['E'] ['L'] [']'] $wsp* $re; |
['('] $classchar* [')'] ['['] $wsp* $re; |
904 |
|
insStartTag : value := $rs ['['] ['I'] ['N'] ['S'] ['['] $wsp* $re; |
905 |
|
insStartTagClass : value := $rs ['['] ['I'] ['N'] ['S'] |
906 |
|
['('] $classchar* [')'] ['['] $wsp* $re; |
907 |
|
delStartTag : value := $rs ['['] ['D'] ['E'] ['L'] ['['] $wsp* $re; |
908 |
|
delStartTagClass : value := $rs ['['] ['D'] ['E'] ['L'] |
909 |
|
['('] $classchar* [')'] ['['] $wsp* $re; |
910 |
|
preEndTag : value := $rs [']'] ['P'] ['R'] ['E'] [']'] $wsp* $re; |
911 |
|
insEndTag : value := $rs [']'] ['I'] ['N'] ['S'] [']'] $wsp* $re; |
912 |
|
delEndTag : value := $rs [']'] ['D'] ['E'] ['L'] [']'] $wsp* $re; |
913 |
formStart : value := ['['] ['['] ['#'] [U+0061..U+007A '-']+ |
formStart : value := ['['] ['['] ['#'] [U+0061..U+007A '-']+ |
914 |
-> FormBody; |
-> FormBody; |
915 |
emphasis2 := [U+0027] [U+0027]; |
emphasis2 := [U+0027] [U+0027]; |
918 |
[^'&' U+000D U+000A]+ |
[^'&' U+000D U+000A]+ |
919 |
['&'] ['&'] ['_'] ['_']; |
['&'] ['&'] ['_'] ['_']; |
920 |
obsPreStart : value := $rs $wsp; |
obsPreStart : value := $rs $wsp; |
921 |
noteLine := $rs [';'] [';'] $wsp*; |
noteStart : value := $rs [';'] [';'] $wsp*; |
922 |
todoLine := $rs ['@'] ['@'] $wsp*; |
edStart : value := $rs ['@'] ['@'] $wsp*; |
923 |
tableLine : value := $rs [','] $nonRSRE* $re; |
tableLine : value := $rs [','] $nonRSRE* $re; |
924 |
imageStart : value := $rs ['_'] ['_'] ['I'] ['M'] ['A'] ['G'] ['E'] |
imageStart : value := $rs ['_'] ['_'] ['I'] ['M'] ['A'] ['G'] ['E'] |
925 |
['_'] ['_'] $re; |
['_'] ['_'] $re; |
939 |
|
|
940 |
lexmode MagicParameterValue |
lexmode MagicParameterValue |
941 |
: standalone |
: standalone |
942 |
|
: extends => WSP |
943 |
{ |
{ |
944 |
quotedPair : value := [U+005C] .; |
quotedPair : value := [U+005C] $nonRSRE; |
945 |
?default-token text : value; |
?default-token text : value; |
946 |
lit := ['"'] -> MagicParameter; |
lit := ['"'] -> MagicParameter; |
947 |
} |
} |
963 |
|
|
964 |
lexmode ExternalRefQuotedStringBody |
lexmode ExternalRefQuotedStringBody |
965 |
: standalone |
: standalone |
966 |
|
: extends => WSP |
967 |
{ |
{ |
968 |
lit := ['"'] -> ExternalRefBody; |
lit := ['"'] -> ExternalRefBody; |
969 |
quotedPair : value := [U+005C] . /* | ['\'] $rs $re */; |
quotedPair : value := [U+005C] $nonRSRE; |
970 |
?default-token text : value; |
?default-token text : value; |
971 |
} |
} |
972 |
lexmode EndTagExternalRefQuotedStringBody |
lexmode EndTagExternalRefQuotedStringBody |
973 |
: standalone |
: standalone |
974 |
|
: extends => WSP |
975 |
{ |
{ |
976 |
lit := ['"'] -> EndTagExternalRefBody; |
lit := ['"'] -> EndTagExternalRefBody; |
977 |
quotedPair : value := [U+005C] . /* | ['\'] $rs $re */; |
quotedPair : value := [U+005C] $nonRSRE; |
978 |
?default-token text : value; |
?default-token text : value; |
979 |
} |
} |
980 |
|
|
988 |
|
|
989 |
lexmode FormQuotedStringBody |
lexmode FormQuotedStringBody |
990 |
: standalone |
: standalone |
991 |
|
: extends => WSP |
992 |
{ |
{ |
993 |
lita := [U+0027] -> FormBody; |
lita := [U+0027] -> FormBody; |
994 |
quotedPair := [U+005C] . /* | ['\'] $rs $re */; |
quotedPair : value := [U+005C] $nonRSRE; |
995 |
?default-token text : value; |
?default-token text : value; |
996 |
} |
} |
997 |
|
|
1016 |
} |
} |
1017 |
|
|
1018 |
my $parent; |
my $parent; |
1019 |
/* |
lang:Perl { |
1020 |
block For block-level elements. |
$parent->{block} = [$self->{doc}->document_element->body_element]; |
1021 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1022 |
|
$parent->{section}->[1] = $parent->{block}->[-1]; |
1023 |
|
$parent->{edit} = []; |
1024 |
|
} |
1025 |
|
|
1026 |
|
&Body ($parent => $parent); |
1027 |
|
} // Document |
1028 |
|
|
1029 |
|
rule Body ($parent) |
1030 |
|
: standalone |
1031 |
|
{ |
1032 |
|
/* $parent |
1033 |
|
block i For block-level elements. |
1034 |
section i For i-th-level sections. Null if no (i-1)-th |
section i For i-th-level sections. Null if no (i-1)-th |
1035 |
level section. |
level section. |
1036 |
list i For i-th-level list items. Null if no i-th-level |
list i For i-th-level list items. Null if no i-th-level |
1037 |
list. |
list. |
1038 |
text For texts or inline-level elements |
text i For texts or inline-level elements |
1039 |
Null if no container for inlines. |
Null if no container for inlines. |
1040 |
|
quote i Contains i-th-level quotation's |bodytext| element. |
1041 |
|
edit i Contains |parent| state restored when i-th-level |
1042 |
|
editing element is closed. |
1043 |
|
tr For |tr| elements. |
1044 |
*/ |
*/ |
1045 |
my $state; |
my $state; |
1046 |
/* |
/* |
1047 |
heading Next |eol| closes the heading. |
heading Next |eol| closes the heading. |
1048 |
|
pre In |pre| element. |
1049 |
section Otherwise. |
section Otherwise. |
1050 |
*/ |
*/ |
1051 |
lang:Perl { |
lang:Perl { |
|
$parent->{block} = $self->{docel}->body_element; |
|
|
$parent->{section}->[1] = $parent->{block}; |
|
1052 |
$state = 'section'; |
$state = 'section'; |
1053 |
} |
} |
1054 |
|
|
1055 |
~* (text) { |
~* (text) { |
1056 |
lang:Perl ($v => $token.value) { |
lang:Perl ($v => $token.value) { |
1057 |
unless (defined $parent->{text}) { |
CORE::delete $parent->{tr}; |
1058 |
$parent->{text} = $parent->{block} |
__CODE{setTextParent}__; |
1059 |
->append_child |
$parent->{text}->[-1]->manakai_append_text ($v); |
|
($self->{doc}->create_element_ns |
|
|
(<Q::xhtml2|>, 'h2:p')); |
|
|
} |
|
|
$parent->{text}->manakai_append_text ($v); |
|
1060 |
} |
} |
1061 |
} (startTag) { |
} (startTag) { |
1062 |
my $element_type; |
my $element_type; |
1108 |
|
|
1109 |
&_StartTag ($element_type => $element_type, $class_names => $class_names, |
&_StartTag ($element_type => $element_type, $class_names => $class_names, |
1110 |
$lang_tag => $lang_tag, $parent => $parent); |
$lang_tag => $lang_tag, $parent => $parent); |
1111 |
|
} (termStartTag) { |
1112 |
|
lang:Perl { |
1113 |
|
CORE::delete $parent->{tr}; |
1114 |
|
__CODE{setTextParent}__; |
1115 |
|
my $a_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'anchor'); |
1116 |
|
$parent->{text}->[-1]->append_child ($a_el); |
1117 |
|
push @{$parent->{text}}, $a_el; |
1118 |
|
} |
1119 |
|
} (midTag) { |
1120 |
|
lang:Perl ($v => $token.value) { |
1121 |
|
CORE::delete $parent->{tr}; |
1122 |
|
if (defined $parent->{text}->[0]) { |
1123 |
|
my $xuri = $parent->{text}->[-1]->manakai_expanded_uri; |
1124 |
|
if ($xuri eq <Q::xhtml2|rb> or $xuri eq <Q::xhtml2|rt>) { |
1125 |
|
push @{$parent->{text}}, |
1126 |
|
$parent->{text}->[-1]->parent_node |
1127 |
|
->append_child |
1128 |
|
($self->{doc}->create_element_ns |
1129 |
|
(<Q::xhtml2|>, |
1130 |
|
'h2:rt')); |
1131 |
|
} elsif ($xuri eq <Q::sw010|qname>) { |
1132 |
|
push @{$parent->{text}}, |
1133 |
|
$parent->{text}->[-1]->parent_node |
1134 |
|
->append_child |
1135 |
|
($self->{doc}->create_element_ns |
1136 |
|
(<Q::sw010|>, |
1137 |
|
'nsuri')); |
1138 |
|
} else { |
1139 |
|
__CODE{setTextParent}__; |
1140 |
|
$parent->{text}->[-1]->manakai_append_text ($v); |
1141 |
|
} |
1142 |
|
} else { |
1143 |
|
__CODE{setTextParent}__; |
1144 |
|
$parent->{text}->[-1]->manakai_append_text ($v); |
1145 |
|
} |
1146 |
|
} |
1147 |
|
} (midTagLang) { |
1148 |
|
lang:Perl ($v => $token.value) { |
1149 |
|
CORE::delete $parent->{tr}; |
1150 |
|
if (defined $parent->{text}->[0]) { |
1151 |
|
my $xuri = $parent->{text}->[-1]->manakai_expanded_uri; |
1152 |
|
$v =~ /\@([A-Za-z0-9-]*)/; |
1153 |
|
my $lang = $1; |
1154 |
|
if ($xuri eq <Q::xhtml2|rb> or $xuri eq <Q::xhtml2|rt>) { |
1155 |
|
push @{$parent->{text}}, |
1156 |
|
$parent->{text}->[-1]->parent_node |
1157 |
|
->append_child |
1158 |
|
($self->{doc}->create_element_ns |
1159 |
|
(<Q::xhtml2|>, |
1160 |
|
'h2:rt')); |
1161 |
|
$parent->{text}->[-1] |
1162 |
|
->set_attribute_ns (<Q::xml|>, 'xml:lang', $lang); |
1163 |
|
} elsif ($xuri eq <Q::sw010|qname>) { |
1164 |
|
push @{$parent->{text}}, |
1165 |
|
$parent->{text}->[-1]->parent_node |
1166 |
|
->append_child |
1167 |
|
($self->{doc}->create_element_ns |
1168 |
|
(<Q::sw010|>, |
1169 |
|
'nsuri')); |
1170 |
|
$parent->{text}->[-1] |
1171 |
|
->set_attribute_ns (<Q::xml|>, 'xml:lang', $lang); |
1172 |
|
} else { |
1173 |
|
__CODE{setTextParent}__; |
1174 |
|
$parent->{text}->[-1]->manakai_append_text ($v); |
1175 |
|
} |
1176 |
|
} else { |
1177 |
|
__CODE{setTextParent}__; |
1178 |
|
$parent->{text}->[-1]->manakai_append_text ($v); |
1179 |
|
} |
1180 |
|
} |
1181 |
|
} (endTag) { |
1182 |
|
lang:Perl { |
1183 |
|
my $iref; |
1184 |
|
my $xref; |
1185 |
|
__CODE{endTag:: $tagString => ']]'}__; |
1186 |
|
} |
1187 |
|
} (endTagAnchorNumberRef) { |
1188 |
|
lang:Perl ($v => $token.value) { |
1189 |
|
$v =~ />>([0-9]+)/; |
1190 |
|
my $iref = $1; |
1191 |
|
my $xref; |
1192 |
|
__CODE{endTag:: $tagString => $v}__; |
1193 |
|
} |
1194 |
|
} (endTagExternalRefStart) { |
1195 |
|
my $xref; |
1196 |
|
lang:Perl { |
1197 |
|
$xref = ''; |
1198 |
|
} |
1199 |
|
~* (text) { |
1200 |
|
lang:Perl ($v => $token.value) { |
1201 |
|
$xref .= $v; |
1202 |
|
} |
1203 |
|
} (quotedPair) { |
1204 |
|
lang:Perl ($v => $token.value) { |
1205 |
|
$xref .= $v; |
1206 |
|
} |
1207 |
|
} (lit) { |
1208 |
|
lang:Perl { |
1209 |
|
$xref .= '"'; |
1210 |
|
} |
1211 |
|
} |
1212 |
|
~ (endTagExternalRefEnd) { } |
1213 |
|
lang:Perl { |
1214 |
|
my $iref; |
1215 |
|
__CODE{endTag:: $tagString => {']<'.$xref.'>]'}}__; |
1216 |
|
} |
1217 |
} (eol) { |
} (eol) { |
1218 |
~? (eol) { |
~? (eol) { |
1219 |
lang:Perl { |
lang:Perl { |
1220 |
$parent->{block} = $parent->{section}->[-1]; |
CORE::delete $parent->{tr}; |
1221 |
$parent->{text} = null; |
if ($state eq 'pre') { |
1222 |
$state = 'section'; |
$parent->{text}->[-1]->manakai_append_text ("\x0A\x0A"); |
1223 |
|
} elsif ($state eq 'obspre') { |
1224 |
|
$#{$parent->{block}}--; |
1225 |
|
$parent->{text} = []; |
1226 |
|
$state = 'section'; |
1227 |
|
} else { |
1228 |
|
$parent->{block} = [$parent->{section}->[-1]]; |
1229 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1230 |
|
$parent->{list} = []; |
1231 |
|
$parent->{text} = []; |
1232 |
|
$state = 'section'; |
1233 |
|
} |
1234 |
} |
} |
1235 |
} else { |
} else { |
1236 |
lang:Perl { |
lang:Perl { |
1237 |
|
CORE::delete $parent->{tr}; |
1238 |
if ($state eq 'heading') { |
if ($state eq 'heading') { |
1239 |
$parent->{text} = null; |
$parent->{text} = []; |
1240 |
$state = 'section'; |
$state = 'section'; |
1241 |
} elsif (defined $parent->{text}) { |
} elsif ($state eq 'pre') { |
1242 |
$parent->{text}->manakai_append_text ("\x0A"); |
$parent->{text}->[-1]->manakai_append_text ("\x0A"); |
1243 |
|
} elsif (defined $parent->{text}->[0]) { |
1244 |
|
$parent->{text}->[-1]->manakai_append_text ("\x0A"); |
1245 |
} |
} |
1246 |
} |
} |
1247 |
} |
} |
1248 |
|
} (anchorNumberDef) { |
1249 |
|
lang:Perl ($v => $token.value) { |
1250 |
|
CORE::delete $parent->{tr}; |
1251 |
|
__CODE{setTextParent}__; |
1252 |
|
my $a_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'anchor-end'); |
1253 |
|
$a_el->set_attribute_ns (<Q::sw09|>, 'sw9:anchor', |
1254 |
|
0+substr ($v, 1, length ($v) - 2)); |
1255 |
|
$a_el->text_content ($v); |
1256 |
|
$parent->{text}->[-1]->append_child ($a_el); |
1257 |
|
} |
1258 |
|
} (anchorNumberRef) { |
1259 |
|
lang:Perl ($v => $token.value) { |
1260 |
|
CORE::delete $parent->{tr}; |
1261 |
|
__CODE{setTextParent}__; |
1262 |
|
my $a_el = $self->{doc} |
1263 |
|
->create_element_ns (<Q::sw09|>, 'anchor-internal'); |
1264 |
|
$a_el->set_attribute_ns (<Q::sw09|>, 'sw9:anchor', |
1265 |
|
0+substr ($v, 2)); |
1266 |
|
$a_el->text_content ($v); |
1267 |
|
$parent->{text}->[-1]->append_child ($a_el); |
1268 |
|
} |
1269 |
|
} (externalRefStart) { |
1270 |
|
my $xref; |
1271 |
|
~ (text) { |
1272 |
|
lang:Perl ($v => $token.value) { |
1273 |
|
$xref .= $v; |
1274 |
|
} |
1275 |
|
} (quotedPair) { |
1276 |
|
lang:Perl ($v => $token.value) { |
1277 |
|
$xref .= $v; |
1278 |
|
} |
1279 |
|
} (lit) { |
1280 |
|
lang:Perl { |
1281 |
|
$xref .= '"'; |
1282 |
|
} |
1283 |
|
} |
1284 |
|
~ (externalRefEnd) { } |
1285 |
|
lang:Perl { |
1286 |
|
CORE::delete $parent->{tr}; |
1287 |
|
__CODE{setTextParent}__; |
1288 |
|
my $a_el = $self->{doc} |
1289 |
|
->create_element_ns (<Q::sw09|>, 'anchor-external'); |
1290 |
|
my $data = $xref; |
1291 |
|
my $scheme; |
1292 |
|
if ($data =~ s/^([A-Z]+)://) { |
1293 |
|
$scheme = $1; |
1294 |
|
} else { |
1295 |
|
$scheme = 'URI'; |
1296 |
|
} |
1297 |
|
$a_el->set_attribute_ns (<Q::sw09|>, 'sw9:resScheme', $scheme); |
1298 |
|
$a_el->set_attribute_ns (<Q::sw09|>, 'sw9:resParameter', $data); |
1299 |
|
$a_el->text_content ($xref); |
1300 |
|
$parent->{text}->[-1]->append_child ($a_el); |
1301 |
|
} |
1302 |
} (listStart) { |
} (listStart) { |
1303 |
lang:Perl ($v => $token.value) { |
lang:Perl ($v => $token.value) { |
1304 |
$v =~ /([-=]+)/; |
CORE::delete $parent->{tr}; |
1305 |
my $level = length $1; |
if ($state eq 'pre' or $state eq 'obspre') { |
1306 |
my $type = substr ($1, -1) eq '-' ? 'ul' : 'ol'; |
$parent->{text}->[-1]->manakai_append_text (substr $v, 1); |
1307 |
if (defined $parent->{list}->[$level]) { |
} else { |
1308 |
unless ($parent->{list}->[$level]->local_name eq $type) { |
$v =~ /([-=]+)/; |
1309 |
$parent->{list}->[$level] |
my $level = length ($1) - 1; |
1310 |
= $parent->{list}->[$level]->parent_node |
my $type = substr ($1, -1) eq '-' ? 'ul' : 'ol'; |
1311 |
->append_child |
if (defined $parent->{list}->[$level]) { |
1312 |
($self->{doc}->create_element_ns |
unless ($parent->{list}->[$level]->local_name eq $type) { |
1313 |
(<Q::xhtml2|>, 'h2:'.$type)); |
$parent->{list}->[$level] |
1314 |
} |
= $parent->{list}->[$level]->parent_node |
1315 |
} elsif (defined $parent->{list}->[0]) { |
->append_child |
1316 |
my $parent_list = $parent->{list}->[-1]; |
($self->{doc}->create_element_ns |
1317 |
my $parent_lc = $parent_list->last_child; |
(<Q::xhtml2|>, 'h2:'.$type)); |
1318 |
if (defined $parent_lc and |
} |
1319 |
$parent_lc->node_type eq <C::Node.ELEMENT_NODE>) { |
} elsif (defined $parent->{list}->[0]) { |
1320 |
$parent->{list}->[$level] |
my $parent_list = $parent->{list}->[-1]; |
1321 |
= $parent_lc->append_child |
my $parent_lc = $parent_list->last_child; |
1322 |
($self->{doc}->create_element_ns |
if (defined $parent_lc and |
1323 |
|
$parent_lc->node_type eq <C::Node.ELEMENT_NODE>) { |
1324 |
|
$parent->{list}->[$level] |
1325 |
|
= $parent_lc->append_child |
1326 |
|
($self->{doc}->create_element_ns |
1327 |
(<Q::xhtml2|>, 'h2:'.$type)); |
(<Q::xhtml2|>, 'h2:'.$type)); |
1328 |
|
} else { |
1329 |
|
$parent->{list}->[$level] |
1330 |
|
= $parent_list->append_child |
1331 |
|
($self->{doc}->create_element_ns |
1332 |
|
(<Q::xhtml2|>, 'h2:li')) |
1333 |
|
->append_child |
1334 |
|
($self->{doc}->create_element_ns |
1335 |
|
(<Q::xhtml2|>, 'h2:'.$type)); |
1336 |
|
} |
1337 |
} else { |
} else { |
1338 |
$parent->{list}->[$level] |
$parent->{list}->[$level] |
1339 |
= $parent_list->append_child |
= $parent->{block}->[-1]->append_child |
1340 |
($self->{doc}->create_element_ns |
($self->{doc}->create_element_ns |
|
(<Q::xhtml2|>, 'h2:li')) |
|
|
->append_child |
|
|
($self->{doc}->create_element_ns |
|
1341 |
(<Q::xhtml2|>, 'h2:'.$type)); |
(<Q::xhtml2|>, 'h2:'.$type)); |
1342 |
} |
} |
1343 |
|
push @{$parent->{block}}, |
1344 |
|
$parent->{list}->[$level]->append_child |
1345 |
|
($self->{doc}->create_element_ns |
1346 |
|
(<Q::xhtml2|>, 'h2:li')); |
1347 |
|
$parent->{text} = [$parent->{block}->[-1]]; |
1348 |
|
$state = 'section'; |
1349 |
|
} |
1350 |
|
} |
1351 |
|
} (dlistStart) { |
1352 |
|
lang:Perl ($v => $token.value) { |
1353 |
|
CORE::delete $parent->{tr}; |
1354 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1355 |
|
$parent->{text}->[-1]->manakai_append_text (substr ($v, 1)); |
1356 |
} else { |
} else { |
1357 |
$parent->{list}->[$level] |
$v =~ /:([^:]*)/; |
1358 |
= $parent->{block}->append_child |
my $dt_src = $1; |
1359 |
($self->{doc}->create_element_ns |
|
1360 |
(<Q::xhtml2|>, 'h2:'.$type)); |
my $dr_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'dr'); |
1361 |
|
my $dt_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:dt'); |
1362 |
|
my $dd_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:dd'); |
1363 |
|
$dr_el->append_child ($dt_el); |
1364 |
|
$dr_el->append_child ($dd_el); |
1365 |
|
|
1366 |
|
if ($parent->{block}->[-1]->manakai_expanded_uri eq <Q::xhtml2|dd>) { |
1367 |
|
$parent->{block}->[-1]->parent_node->parent_node |
1368 |
|
->append_child ($dr_el); |
1369 |
|
} else { |
1370 |
|
my $dl_el = $self->{doc}->create_element_ns |
1371 |
|
(<Q::xhtml2|>, 'h2:dl'); |
1372 |
|
$dl_el->append_child ($dr_el); |
1373 |
|
$parent->{block}->[-1]->append_child ($dl_el); |
1374 |
|
} |
1375 |
|
push @{$parent->{block}}, $dd_el; |
1376 |
|
$parent->{text} = [$dd_el]; |
1377 |
|
$parent->{list} = []; |
1378 |
|
$parent->{edit} = []; |
1379 |
|
$state = 'section'; |
1380 |
|
|
1381 |
|
my $original_pos = pos $self->{source}; |
1382 |
|
{ |
1383 |
|
local $self->{token} = []; |
1384 |
|
local $self->{char} = []; |
1385 |
|
local $self->{source} = $dt_src; |
1386 |
|
pos ($self->{source}) = 0; |
1387 |
|
local $self->{location} = {}; |
1388 |
|
local $self->{scanner} = $self->can ('_scan_Body'); |
1389 |
|
$self->_parse_Body ({ |
1390 |
|
block => [$dt_el], |
1391 |
|
quote => [$dt_el], |
1392 |
|
section => [null, $dt_el], |
1393 |
|
text => [$dt_el], |
1394 |
|
}); |
1395 |
|
} |
1396 |
|
pos ($self->{source}) = $original_pos; |
1397 |
|
} |
1398 |
|
} |
1399 |
|
} (emphasis2) { |
1400 |
|
lang:Perl { |
1401 |
|
CORE::delete $parent->{tr}; |
1402 |
|
if (defined $parent->{text}->[1] and |
1403 |
|
$parent->{text}->[-1]->manakai_expanded_uri eq <Q::xhtml2|em>) { |
1404 |
|
$#{$parent->{text}}--; |
1405 |
|
} else { |
1406 |
|
__CODE{setTextParent}__; |
1407 |
|
my $em_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:em'); |
1408 |
|
$parent->{text}->[-1]->append_child ($em_el); |
1409 |
|
push @{$parent->{text}}, $em_el; |
1410 |
|
} |
1411 |
|
} |
1412 |
|
} (emphasis3) { |
1413 |
|
lang:Perl { |
1414 |
|
CORE::delete $parent->{tr}; |
1415 |
|
if (defined $parent->{text}->[1] and |
1416 |
|
$parent->{text}->[-1]->manakai_expanded_uri |
1417 |
|
eq <Q::xhtml2|strong>) { |
1418 |
|
$#{$parent->{text}}--; |
1419 |
|
} else { |
1420 |
|
__CODE{setTextParent}__; |
1421 |
|
my $em_el = $self->{doc}->create_element_ns |
1422 |
|
(<Q::xhtml2|>, 'h2:strong'); |
1423 |
|
$parent->{text}->[-1]->append_child ($em_el); |
1424 |
|
push @{$parent->{text}}, $em_el; |
1425 |
|
} |
1426 |
|
} |
1427 |
|
} (quote) { |
1428 |
|
lang:Perl ($v => $token.value) { |
1429 |
|
CORE::delete $parent->{tr}; |
1430 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1431 |
|
$parent->{text}->[-1]->manakai_append_text (substr ($v, 1)); |
1432 |
|
} else { |
1433 |
|
$v =~ /(>+)/; |
1434 |
|
my $level = length $1; |
1435 |
|
if (defined $parent->{quote}->[$level]) { |
1436 |
|
if (defined $parent->{quote}->[$level + 1]) { |
1437 |
|
$#{$parent->{quote}} = $level; |
1438 |
|
} |
1439 |
|
} else { |
1440 |
|
L: for my $i (1..$level) { |
1441 |
|
next L if defined $parent->{quote}->[$i]; |
1442 |
|
$parent->{quote}->[$i] |
1443 |
|
= $parent->{quote}->[$i - 1] |
1444 |
|
->append_child ($self->{doc}->create_element_ns |
1445 |
|
(<Q::xhtml2|>, 'h2:blockquote')) |
1446 |
|
->append_child |
1447 |
|
($self->{doc}->create_element_ns |
1448 |
|
(<Q::html3|>, 'h3:bodytext')); |
1449 |
|
} # L |
1450 |
|
} |
1451 |
|
push @{$parent->{block}}, $parent->{quote}->[$level]; |
1452 |
|
$parent->{text} = []; |
1453 |
|
$parent->{list} = []; |
1454 |
|
$state = 'section'; |
1455 |
} |
} |
|
$parent->{block} = |
|
|
$parent->{text} = $parent->{list}->[$level] |
|
|
->append_child |
|
|
($self->{doc}->create_element_ns |
|
|
(<Q::xhtml2|>, 'h2:li')); |
|
|
$state = 'section'; |
|
1456 |
} |
} |
1457 |
} (headingStart) { |
} (headingStart) { |
1458 |
lang:Perl ($v => $token.value) { |
lang:Perl ($v => $token.value) { |
1459 |
$v =~ /(\*+)/; |
CORE::delete $parent->{tr}; |
1460 |
my $level = length $1; |
if ($state eq 'pre' or $state eq 'obspre') { |
1461 |
if (defined $parent->{section}->[$level]) { |
$parent->{text}->[-1]->manakai_append_text (substr ($v, 1)); |
1462 |
if (defined $parent->{section}->[$level + 1]) { |
} else { |
1463 |
$#{$parent->{section}} = $level; |
$v =~ /(\*+)/; |
1464 |
|
my $level = length $1; |
1465 |
|
if (defined $parent->{section}->[$level]) { |
1466 |
|
if (defined $parent->{section}->[$level + 1]) { |
1467 |
|
$#{$parent->{section}} = $level; |
1468 |
|
} |
1469 |
|
} else { |
1470 |
|
L: for my $i (2..$level) { |
1471 |
|
next L if defined $parent->{section}->[$i]; |
1472 |
|
$parent->{section}->[$i] |
1473 |
|
= $self->{doc}->create_element_ns |
1474 |
|
(<Q::xhtml2|>, 'h2:section'); |
1475 |
|
$parent->{section}->[$i - 1] |
1476 |
|
->append_child ($parent->{section}->[$i]); |
1477 |
|
} # L |
1478 |
} |
} |
1479 |
|
$parent->{section}->[$level + 1] |
1480 |
|
= $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:section'); |
1481 |
|
$parent->{section}->[$level] |
1482 |
|
->append_child ($parent->{section}->[$level + 1]); |
1483 |
|
$parent->{block} = [$parent->{section}->[$level + 1]]; |
1484 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1485 |
|
$parent->{text} = [$self->{doc}->create_element_ns |
1486 |
|
(<Q::xhtml2|>, 'h2:h')]; |
1487 |
|
$parent->{block}->[-1]->append_child ($parent->{text}->[-1]); |
1488 |
|
$parent->{list} = []; |
1489 |
|
$state = 'heading'; |
1490 |
|
} |
1491 |
|
} |
1492 |
|
} (noteStart) { |
1493 |
|
lang:Perl ($v => $token.value) { |
1494 |
|
CORE::delete $parent->{tr}; |
1495 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1496 |
|
$parent->{text}->[-1]->manakai_append_text |
1497 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1498 |
} else { |
} else { |
1499 |
L: for my $i (2..$level) { |
my $ed_el = $self->{doc}->create_element_ns |
1500 |
next L if defined $parent->{section}->[$i]; |
(<Q::sw010|>, 'sw10:comment-p'); |
1501 |
$parent->{section}->[$i] |
$parent->{block}->[-1]->append_child ($ed_el); |
1502 |
= $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:section'); |
push @{$parent->{block}}, $ed_el; |
1503 |
$parent->{section}->[$i - 1] |
$parent->{list} = []; |
1504 |
->append_child ($parent->{section}->[$i]); |
$parent->{quote} = [$ed_el]; |
1505 |
} # L |
$parent->{text} = [$ed_el]; |
1506 |
} |
$state = 'section'; |
1507 |
$parent->{block} = |
} |
1508 |
$parent->{section}->[$level + 1] |
} |
1509 |
= $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:section'); |
} (edStart) { |
1510 |
$parent->{section}->[$level] |
lang:Perl ($v => $token.value) { |
1511 |
->append_child ($parent->{section}->[$level + 1]); |
CORE::delete $parent->{tr}; |
1512 |
$parent->{text} = $self->{doc}->create_element_ns |
if ($state eq 'pre' or $state eq 'obspre') { |
1513 |
(<Q::xhtml2|>, 'h2:h'); |
$parent->{text}->[-1]->manakai_append_text |
1514 |
$parent->{block}->append_child ($parent->{text}); |
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1515 |
$state = 'heading'; |
} else { |
1516 |
|
my $ed_el = $self->{doc}->create_element_ns (<Q::sw010|>, 'sw10:ed'); |
1517 |
|
$parent->{block}->[-1]->append_child ($ed_el); |
1518 |
|
push @{$parent->{block}}, $ed_el; |
1519 |
|
$parent->{list} = []; |
1520 |
|
$parent->{quote} = [$ed_el]; |
1521 |
|
$parent->{text} = [$ed_el]; |
1522 |
|
$state = 'section'; |
1523 |
|
} |
1524 |
|
} |
1525 |
|
} (preStartTag) { |
1526 |
|
lang:Perl ($v => $token.value) { |
1527 |
|
CORE::delete $parent->{tr}; |
1528 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1529 |
|
$parent->{text}->[-1]->manakai_append_text |
1530 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1531 |
|
} else { |
1532 |
|
my $pre_el = $self->{doc}->create_element_ns |
1533 |
|
(<Q::xhtml2|>, 'h2:pre'); |
1534 |
|
$pre_el->set_attribute_ns (<Q::xml|>, 'xml:space', 'preserve'); |
1535 |
|
$parent->{block}->[-1]->append_child ($pre_el); |
1536 |
|
push @{$parent->{block}}, $pre_el; |
1537 |
|
$parent->{text} = [$pre_el]; |
1538 |
|
$state = 'pre'; |
1539 |
|
} |
1540 |
|
} |
1541 |
|
} (preStartTagClass) { |
1542 |
|
lang:Perl ($v => $token.value) { |
1543 |
|
CORE::delete $parent->{tr}; |
1544 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1545 |
|
$parent->{text}->[-1]->manakai_append_text |
1546 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1547 |
|
} else { |
1548 |
|
my $pre_el = $self->{doc}->create_element_ns |
1549 |
|
(<Q::xhtml2|>, 'h2:pre'); |
1550 |
|
$pre_el->set_attribute_ns (<Q::xml|>, 'xml:space', 'preserve'); |
1551 |
|
$v =~ /\(([^()]*)/; |
1552 |
|
$pre_el->set_attribute_ns (null, class => $1); |
1553 |
|
$parent->{block}->[-1]->append_child ($pre_el); |
1554 |
|
push @{$parent->{block}}, $pre_el; |
1555 |
|
$parent->{text} = [$pre_el]; |
1556 |
|
$state = 'pre'; |
1557 |
|
} |
1558 |
|
} |
1559 |
|
} (obsPreStart) { |
1560 |
|
lang:Perl ($v => $token.value) { |
1561 |
|
CORE::delete $parent->{tr}; |
1562 |
|
unless ($state eq 'pre' or $state eq 'obspre') { |
1563 |
|
my $pre_el = $self->{doc}->create_element_ns |
1564 |
|
(<Q::xhtml2|>, 'h2:pre'); |
1565 |
|
$pre_el->set_attribute_ns (<Q::xml|>, 'xml:space', 'preserve'); |
1566 |
|
$parent->{block}->[-1]->append_child ($pre_el); |
1567 |
|
push @{$parent->{block}}, $pre_el; |
1568 |
|
$parent->{text} = [$pre_el]; |
1569 |
|
$state = 'obspre'; |
1570 |
|
} |
1571 |
|
$parent->{text}->[-1]->manakai_append_text (substr ($v, 1)); |
1572 |
|
} |
1573 |
|
} (preEndTag) { |
1574 |
|
lang:Perl ($v => $token.value) { |
1575 |
|
CORE::delete $parent->{tr}; |
1576 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1577 |
|
$#{$parent->{block}}--; |
1578 |
|
$parent->{text} = []; |
1579 |
|
$parent->{list} = []; |
1580 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1581 |
|
$state = 'section'; |
1582 |
|
} else { |
1583 |
|
__CODE{setTextParent}__; |
1584 |
|
$parent->{text}->[-1]->manakai_append_text |
1585 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1586 |
|
} |
1587 |
|
} |
1588 |
|
} (insStartTag) { |
1589 |
|
lang:Perl ($v => $token.value) { |
1590 |
|
CORE::delete $parent->{tr}; |
1591 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1592 |
|
$parent->{text}->[-1]->manakai_append_text |
1593 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1594 |
|
} else { |
1595 |
|
my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'insert'); |
1596 |
|
$parent->{block}->[-1]->append_child ($ins_el); |
1597 |
|
push @{$parent->{edit}}, { |
1598 |
|
section => $parent->{section}, |
1599 |
|
block => $parent->{block}, |
1600 |
|
text => $parent->{text}, |
1601 |
|
list => $parent->{list}, |
1602 |
|
quote => $parent->{quote}, |
1603 |
|
type => 'insert', |
1604 |
|
}; |
1605 |
|
$parent->{section} = [null, $ins_el]; |
1606 |
|
$parent->{block} = [$ins_el]; |
1607 |
|
$parent->{text} = []; |
1608 |
|
$parent->{list} = []; |
1609 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1610 |
|
} |
1611 |
|
} |
1612 |
|
} (insStartTagClass) { |
1613 |
|
lang:Perl ($v => $token.value) { |
1614 |
|
CORE::delete $parent->{tr}; |
1615 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1616 |
|
$parent->{text}->[-1]->manakai_append_text |
1617 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1618 |
|
} else { |
1619 |
|
my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'insert'); |
1620 |
|
$parent->{block}->[-1]->append_child ($ins_el); |
1621 |
|
$v =~ /\(([^()]*)/; |
1622 |
|
$ins_el->set_attribute_ns (null, class => $1); |
1623 |
|
push @{$parent->{edit}}, { |
1624 |
|
section => $parent->{section}, |
1625 |
|
block => $parent->{block}, |
1626 |
|
list => $parent->{list}, |
1627 |
|
quote => $parent->{quote}, |
1628 |
|
type => 'insert', |
1629 |
|
}; |
1630 |
|
$parent->{section} = [null, $ins_el]; |
1631 |
|
$parent->{block} = [$ins_el]; |
1632 |
|
$parent->{text} = []; |
1633 |
|
$parent->{list} = []; |
1634 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1635 |
|
} |
1636 |
|
} |
1637 |
|
} (insEndTag) { |
1638 |
|
lang:Perl ($v => $token.value) { |
1639 |
|
CORE::delete $parent->{tr}; |
1640 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1641 |
|
$parent->{text}->[-1]->manakai_append_text |
1642 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1643 |
|
} else { |
1644 |
|
if (defined $parent->{edit}->[0] and |
1645 |
|
$parent->{edit}->[-1]->{type} eq 'insert') { |
1646 |
|
my $rp = pop @{$parent->{edit}}; |
1647 |
|
$parent->{$_} = $rp->{$_} |
1648 |
|
for qw/section block list quote/; |
1649 |
|
$parent->{text} = []; |
1650 |
|
} else { |
1651 |
|
$parent->{text}->[-1]->manakai_append_text |
1652 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1653 |
|
} |
1654 |
|
} |
1655 |
|
} |
1656 |
|
} (delStartTag) { |
1657 |
|
lang:Perl ($v => $token.value) { |
1658 |
|
CORE::delete $parent->{tr}; |
1659 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1660 |
|
$parent->{text}->[-1]->manakai_append_text |
1661 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1662 |
|
} else { |
1663 |
|
my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'delete'); |
1664 |
|
$parent->{block}->[-1]->append_child ($ins_el); |
1665 |
|
push @{$parent->{edit}}, { |
1666 |
|
section => $parent->{section}, |
1667 |
|
block => $parent->{block}, |
1668 |
|
list => $parent->{list}, |
1669 |
|
quote => $parent->{quote}, |
1670 |
|
type => 'delete', |
1671 |
|
}; |
1672 |
|
$parent->{section} = [null, $ins_el]; |
1673 |
|
$parent->{block} = [$ins_el]; |
1674 |
|
$parent->{text} = []; |
1675 |
|
$parent->{list} = []; |
1676 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1677 |
|
} |
1678 |
|
} |
1679 |
|
} (delStartTagClass) { |
1680 |
|
lang:Perl ($v => $token.value) { |
1681 |
|
CORE::delete $parent->{tr}; |
1682 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1683 |
|
$parent->{text}->[-1]->manakai_append_text |
1684 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1685 |
|
} else { |
1686 |
|
my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'delete'); |
1687 |
|
$parent->{block}->[-1]->append_child ($ins_el); |
1688 |
|
$v =~ /\(([^()]*)/; |
1689 |
|
$ins_el->set_attribute_ns (null, class => $1); |
1690 |
|
push @{$parent->{edit}}, { |
1691 |
|
section => $parent->{section}, |
1692 |
|
block => $parent->{block}, |
1693 |
|
list => $parent->{list}, |
1694 |
|
quote => $parent->{quote}, |
1695 |
|
type => 'delete', |
1696 |
|
}; |
1697 |
|
$parent->{section} = [null, $ins_el]; |
1698 |
|
$parent->{block} = [$ins_el]; |
1699 |
|
$parent->{text} = []; |
1700 |
|
$parent->{list} = []; |
1701 |
|
$parent->{quote} = [$parent->{block}->[-1]]; |
1702 |
|
} |
1703 |
|
} |
1704 |
|
} (delEndTag) { |
1705 |
|
lang:Perl ($v => $token.value) { |
1706 |
|
CORE::delete $parent->{tr}; |
1707 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1708 |
|
$parent->{text}->[-1]->manakai_append_text |
1709 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1710 |
|
} else { |
1711 |
|
if (defined $parent->{edit}->[0] and |
1712 |
|
$parent->{edit}->[-1]->{type} eq 'delete') { |
1713 |
|
my $rp = pop @{$parent->{edit}}; |
1714 |
|
$parent->{$_} = $rp->{$_} |
1715 |
|
for qw/section block list quote/; |
1716 |
|
$parent->{text} = []; |
1717 |
|
} else { |
1718 |
|
$parent->{text}->[-1]->manakai_append_text |
1719 |
|
(substr ($v, 1, length ($v) - 2) . "\x0A"); |
1720 |
|
} |
1721 |
|
} |
1722 |
|
} |
1723 |
|
} (tableLine) { |
1724 |
|
lang:Perl ($v => $token.value) { |
1725 |
|
if ($state eq 'pre' or $state eq 'obspre') { |
1726 |
|
$parent->{text}->[-1]->manakai_append_text (substr ($v, 1)); |
1727 |
|
} else { |
1728 |
|
my $tbody_el; |
1729 |
|
if (defined $parent->{tr}) { |
1730 |
|
$tbody_el = $parent->{tr}; |
1731 |
|
} else { |
1732 |
|
my $tbl_el = $self->{doc}->create_element_ns |
1733 |
|
(<Q::xhtml2|>, 'h2:table'); |
1734 |
|
my $tbody_el = $self->{doc}->create_element_ns |
1735 |
|
(<Q::xhtml2|>, 'h2:tbody'); |
1736 |
|
$tbl_el->append_child ($tbody_el); |
1737 |
|
$parent->{block}->[-1]->append_child ($tbl_el); |
1738 |
|
$parent->{tr} = $tbody_el; |
1739 |
|
} |
1740 |
|
|
1741 |
|
my $tr_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:tr'); |
1742 |
|
$parent->{tr}->append_child ($tr_el); |
1743 |
|
my $src = substr ($v, 1, length ($v) - 2); |
1744 |
|
my $prev_cell; |
1745 |
|
C: while ($src =~ /\G,\s*/gc) { |
1746 |
|
$src =~ /\G([^,"][^,]*|"(?>[^"\\]*)(?>(?>[^"\\]+|\\.)*)"\s*)/gc; |
1747 |
|
my $cell = defined $1 ? $1 : ''; |
1748 |
|
if ($cell =~ s/^"//) { |
1749 |
|
$cell =~ s/"\s*$//g; |
1750 |
|
$cell =~ s/\\(.)/$1/gs; |
1751 |
|
} else { |
1752 |
|
$cell =~ s/\s+$//g; |
1753 |
|
if ($cell eq '==') { |
1754 |
|
if (ref $prev_cell) { |
1755 |
|
my $colspan = $prev_cell->get_attribute_ns (null, 'colspan'); |
1756 |
|
$colspan = defined $colspan ? $colspan + 1 : 1; |
1757 |
|
$prev_cell->set_attribute_ns (null, colspan => $colspan); |
1758 |
|
next C; |
1759 |
|
} |
1760 |
|
} |
1761 |
|
} |
1762 |
|
$prev_cell = $self->{doc}->create_element_ns |
1763 |
|
(<Q::xhtml2|>, 'h2:td'); |
1764 |
|
$tr_el->append_child ($prev_cell); |
1765 |
|
|
1766 |
|
my $original_pos = pos $self->{source}; |
1767 |
|
{ |
1768 |
|
local $self->{token} = []; |
1769 |
|
local $self->{char} = []; |
1770 |
|
local $self->{source} = $cell; |
1771 |
|
pos ($self->{source}) = 0; |
1772 |
|
local $self->{location} = {}; |
1773 |
|
local $self->{scanner} = $self->can ('_scan_Body'); |
1774 |
|
$self->_parse_Body ({ |
1775 |
|
block => [$prev_cell], |
1776 |
|
quote => [$prev_cell], |
1777 |
|
section => [null, $prev_cell], |
1778 |
|
text => [$prev_cell], |
1779 |
|
}); |
1780 |
|
} |
1781 |
|
pos ($self->{source}) = $original_pos; |
1782 |
|
} |
1783 |
|
$parent->{text} = []; |
1784 |
|
$state = 'section'; |
1785 |
|
} |
1786 |
|
} |
1787 |
|
} (formStart) { |
1788 |
|
my $form_el; |
1789 |
|
my $param; |
1790 |
|
my $ref; |
1791 |
|
lang:Perl ($v => $token.value) { |
1792 |
|
CORE::delete $parent->{tr}; |
1793 |
|
$form_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'form'); |
1794 |
|
$v =~ /#([a-z-]+)/; |
1795 |
|
$form_el->set_attribute_ns (null, ref => $ref = $1); |
1796 |
|
$param = ''; |
1797 |
|
} |
1798 |
|
|
1799 |
|
~* (text) { |
1800 |
|
lang:Perl ($v => $token.value) { |
1801 |
|
$param .= $v; |
1802 |
|
} |
1803 |
|
} (quotedPair) { |
1804 |
|
lang:Perl ($v => $token.value) { |
1805 |
|
$param .= $v; |
1806 |
|
} |
1807 |
|
} (lita) { |
1808 |
|
lang:Perl ($v => $token.value) { |
1809 |
|
$param .= "'"; |
1810 |
|
} |
1811 |
|
} |
1812 |
|
|
1813 |
|
~ (formEnd) { } |
1814 |
|
|
1815 |
|
lang:Perl { |
1816 |
|
if ($param =~ s/^\(([^()]*)\)//) { |
1817 |
|
$form_el->set_attribute_ns (null, id => $1); |
1818 |
|
} |
1819 |
|
if ($ref eq 'form' and |
1820 |
|
$param =~ m{\A |
1821 |
|
: ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' ## input |
1822 |
|
(?> : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' ## template |
1823 |
|
(?> : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' )? )? ## option |
1824 |
|
\z}x) { |
1825 |
|
my ($in, $te, $op) = ($1, defined $2 ? $2 : '', |
1826 |
|
defined $3 ? $3 : ''); |
1827 |
|
s/\\(.)/$1/g for $in, $te, $op; |
1828 |
|
$form_el->set_attribute_ns (null, input => $1); |
1829 |
|
$form_el->set_attribute_ns (null, template => defined $2 ? $2 : ''); |
1830 |
|
$form_el->set_attribute_ns (null, option => defined $3 ? $3 : ''); |
1831 |
|
} else { |
1832 |
|
$param =~ s/^://; |
1833 |
|
$form_el->set_attribute_ns (null, parameter => $param); |
1834 |
|
} |
1835 |
|
|
1836 |
|
if (defined $parent->{text}->[0]) { |
1837 |
|
$parent->{text}->[-1]->append_child ($form_el); |
1838 |
|
} else { |
1839 |
|
$parent->{block}->[-1]->append_child ($form_el); |
1840 |
|
} |
1841 |
|
} |
1842 |
|
} (magicVersionS) { |
1843 |
|
lang:Perl ($v => $token.value) { |
1844 |
|
CORE::delete $parent->{tr}; |
1845 |
|
__CODE{setTextParent}__; |
1846 |
|
$parent->{text}->[-1]->manakai_append_text (substr ($v, 1)); |
1847 |
|
} |
1848 |
|
?lexmode Body; |
1849 |
|
} (magicVersionI) { |
1850 |
|
lang:Perl ($v => $token.value) { |
1851 |
|
CORE::delete $parent->{tr}; |
1852 |
|
__CODE{setTextParent}__; |
1853 |
|
$parent->{text}->[-1]->manakai_append_text ($v); |
1854 |
|
} |
1855 |
|
?lexmode Body; |
1856 |
|
} (entityRef) { |
1857 |
|
lang:Perl ($v => $token.value) { |
1858 |
|
CORE::delete $parent->{tr}; |
1859 |
|
my $ref_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'replace'); |
1860 |
|
$ref_el->set_attribute_ns |
1861 |
|
(null, 'by', substr ($v, 4, length ($v) - 8)); |
1862 |
|
if (defined $parent->{text}->[0]) { |
1863 |
|
$parent->{text}->[-1]->append_child ($ref_el); |
1864 |
|
} else { |
1865 |
|
$parent->{block}->[-1]->append_child ($ref_el); |
1866 |
|
} |
1867 |
|
} |
1868 |
|
} (imageStart) { |
1869 |
|
lang:Perl { |
1870 |
|
my $img_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'image'); |
1871 |
|
|
1872 |
|
my $value = ''; |
1873 |
|
while (my $token = shift @{$self->{token}}) { |
1874 |
|
$value .= $token->{value} if defined $token->{value}; |
1875 |
|
} |
1876 |
|
$value =~ tr/\x0D//d; |
1877 |
|
$img_el->manakai_append_text ($value); |
1878 |
|
$value = ''; |
1879 |
|
|
1880 |
|
while ((my $char = $self->_shift_char) >= 0) { |
1881 |
|
if ($char == 0x000D) { |
1882 |
|
$img_el->manakai_append_text ($value); |
1883 |
|
$value = ''; |
1884 |
|
} else { |
1885 |
|
$value .= ord $char; |
1886 |
|
} |
1887 |
|
} |
1888 |
|
$img_el->manakai_append_text ($value); |
1889 |
|
|
1890 |
|
$self->{doc}->document_element->append_child ($img_el); |
1891 |
|
} |
1892 |
|
} (name) { |
1893 |
|
lang:Perl ($v => $token.value) { |
1894 |
|
CORE::delete $parent->{tr}; |
1895 |
|
__CODE{setTextParent}__; |
1896 |
|
$parent->{text}->[-1]->manakai_append_text ($v); |
1897 |
|
} |
1898 |
|
} (vi) { |
1899 |
|
lang:Perl ($v => $token.value) { |
1900 |
|
CORE::delete $parent->{tr}; |
1901 |
|
__CODE{setTextParent}__; |
1902 |
|
$parent->{text}->[-1]->manakai_append_text ('='); |
1903 |
|
} |
1904 |
|
} (lit) { |
1905 |
|
lang:Perl ($v => $token.value) { |
1906 |
|
CORE::delete $parent->{tr}; |
1907 |
|
__CODE{setTextParent}__; |
1908 |
|
$parent->{text}->[-1]->manakai_append_text ($v); |
1909 |
} |
} |
1910 |
} |
} |
1911 |
} // Document |
} // Body |
1912 |
|
|
1913 |
rule MagicParam { |
rule MagicParam { |
1914 |
~* (name) { |
~* (name) { |
1950 |
|
|
1951 |
rule _StartTag ($parent, $element_type, $class_names, $lang_tag) { |
rule _StartTag ($parent, $element_type, $class_names, $lang_tag) { |
1952 |
lang:Perl { |
lang:Perl { |
1953 |
unless (defined $parent->{text}) { |
__CODE{setTextParent}__; |
|
$parent->{text} = $parent->{block} |
|
|
->append_child |
|
|
($self->{doc}->create_element_ns |
|
|
(<Q::xhtml2|>, 'h2:p')); |
|
|
} |
|
1954 |
my @class_names = split /\s+/, $class_names; |
my @class_names = split /\s+/, $class_names; |
1955 |
my $et = { |
my $et = { |
1956 |
ABBR => [<Q::xhtml2|>, 'abbr'], |
ABBR => [<Q::xhtml2|>, 'abbr'], |
1979 |
$et = [<Q::xhtml2|>, 'code']; |
$et = [<Q::xhtml2|>, 'code']; |
1980 |
push @class_names, $element_type; |
push @class_names, $element_type; |
1981 |
} |
} |
1982 |
$parent->{text} |
my $el = $self->{doc}->create_element_ns ($et->[0], $et->[1]); |
1983 |
= $parent->{text}->append_child |
$parent->{text}->[-1]->append_child ($el); |
1984 |
($self->{doc}->create_element_ns |
$el->set_attribute_ns (null, 'class' => join ' ', @class_names) |
|
($et->[0], $et->[1])); |
|
|
$parent->{text} |
|
|
->set_attribute_ns (null, 'class' => join ' ', @class_names) |
|
1985 |
if @class_names; |
if @class_names; |
1986 |
$parent->{text} |
$el->set_attribute_ns (<Q::xml|>, 'xml:lang', $lang_tag) |
|
->set_attribute_ns (<Q::xml|>, 'xml:lang', $lang_tag) |
|
1987 |
if defined $lang_tag; |
if defined $lang_tag; |
1988 |
|
|
1989 |
|
if ($element_type eq 'RUBY' or $element_type eq 'RUBYB' or |
1990 |
|
$element_type eq 'RUBYB') { |
1991 |
|
$el = $el->append_child ($self->{doc}->create_element_ns |
1992 |
|
(<Q::xhtml2|>, 'rb')); |
1993 |
|
} elsif ($element_type eq 'QN') { |
1994 |
|
$el = $el->append_child ($self->{doc}->create_element_ns |
1995 |
|
(<Q::sw010|>, 'qname')); |
1996 |
|
} |
1997 |
|
|
1998 |
|
push @{$parent->{text}}, $el; |
1999 |
} |
} |
2000 |
} // _StartTag |
} // _StartTag |
2001 |
|
|
2002 |
@Code: |
token-error default : default { |
2003 |
@@QName: inlineContainerElementTypes |
// |
2004 |
|
} |
2005 |
|
|
2006 |
|
@CODE: |
2007 |
|
@@QName: setTextParent |
2008 |
@@PerlDef: |
@@PerlDef: |
2009 |
{ |
unless (defined $parent->{text}->[0]) { |
2010 |
abbr => true, code => true, del => true, dfn => true, |
$parent->{text} = [$parent->{block}->[-1] |
2011 |
ins => true, kbd => true, q => true, samp => true, |
->append_child |
2012 |
sub => true, sup => true, var => true, weak => true, |
($self->{doc}->create_element_ns |
2013 |
aa => true, cite => true, csection => true, key => true, |
(<Q::xhtml2|>, 'h2:p'))]; |
|
span => true, src => true, anchor => true, nsuri => true, |
|
|
qname => true, rb => true, rt => true, |
|
|
|
|
|
p => true, pre => true, h => true, li => true, |
|
|
dt => true, dd => true, ed => true, comment-p => true, |
|
|
td => true, em => true, strong => true, |
|
2014 |
} |
} |
2015 |
|
|
2016 |
# document head body section bodytext insert delete |
@CODE: |
2017 |
# ul ol dl dr table tbody tr form replace ruby rubyb qn |
@@QName: endTag |
2018 |
# anchor-external anchor-internal anchor-end text blockquote |
@@PerlDef: |
2019 |
|
if (defined $parent->{text}->[1]) { |
2020 |
|
if (defined $iref) { |
2021 |
|
$parent->{text}->[-1]->set_attribute_ns |
2022 |
|
(<Q::sw09|>, 'sw9:anchor', 0+$iref); |
2023 |
|
} |
2024 |
|
if (defined $xref) { |
2025 |
|
if ($xref =~ s/^([A-Z]+)://) { |
2026 |
|
$parent->{text}->[-1]->set_attribute_ns |
2027 |
|
(<Q::sw09|>, 'sw9:resScheme', $1); |
2028 |
|
$parent->{text}->[-1]->set_attribute_ns |
2029 |
|
(<Q::sw09|>, 'sw9:resParameter', $xref); |
2030 |
|
} else { |
2031 |
|
$parent->{text}->[-1]->set_attribute_ns |
2032 |
|
(<Q::sw09|>, 'sw9:resScheme', 'URI'); |
2033 |
|
$parent->{text}->[-1]->set_attribute_ns |
2034 |
|
(<Q::sw09|>, 'sw9:resParameter', $xref); |
2035 |
|
} |
2036 |
|
} |
2037 |
|
$#{$parent->{text}}--; |
2038 |
|
} else { |
2039 |
|
__CODE{setTextParent}__; |
2040 |
|
$parent->{text}->[-1]->manakai_append_text ($tagString); |
2041 |
|
} |
2042 |
|
|