/[suikacvs]/messaging/manakai/lib/Message/Markup/SuikaWiki.dis
Suika

Contents of /messaging/manakai/lib/Message/Markup/SuikaWiki.dis

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Sat Dec 30 04:42:55 2006 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +4 -14 lines
++ manakai/lib/Message/Markup/ChangeLog	30 Dec 2006 04:39:04 -0000
2006-12-30  Wakaba  <wakaba@suika.fam.cx>

	* Atom.dis, SuikaWiki.dis: References
	to the |ManakaiDOM:ManakaiDOM| mode are removed.

++ manakai/lib/Message/Util/ChangeLog	30 Dec 2006 04:39:32 -0000
	* DIS.dis, PerlCode.dis: References to the |ManakaiDOM:ManakaiDOM|
	mode are removed.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/Util/DIS/ChangeLog	30 Dec 2006 04:42:43 -0000
	* DPG.dis, Perl.dis, Value.dis, Test.dis: References
	to |ManakaiDOM:ManakaiDOM| modes are removed.

	* Perl.dis (plCodeFragment): |local|ize
	the |DIS:plCodeFragment| cache to avoid
	ancestor nodes of the cached fragment
	are destroyed so that the cached nodes
	become invalid.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/DOM/ChangeLog	30 Dec 2006 04:37:29 -0000
	* CharacterData.dis, DOMCore.dis, DOMFeature.dis,
	GenericLS.dis, TreeCore.dis, DOMString.dis,
	XML.dis, Element.dis, Document.dis, TreeStore,dis,
	Traversal.dis, XDoctype.dis, XMLParser.dis, DOMLS.dis,
	SimpleLS.dis, DOMMain.dis: References
	to the |ManakaiDOM:ManakaiDOM|, |ManakaiDOM:ManakaiDOM1|,
	|ManakaiDOM:ManakaiDOM2|, and |ManakaiDOM:ManakaiDOM3|
	modes are removed.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/URI/ChangeLog	30 Dec 2006 04:35:39 -0000
2006-12-30  Wakaba  <wakaba@suika.fam.cx>

	* Generic.dis (Require): Reference to the |ManakaiDOM:ManakaiDOM|
	mode is removed.

++ manakai/lib/Message/Charset/ChangeLog	30 Dec 2006 04:35:23 -0000
2006-12-30  Wakaba  <wakaba@suika.fam.cx>

	* Encode.dis (Require): Reference to the |ManakaiDOM:ManakaiDOM|
	mode is removed.

1 wakaba 1.1 Module:
2     @QName: Markup|SuikaWiki
3     @enFN:
4     SuikaWiki/0.9 and SuikaWiki/0.10 Document Markup Language DOM
5     @enDesc:
6     {TODO::
7    
8     }
9    
10 wakaba 1.2 <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 wakaba 1.1 @Namespace:
52     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup/SuikaWiki/
53    
54     @DISCore:author: DISCore|Wakaba
55     @License: license|Perl+MPL
56     @Date:
57 wakaba 1.6 $Date: 2006/12/02 12:46:25 $
58 wakaba 1.1
59     @Require:
60     @@Module:
61     @@@QName: Markup|common
62     @@Module:
63     @@@QName: MDOM|TreeCore
64     @@@WithFor: ManakaiDOM|ManakaiDOMLatest
65     @@Module:
66     @@@QName: Markup|Atom
67     @@@WithFor: ManakaiDOM|ManakaiDOMLatest
68     @DefaultFor: ManakaiDOM|ManakaiDOMLatest
69    
70     Namespace:
71     @aa:
72     http://pc5.2ch.net/test/read.cgi/hp/1096723178/aavocab#
73     @c:
74     http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#
75     @cfg:
76     http://suika.fam.cx/www/2006/dom-config/
77     @dis:
78     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--
79     @doc:
80     http://suika.fam.cx/~wakaba/archive/2005/7/tutorial#
81     @d:
82     http://suika.fam.cx/~wakaba/archive/2004/dom/xdt#
83     @DOMMain:
84     http://suika.fam.cx/~wakaba/archive/2004/dom/main#
85     @dx:
86     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#
87     @ecore:
88     http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/Core/
89     @f:
90     http://suika.fam.cx/~wakaba/archive/2004/dom/feature#
91     @fe:
92     http://suika.fam.cx/www/2006/feature/
93     @gls:
94     http://suika.fam.cx/~wakaba/archive/2004/dom/gls#
95     @html:
96     http://www.w3.org/1999/xhtml
97     @idl:
98     http://suika.fam.cx/~wakaba/archive/2004/dis/IDL#
99     @kwd:
100     http://suika.fam.cx/~wakaba/archive/2005/rfc2119/
101     @lang:
102     http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#
103     @license:
104     http://suika.fam.cx/~wakaba/archive/2004/8/18/license#
105     @ManakaiDOM:
106     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#
107     @mat:
108     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup/Atom/
109     @Markup:
110     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#
111     @mat:
112     http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup/Atom/
113     @MDOM:
114     http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.
115     @MDOMX:
116     http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#
117     @dlp:
118     http://suika.fam.cx/~wakaba/archive/2004/dis/Perl#
119     @html3:
120     urn:x-suika-fam-cx:markup:ietf:html:3:draft:00:
121     @html5:
122     http://www.w3.org/1999/xhtml
123     @rel:
124     http://www.iana.org/assignments/relation/
125     @s:
126     http://suika.fam.cx/~wakaba/archive/2004/dis/Markup#
127     @sw09:
128     urn:x-suika-fam-cx:markup:suikawiki:0:9:
129     @sw010:
130     urn:x-suika-fam-cx:markup:suikawiki:0:10:
131     @tc:
132     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/
133     @td:
134     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/Document/
135     @te:
136     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/Element/
137     @test:
138     http://suika.fam.cx/~wakaba/archive/2004/dis/Test#
139     @tx:
140     http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/XML/
141     @urigen:
142     http://suika.fam.cx/~wakaba/archive/2005/manakai/URI/Generic/
143     @xhtml2:
144     http://www.w3.org/2002/06/xhtml2/
145     @xml:
146     http://www.w3.org/XML/1998/namespace
147     @xmlns:
148     http://www.w3.org/2000/xmlns/
149    
150     ElementTypeBinding:
151     @Name: CODE
152     @ElementType:
153     dis:ResourceDef
154     @ShadowContent:
155     @@DISCore:resourceType: dlp|BlockCode
156     @@ForCheck: ManakaiDOM|ForClass
157    
158     ElementTypeBinding:
159     @Name: Method
160     @ElementType:
161     dis:ResourceDef
162     @ShadowContent:
163     @@DISCore:resourceType: DISLang|Method
164     @@ForCheck: !=ManakaiDOM|ManakaiDOM
165    
166     ElementTypeBinding:
167     @Name: Param
168     @ElementType:
169     dis:ResourceDef
170     @ShadowContent:
171     @@DISCore:resourceType: DISLang|MethodParameter
172    
173     ElementTypeBinding:
174     @Name: Return
175     @ElementType:
176     dis:ResourceDef
177     @ShadowContent:
178     @@DISCore:resourceType: DISLang|MethodReturn
179    
180     ElementTypeBinding:
181     @Name: Attr
182     @ElementType:
183     dis:ResourceDef
184     @ShadowContent:
185     @@DISCore:resourceType: DISLang|Attribute
186     @@ForCheck: !=ManakaiDOM|ManakaiDOM
187    
188     ElementTypeBinding:
189     @Name: Get
190     @ElementType:
191     dis:ResourceDef
192     @ShadowContent:
193     @@DISCore:resourceType: DISLang|AttributeGet
194    
195     ElementTypeBinding:
196     @Name: Set
197     @ElementType:
198     dis:ResourceDef
199     @ShadowContent:
200     @@DISCore:resourceType: DISLang|AttributeSet
201    
202     ElementTypeBinding:
203     @Name: nullCase
204     @ElementType:
205     dis:ResourceDef
206     @ShadowContent:
207     @@DISCore:resourceType: ManakaiDOM|InCase
208     @@Value:
209     @@@is-null:1
210    
211     ElementTypeBinding:
212     @Name: PerlDef
213     @ElementType:
214     dis:Def
215     @ShadowContent:
216     @@ContentType: lang|Perl
217     @@ForCheck: ManakaiDOM|ForClass
218    
219     ElementTypeBinding:
220     @Name: PerlCDef
221     @ElementType:
222     dis:Def
223     @ShadowContent:
224     @@ContentType: lang|Perl
225    
226     ElementTypeBinding:
227     @Name: enImplNote
228     @ElementType:
229     dis:ImplNote
230     @ShadowContent:
231     @@lang:en
232    
233     ElementTypeBinding:
234     @Name: enFN
235     @ElementType:
236     dis:FullName
237     @ShadowContent:
238     @@lang:en
239    
240     ElementTypeBinding:
241 wakaba 1.3 @Name: PTests
242     @ElementType:
243     dis:ResourceDef
244     @ShadowContent:
245     @@ForCheck: ManakaiDOM|ForClass
246     @@DISCore:resourceType: test|ParserTestSet
247    
248     ElementTypeBinding:
249     @Name: PTest
250     @ElementType:
251     dis:ResourceDef
252     @ShadowContent:
253     @@ForCheck: ManakaiDOM|ForClass
254     @@DISCore:resourceType: test|ParserTest
255    
256     ElementTypeBinding:
257     @Name: DEnt
258     @ElementType:
259     dis:ResourceDef
260     @ShadowContent:
261     @@DISCore:resourceType: test|RootEntity
262    
263     ElementTypeBinding:
264 wakaba 1.1 @Name: IFClsETDef
265     @ElementType:
266     dis:ResourceDef
267     @ShadowContent:
268     @@DISCore:resourceType:
269     @@@@: dis|MultipleResource
270     @@@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass !s|ForML
271     @@resourceFor: ManakaiDOM|ForIF
272     @@resourceFor: ManakaiDOM|ForClass
273     @@resourceFor: s|ForML
274     @@For: ManakaiDOM|ManakaiDOM
275    
276     @@DISCore:resourceType:
277     @@@@: DISLang|Interface
278     @@@ForCheck: ManakaiDOM|ForIF
279    
280     @@DISCore:resourceType:
281     @@@@: DISLang|Class
282     @@@ForCheck: ManakaiDOM|ForClass
283 wakaba 1.6
284 wakaba 1.1 @@Implement:
285     @@@@: ||ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForIF
286     @@@ContentType: DISCore|TFPQNames
287     @@@ForCheck: ManakaiDOM|ForClass ManakaiDOM|ManakaiDOMLatest
288    
289     @@s:elementType:
290     @@@@: ||+||s|ForML
291     @@@ContentType: DISCore|TFPQNames
292     @@@DISCore:stopISARecursive:1
293    
294     @@DISCore:resourceType:
295     @@@@: s|ElementType
296     @@@ForCheck: s|ForML
297    
298     @@f:implements: AtomFeature10
299    
300     ElementTypeBinding:
301     @Name: IFClsDef
302     @ElementType:
303     dis:ResourceDef
304     @ShadowContent:
305     @@DISCore:resourceType:
306     @@@@: dis|MultipleResource
307     @@@ForCheck: !ManakaiDOM|ForIF !ManakaiDOM|ForClass !s|ForML
308     @@resourceFor: ManakaiDOM|ForIF
309     @@resourceFor: ManakaiDOM|ForClass
310     @@For: ManakaiDOM|ManakaiDOM
311    
312     @@DISCore:resourceType:
313     @@@@: DISLang|Interface
314     @@@ForCheck: ManakaiDOM|ForIF
315    
316     @@DISCore:resourceType:
317     @@@@: DISLang|Class
318     @@@ForCheck: ManakaiDOM|ForClass
319 wakaba 1.6
320 wakaba 1.1 @@Implement:
321     @@@@: ||ManakaiDOM|ManakaiDOMLatest||ManakaiDOM|ForIF
322     @@@ContentType: DISCore|TFPQNames
323     @@@ForCheck: ManakaiDOM|ForClass ManakaiDOM|ManakaiDOMLatest
324    
325     @@f:implements: AtomFeature10
326    
327     ElementTypeBinding:
328     @Name: IFQName
329     @ElementType:
330     dis:QName
331     @ShadowContent:
332     @@ForCheck: ManakaiDOM|ForIF
333    
334     ElementTypeBinding:
335     @Name: ClsQName
336     @ElementType:
337     dis:QName
338     @ShadowContent:
339     @@ForCheck: ManakaiDOM|ForClass
340    
341     ElementTypeBinding:
342     @Name: ETRQName
343     @ElementType:
344     dis:QName
345     @ShadowContent:
346     @@ForCheck: s|ForML
347    
348     ElementTypeBinding:
349     @Name: ETQName
350     @ElementType:
351     dis:AppName
352     @ShadowContent:
353     @@ForCheck: s|ForML
354     @@ContentType: DISCore|QName
355    
356     ElementTypeBinding:
357     @Name: IFISA
358     @ElementType:
359     dis:ISA
360     @ShadowContent:
361     @@ForCheck: ManakaiDOM|ForIF
362    
363     ElementTypeBinding:
364     @Name: ClsISA
365     @ElementType:
366     dis:ISA
367     @ShadowContent:
368     @@ForCheck: ManakaiDOM|ForClass
369    
370     ElementTypeBinding:
371     @Name: disDef
372     @ElementType:
373     dis:Def
374     @ShadowContent:
375     @@ContentType:
376     lang:dis
377     @@ForCheck: ManakaiDOM|ForClass
378    
379     ElementTypeBinding:
380     @Name: Code
381     @ElementType:
382     dis:ResourceDef
383     @ShadowContent:
384     @@DISCore:resourceType: dlp|InlineCode
385     @@ForCheck: ManakaiDOM|ForClass
386    
387     ElementTypeBinding:
388     @Name: Test
389     @ElementType:
390     dis:ResourceDef
391     @ShadowContent:
392     @@DISCore:resourceType: test|StandaloneTest
393     @@ForCheck: ManakaiDOM|ForClass
394    
395     ElementTypeBinding:
396     @Name: TestC
397     @ElementType:
398     dis:ResourceDef
399     @ShadowContent:
400     @@DISCore:resourceType: test|StandaloneTest
401    
402     ResourceDef:
403     @QName: Document
404     @AliasFor: td|Document
405     @For: ManakaiDOM|DOM
406    
407     ResourceDef:
408     @QName: Element
409     @AliasFor: te|Element
410     @For: ManakaiDOM|DOM
411    
412     ResourceDef:
413     @QName: Attr
414     @AliasFor: te|Attr
415     @For: ManakaiDOM|DOM
416    
417     ResourceDef:
418     @QName: DOMString
419     @AliasFor: DOMMain|DOMString
420     @For: ManakaiDOM|DOM
421    
422     ResourceDef:
423     @QName: DOMURI
424     @AliasFor: ManakaiDOM|ManakaiDOMURI
425     @For: ManakaiDOM|DOM3
426    
427     ResourceDef:
428     @QName: DOMTimeStamp
429     @AliasFor: DOMMain|DOMTimeStamp
430     @For: ManakaiDOM|DOM2
431    
432     ResourceDef:
433     @QName: boolean
434     @AliasFor: idl|boolean||ManakaiDOM|all
435    
436     ResourceDef:
437     @QName: Node
438     @AliasFor: tc|Node
439     @For: ManakaiDOM|ManakaiDOM
440    
441     ResourceDef:
442     @QName: NodeList
443     @AliasFor: tc|NodeList
444     @For: ManakaiDOM|ManakaiDOM
445    
446     ResourceDef:
447     @QName: StaticNodeList
448     @AliasFor: tc|StaticNodeList
449     @For: ManakaiDOM|ManakaiDOM
450    
451     ElementTypeBinding:
452     @Name: enDesc
453     @ElementType:
454     dis:Description
455     @ShadowContent:
456     @@lang:en
457    
458     ElementTypeBinding:
459     @Name: TrueCase
460     @ElementType:
461     dis:ResourceDef
462     @ShadowContent:
463     @@DISCore:resourceType:
464     ManakaiDOM:InCase
465     @@Value:
466     @@@@: 1
467     @@@ContentType: DISCore|Boolean
468     @@Type: idl|boolean||ManakaiDOM|all
469    
470     ElementTypeBinding:
471     @Name: FalseCase
472     @ElementType:
473     dis:ResourceDef
474     @ShadowContent:
475     @@DISCore:resourceType:
476     ManakaiDOM:InCase
477     @@Value:
478     @@@@: 0
479     @@@ContentType: DISCore|Boolean
480     @@Type: idl|boolean||ManakaiDOM|all
481    
482     ## -- Features
483    
484     ElementTypeBinding:
485     @Name: FeatureDef
486     @ElementType:
487     dis:ResourceDef
488     @ShadowContent:
489     @@DISCore:resourceType: f|Feature
490     @@For: =ManakaiDOM|all
491    
492     ElementTypeBinding:
493     @Name: FeatureVerDef
494     @ElementType:
495     dis:ResourceDef
496     @ShadowContent:
497     @@DISCore:resourceType: f|Feature
498    
499     ElementTypeBinding:
500     @Name: featureQName
501     @ElementType:
502     f:name
503     @ShadowContent:
504     @@ContentType: DISCore|QName
505    
506     FeatureDef:
507     @featureQName: fe|SuikaWikiDML
508     @QName: SWDMLFeature
509     @FeatureVerDef:
510     @@QName: SWDMLFeature010
511     @@Version: 0.10
512     @@f:instanceOf: SWDMLFeature
513     @@f:requires: tx|XMLFeature30
514     @@enDesc:
515     The SuikaWiki Document Markup Language DOM, version 0.10.
516    
517     ## -- Implementation
518    
519     ## TODO:
520    
521     ## -- Elements
522    
523     IFClsDef:
524     @IFQName: SWDMLElement
525     @ClsQName: ManakaiSWDMLElement
526    
527     @IFISA: Element
528     @ClsISA: te|ManakaiDOMElement
529    
530     @s:elementType: AnySW09Element||ManakaiDOM|all
531     @s:elementType: AnySW010Element||ManakaiDOM|all
532     ##SWDMLElement
533    
534     ResourceDef:
535     @QName: AnySW09Element
536     @DISCore:resourceType: s|AnyElementInNS
537     @AppName:
538     @@@: sw09|*
539     @@ContentType: DISCore|QName
540     @ForCheck: =ManakaiDOM|all
541    
542     ResourceDef:
543     @QName: AnySW010Element
544     @DISCore:resourceType: s|AnyElementInNS
545     @AppName:
546     @@@: sw010|*
547     @@ContentType: DISCore|QName
548     @ForCheck: =ManakaiDOM|all
549    
550     IFClsETDef:
551     @IFQName: SWDMLDocumentElement
552     @ETQName: sw09|document
553     @ClsQName: ManakaiSWDMLDocumentElement
554    
555     @IFISA: SWDMLElement
556     @ClsISA: ManakaiSWDMLElement
557    
558     @Attr:
559     @@Name: headElement
560     @@enDesc:
561     The <XE::xhtml2|head> child element of the node.
562     @@Type: SWDMLElement
563     @@Get:
564     @@@enDesc:
565     It <kwd:MUST> <I::return a <XE::xhtml2|head> child element>
566     of the node.
567     @@@nullCase:
568     @@@@enDesc:
569     If the algorithm returns <DOM::null>.
570     @@@NodeReadOnlyError:
571     @@@PerlDef:
572     __CODE{mat|returnChildElement::
573     $node => $self,
574     $namespaceURI => {<Q::xhtml2|>},
575     $localName => 'head',
576     $r => $r,
577     }__;
578    
579     @Attr:
580     @@Name: bodyElement
581     @@enDesc:
582     The <XE::xhtml2|body> child element of the node.
583     @@Type: SWDMLElement
584     @@Get:
585     @@@enDesc:
586     It <kwd:MUST> <I::return a <XE::xhtml2|body> child element>
587     of the node.
588     @@@nullCase:
589     @@@@enDesc:
590     If the algorithm returns <DOM::null>.
591     @@@NodeReadOnlyError:
592     @@@PerlDef:
593     __CODE{mat|returnChildElement::
594     $node => $self,
595     $namespaceURI => {<Q::xhtml2|>},
596     $localName => 'body',
597     $r => $r,
598     }__;
599    
600     @Attr:
601     @@Name: markupLanguageName
602     @@enDesc:
603     The markup language name.
604    
605     It <kwd:MUST> <I::reflect the string value
606     of the <XA::sw09|Name> attribute> of the node. It default
607     value <kwd:MUST> be <CODE::SuikaWiki>.
608     @@Type: DOMString
609     @@Get:
610     @@@nullCase:
611     @@@@enDesc:
612     If the algorithm returns <DOM::null>.
613     @@@PerlDef:
614     __CODE{mat|getReflectAttrStringValue::
615     $node => $self,
616     $namespaceURI => {<Q::sw09|>},
617     $localName => 'Name',
618     $r => $r,
619     $defaultValue => 'SuikaWiki',
620     }__;
621     @@Set:
622     @@@nullCase:
623     @@@@enDesc:
624     Removes the attribute.
625     @@@NodeReadOnlyError:
626     @@@PerlDef:
627     __CODE{mat|setReflectAttrStringValue::
628     $node => $self,
629     $namespaceURI => {<Q::sw09|>},
630     $localName => 'Name',
631     $given => $given,
632     }__;
633    
634     @Attr:
635     @@Name: markupLanguageVersion
636     @@enDesc:
637     The markup language version.
638    
639     It <kwd:MUST> <I::reflect the string value
640     of the <XA::sw09|Version> attribute> of the node. It default
641     value <kwd:MUST> be <CODE::0.9>.
642     @@Type: DOMString
643     @@Get:
644     @@@nullCase:
645     @@@@enDesc:
646     If the algorithm returns <DOM::null>.
647     @@@PerlDef:
648     __CODE{mat|getReflectAttrStringValue::
649     $node => $self,
650     $namespaceURI => {<Q::sw09|>},
651     $localName => 'Version',
652     $r => $r,
653     $defaultValue => '0.9',
654     }__;
655     @@Set:
656     @@@nullCase:
657     @@@@enDesc:
658     Removes the attribute.
659     @@@NodeReadOnlyError:
660     @@@PerlDef:
661     __CODE{mat|setReflectAttrStringValue::
662     $node => $self,
663     $namespaceURI => {<Q::sw09|>},
664     $localName => 'Version',
665     $given => $given,
666     }__;
667     ##SWDMLDocumentElement
668    
669     ElementTypeBinding:
670     @Name: NodeReadOnlyError
671     @ElementType:
672     dx:raises
673     @ShadowContent:
674     @@@: MDOMX|NOMOD_THIS
675     @@Description:
676     @@@lang:en
677     @@@@:
678     If the node or a descendant of it, which
679     is to be modified, is read-only.
680    
681     ## -- Parser
682    
683     IFClsDef:
684     @IFQName: SWDMLParser
685     @ClsQName: ManakaiSWDMLParser
686    
687     @Implement: ecore|MUErrorTarget||ManakaiDOM|Perl
688    
689     @DISLang:role: gls|ParserRole
690    
691     @f:implements: SWDMLFeature010
692     @f:provides:
693     @@@: SWDMLFeature010
694     @@f:through: c|ManakaiDOMImplementation
695    
696     @enDesc:
697     A <IF::SWDMLParser> object parses a SuikaWiki/0.9,
698     SuikaWikiImage/0.9, or SuikaWiki/0.10 textual document and
699     returns it as an object.
700    
701     @Attr:
702     @@Name: domConfig
703     @@enDesc:
704     The configuration of the parser.
705    
706     @@Get:
707     @@@Type: c|DOMConfiguration
708     @@@enDesc: The DOM configuration object.
709     @@@PerlDef:
710     __CODE{c|getConfigObject::
711     $target => $self,
712     $targetHash => $self,
713     $targetType => {<IFName::SWDMLParser>},
714     $result => $r,
715     }__;
716    
717     @Method:
718     @@ManakaiDOM:isForInternal:1
719     @@ForCheck: ManakaiDOM|ForClass
720     @@Operator: DISPerl|NewMethod
721     @@enDesc:
722     Creates a new instance of the object.
723     @@Param:
724     @@@Name: impl
725     @@@Type: gls|GLSImplementation
726     @@@enDesc:
727     The implementation from which the parser is created.
728     @@Param:
729     @@@Name: features
730     @@@Type: DOMString
731     @@@dis:actualType: f|FeaturesString
732     @@@enDesc:
733     The set of features requested for the parser.
734     @@Return:
735     @@@Type: DOMMain|DOMObject
736     @@@enDesc:
737     The newly created parser.
738     @@@PerlDef:
739     $r = bless {
740 wakaba 1.4 <H::f|implementation> => $impl->get_feature ('XML' => '3.0'),
741 wakaba 1.1 }, $self;
742    
743     @Method:
744     @@Name: parseString
745     @@enDesc:
746     Parses a string as SWDML textual document and converts it into
747     DOM tree.
748     @@Param:
749     @@@Name: sourceText
750     @@@Type: DOMString
751     @@@enDesc:
752     The text to parse.
753     @@Return:
754     @@@Type: DISPerl|HASH
755     @@@enDesc:
756     An object representation of <P::sourceText>.
757     @@@PerlDef:
758     $self->{scanner} = $self->can ('_scan_Body');
759     $self->{char} = [0x000A];
760     $self->{token} = [];
761     $self->{source} = $sourceText;
762 wakaba 1.2 pos ($self->{source}) = 0;
763 wakaba 1.1 $self->{location} = {};
764     $self->{doc} = $self->{<H::f|implementation>}
765     ->create_document (<Q::sw09|>, 'document');
766     $self->{doc}->strict_error_checking (false);
767     $self->{docel} = $self->{doc}->document_element;
768     $self->{docel}->set_attribute_ns (<Q::xmlns|>, 'xmlns', <Q::sw09|>);
769     $self->{docel}->set_attribute_ns (<Q::xmlns|>, 'xmlns:h2', <Q::xhtml2|>);
770 wakaba 1.3 $self->{docel}->markup_language_name ('SuikaWiki');
771 wakaba 1.1 $self->{docel}->markup_language_version ('0.10');
772     $self->{docel}->append_child
773     ($self->{doc}->create_element_ns
774     (<Q::xhtml2|>, 'h2:head'));
775     $self->{docel}->append_child
776     ($self->{doc}->create_element_ns
777     (<Q::xhtml2|>, 'h2:body'));
778     __DEEP{
779     $self->_parse_Document;
780     }__;
781    
782     $r = $self->{doc};
783    
784     @Method:
785     @@Name: shiftChar
786     @@ManakaiDOM:isForInternal:1
787     @@ForCheck: ManakaiDOM|ForClass
788     @@enDesc:
789     Returns the next character.
790     @@Return:
791     @@@Type: idl|long||ManakaiDOM|all
792     @@@enDesc:
793     The code position number of the next character, if any,
794     or <CODE::-2>.
795     @@@PerlDef:
796     if (@{$self->{char}}) {
797     $r = shift @{$self->{char}};
798     } else {
799     my $char = substr ($self->{source}, pos ($self->{source}), 1);
800     pos ($self->{source})++;
801    
802     if (length $char) {
803     $r = ord $char;
804     if ($r == 0x000D) {
805     my $char2 = substr ($self->{source}, pos ($self->{source}), 1);
806     if (length $char2) {
807     if (ord $char2 == 0x000A) {
808     pos ($self->{source})++;
809     }
810     push @{$self->{char}}, 0x000A;
811     }
812     } elsif ($r == 0x000A) {
813     $r = 0x000D;
814     push @{$self->{char}}, 0x000A;
815     }
816     } else { ## ISSUE: The last |RE|
817     $r = -1;
818     }
819     }
820    
821     @Method:
822     @@ManakaiDOM:isForInternal: 1
823     @@Operator: ManakaiDOM|MUErrorHandler
824     @@enDesc:
825     When a <IF::ecore|ErrorInterface||ManakaiDOM|Perl> is <Perl::report>ed,
826     then this method is invoked.
827    
828     The method calls the <cfg::DOMCore|error-handler> if the error is of
829     <IF::DOMCore|DOMError>. Otherwise, the error is re-thrown so that
830     corresponding <Perl::catch> clause, if any, can catch the error.
831     @@Param:
832     @@@Name: err
833     @@@Type: ecore|ErrorInterface||ManakaiDOM|Perl
834     @@@enDesc:
835     The reported error object.
836     @@Return:
837     @@@Type: DISPerl|Any
838     @@@enDesc:
839     If the <P::err> is a <IF::DOMCore|DOMError>, then the return value
840     of the error handler.
841    
842     {NOTE:: If the error is thrown, the method never returns.
843     }
844     @@@nullCase:
845     @@@@enDesc:
846     No error handler.
847     @@@PerlDef:
848 wakaba 1.6 if ($err->isa (<IFName::DOMCore|DOMError>)) {
849 wakaba 1.1 __DEEP{
850     A: {
851     my $cfg = $self-><AG::SWDMLParser.domConfig>;
852     my $h = $cfg-><M::DOMCore|DOMConfiguration.getParameter>
853     ('error-handler');
854     $r = $h-><M::DOMCore|DOMErrorHandler.handleError> ($err);
855     } # A
856     }__;
857     } else {
858     $err-><M::ecore|ErrorInterface||ManakaiDOM|Perl.throw>;
859     }
860    
861     @DISPerl:dpgDef:
862    
863     lexmode WSP {
864     $wsp := [U+0009 U+0020];
865    
866     /*
867     U+000D and U+000A characters in source stream are
868     replaced to record separators by |shiftChar|.
869     */
870     $rs := [U+000A];
871     $re := [U+000D];
872     $nonRSRE := [^U+000D U+000A];
873     }
874    
875     lexmode Body
876     : extends => 'WSP'
877     : initial
878     : standalone
879     {
880     $digit := [U+0030..U+0039];
881     $ltagchar := [U+0041..U+005A U+0061..U+007A U+0030..U+0039 '-' '_'];
882     $classchar := [^'(' ')' U+005C U+000D U+000A];
883    
884     magicVersionS : value
885     := $rs ['#'] ['?'] ['S'] ['u'] ['i'] ['k'] ['a']
886     ['W'] ['i'] ['k'] ['i'] ['/'] ['0'] ['.'] ['9'] $wsp*
887     -> MagicParameter;
888     magicVersionI : value
889     := $rs ['#'] ['?'] ['S'] ['u'] ['i'] ['k'] ['a']
890     ['W'] ['i'] ['k'] ['i'] ['I'] ['m'] ['a'] ['g'] ['e']
891     ['/'] ['0'] ['.'] ['9'] $wsp*
892     -> MagicParameter;
893     otherRS : ignore := $rs;
894     headingStart : value := $rs ['*']+ $wsp*;
895     listStart : value := $rs ['-' '=']+ $wsp*;
896     dlistStart : value := $rs [':'] [^':' U+000D U+000A]* [':'] $wsp*;
897     quote : value := $rs ['>']+ $wsp*;
898     eol := $re;
899     anchorNumberDef : value := ['['] $digit+ [']'];
900     anchorNumberRef : value := ['>'] ['>'] $digit+;
901     externalRefStart := ['<'] -> ExternalRefBody;
902     startTag : value := ['['] [U+0041..U+005A]+ ['['];
903     startTagClass : value := ['['] [U+0041..U+005A]+
904     ['('] $classchar* [')'] ['['];
905     startTagClassLang : value := ['['] [U+0041..U+005A]+
906     ['('] $classchar* [')']
907     ['@'] $ltagchar* ['['];
908     startTagLang : value := ['['] [U+0041..U+005A]+ ['@'] $ltagchar* ['['];
909     termStartTag := ['['] ['['];
910     midTag : value := [']'] $wsp* ['['];
911 wakaba 1.2 midTagLang : value := [']'] $wsp* ['@'] $ltagchar* ['['];
912 wakaba 1.1 endTag := [']'] [']'];
913     endTagAnchorNumberRef : value := [']'] ['>'] ['>'] $digit+ [']'];
914     endTagExternalRefStart := [']'] ['<'] -> EndTagExternalRefBody;
915 wakaba 1.2 preStartTag : value := $rs ['['] ['P'] ['R'] ['E'] ['['] $wsp* $re;
916     preStartTagClass : value := $rs ['['] ['P'] ['R'] ['E']
917     ['('] $classchar* [')'] ['['] $wsp* $re;
918     insStartTag : value := $rs ['['] ['I'] ['N'] ['S'] ['['] $wsp* $re;
919     insStartTagClass : value := $rs ['['] ['I'] ['N'] ['S']
920     ['('] $classchar* [')'] ['['] $wsp* $re;
921     delStartTag : value := $rs ['['] ['D'] ['E'] ['L'] ['['] $wsp* $re;
922     delStartTagClass : value := $rs ['['] ['D'] ['E'] ['L']
923     ['('] $classchar* [')'] ['['] $wsp* $re;
924     preEndTag : value := $rs [']'] ['P'] ['R'] ['E'] [']'] $wsp* $re;
925     insEndTag : value := $rs [']'] ['I'] ['N'] ['S'] [']'] $wsp* $re;
926     delEndTag : value := $rs [']'] ['D'] ['E'] ['L'] [']'] $wsp* $re;
927 wakaba 1.1 formStart : value := ['['] ['['] ['#'] [U+0061..U+007A '-']+
928     -> FormBody;
929     emphasis2 := [U+0027] [U+0027];
930     emphasis3 := [U+0027] [U+0027] [U+0027];
931     entityRef : value := ['_'] ['_'] ['&'] ['&']
932     [^'&' U+000D U+000A]+
933     ['&'] ['&'] ['_'] ['_'];
934     obsPreStart : value := $rs $wsp;
935 wakaba 1.2 noteStart : value := $rs [';'] [';'] $wsp*;
936     edStart : value := $rs ['@'] ['@'] $wsp*;
937 wakaba 1.1 tableLine : value := $rs [','] $nonRSRE* $re;
938     imageStart : value := $rs ['_'] ['_'] ['I'] ['M'] ['A'] ['G'] ['E']
939     ['_'] ['_'] $re;
940     ?default-token text : value;
941     }
942    
943     lexmode MagicParameter
944     : extends => 'WSP'
945     : standalone
946     {
947     name : value := [U+0041..U+005A U+0061..U+007A U+0030..U+0039 '-']+;
948     vi := ['='];
949     lit := ['"'] -> MagicParameterValue;
950     s : ignore := $wsp+;
951     eol := $re -> Body;
952     }
953    
954     lexmode MagicParameterValue
955     : standalone
956 wakaba 1.2 : extends => WSP
957 wakaba 1.1 {
958 wakaba 1.2 quotedPair : value := [U+005C] $nonRSRE;
959 wakaba 1.1 ?default-token text : value;
960     lit := ['"'] -> MagicParameter;
961     }
962    
963     lexmode ExternalRefBody
964     : standalone
965     {
966     lit := ['"'] -> ExternalRefQuotedStringBody;
967     externalRefEnd := ['>'] -> Body;
968     ?default-token text : value;
969     }
970     lexmode EndTagExternalRefBody
971     : standalone
972     {
973     lit := ['"'] -> EndTagExternalRefQuotedStringBody;
974     endTagExternalRefEnd := ['>'] [']'] -> Body;
975     ?default-token text : value;
976     }
977    
978     lexmode ExternalRefQuotedStringBody
979     : standalone
980 wakaba 1.2 : extends => WSP
981 wakaba 1.1 {
982     lit := ['"'] -> ExternalRefBody;
983 wakaba 1.2 quotedPair : value := [U+005C] $nonRSRE;
984 wakaba 1.1 ?default-token text : value;
985     }
986     lexmode EndTagExternalRefQuotedStringBody
987     : standalone
988 wakaba 1.2 : extends => WSP
989 wakaba 1.1 {
990     lit := ['"'] -> EndTagExternalRefBody;
991 wakaba 1.2 quotedPair : value := [U+005C] $nonRSRE;
992 wakaba 1.1 ?default-token text : value;
993     }
994    
995     lexmode FormBody
996     : standalone
997     {
998     lita := [U+0027] -> FormQuotedStringBody;
999     formEnd := [']'] [']'] -> Body;
1000     ?default-token text : value;
1001     }
1002    
1003     lexmode FormQuotedStringBody
1004     : standalone
1005 wakaba 1.2 : extends => WSP
1006 wakaba 1.1 {
1007     lita := [U+0027] -> FormBody;
1008 wakaba 1.2 quotedPair : value := [U+005C] $nonRSRE;
1009 wakaba 1.1 ?default-token text : value;
1010     }
1011    
1012    
1013     rule Document
1014     : standalone
1015     {
1016     ~? (magicVersionS) {
1017     lang:Perl {
1018     $self->{docel}
1019     ->set_attribute_ns (<Q::sw09|>, 'sw9:Name' => 'SuikaWiki');
1020     $self->{docel}->set_attribute_ns (<Q::sw09|>, 'sw9:Version' => '0.9');
1021     }
1022     &MagicParam;
1023     } (magicVersionI) {
1024     lang:Perl {
1025     $self->{docel}
1026     ->set_attribute_ns (<Q::sw09|>, 'sw9:Name' => 'SuikaWikiImage');
1027     $self->{docel}->set_attribute_ns (<Q::sw09|>, 'sw9:Version' => '0.9');
1028     }
1029     &MagicParam;
1030     }
1031    
1032     my $parent;
1033 wakaba 1.2 lang:Perl {
1034     $parent->{block} = [$self->{doc}->document_element->body_element];
1035     $parent->{quote} = [$parent->{block}->[-1]];
1036     $parent->{section}->[1] = $parent->{block}->[-1];
1037     $parent->{edit} = [];
1038     }
1039    
1040     &Body ($parent => $parent);
1041     } // Document
1042    
1043     rule Body ($parent)
1044     : standalone
1045     {
1046     /* $parent
1047     block i For block-level elements.
1048 wakaba 1.1 section i For i-th-level sections. Null if no (i-1)-th
1049     level section.
1050     list i For i-th-level list items. Null if no i-th-level
1051     list.
1052 wakaba 1.2 text i For texts or inline-level elements
1053 wakaba 1.1 Null if no container for inlines.
1054 wakaba 1.2 quote i Contains i-th-level quotation's |bodytext| element.
1055     edit i Contains |parent| state restored when i-th-level
1056     editing element is closed.
1057     tr For |tr| elements.
1058 wakaba 1.1 */
1059     my $state;
1060     /*
1061     heading Next |eol| closes the heading.
1062 wakaba 1.2 pre In |pre| element.
1063 wakaba 1.1 section Otherwise.
1064     */
1065     lang:Perl {
1066     $state = 'section';
1067     }
1068    
1069     ~* (text) {
1070     lang:Perl ($v => $token.value) {
1071 wakaba 1.2 CORE::delete $parent->{tr};
1072     __CODE{setTextParent}__;
1073     $parent->{text}->[-1]->manakai_append_text ($v);
1074 wakaba 1.1 }
1075     } (startTag) {
1076     my $element_type;
1077     my $class_names;
1078     my $lang_tag;
1079     lang:Perl ($v => $token.value) {
1080     $v =~ /([A-Z]+)/;
1081     $element_type = $1;
1082     $class_names = '';
1083     }
1084    
1085     &_StartTag ($element_type => $element_type, $class_names => $class_names,
1086     $lang_tag => $lang_tag, $parent => $parent);
1087     } (startTagClass) {
1088     my $element_type;
1089     my $class_names;
1090     my $lang_tag;
1091     lang:Perl ($v => $token.value) {
1092     $v =~ /([A-Z]+)\(([^()]+)/;
1093     $element_type = $1;
1094     $class_names = $2;
1095     }
1096    
1097     &_StartTag ($element_type => $element_type, $class_names => $class_names,
1098     $lang_tag => $lang_tag, $parent => $parent);
1099     } (startTagClassLang) {
1100     my $element_type;
1101     my $class_names;
1102     my $lang_tag;
1103     lang:Perl ($v => $token.value) {
1104     $v =~ /([A-Z]+)\(([^()]+)\@([^\[\]]*)/;
1105     $element_type = $1;
1106     $class_names = $2;
1107     $lang_tag = $2;
1108     }
1109    
1110     &_StartTag ($element_type => $element_type, $class_names => $class_names,
1111     $lang_tag => $lang_tag, $parent => $parent);
1112     } (startTagLang) {
1113     my $element_type;
1114     my $class_names;
1115     my $lang_tag;
1116     lang:Perl ($v => $token.value) {
1117     $v =~ /([A-Z]+)\@([^\[\]]*)/;
1118     $element_type = $1;
1119     $class_names = '';
1120     $lang_tag = $2;
1121     }
1122    
1123     &_StartTag ($element_type => $element_type, $class_names => $class_names,
1124     $lang_tag => $lang_tag, $parent => $parent);
1125 wakaba 1.2 } (termStartTag) {
1126     lang:Perl {
1127     CORE::delete $parent->{tr};
1128     __CODE{setTextParent}__;
1129     my $a_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'anchor');
1130     $parent->{text}->[-1]->append_child ($a_el);
1131     push @{$parent->{text}}, $a_el;
1132     }
1133     } (midTag) {
1134     lang:Perl ($v => $token.value) {
1135     CORE::delete $parent->{tr};
1136     if (defined $parent->{text}->[0]) {
1137     my $xuri = $parent->{text}->[-1]->manakai_expanded_uri;
1138     if ($xuri eq <Q::xhtml2|rb> or $xuri eq <Q::xhtml2|rt>) {
1139     push @{$parent->{text}},
1140     $parent->{text}->[-1]->parent_node
1141     ->append_child
1142     ($self->{doc}->create_element_ns
1143     (<Q::xhtml2|>,
1144     'h2:rt'));
1145     } elsif ($xuri eq <Q::sw010|qname>) {
1146     push @{$parent->{text}},
1147     $parent->{text}->[-1]->parent_node
1148     ->append_child
1149     ($self->{doc}->create_element_ns
1150     (<Q::sw010|>,
1151     'nsuri'));
1152     } else {
1153     __CODE{setTextParent}__;
1154     $parent->{text}->[-1]->manakai_append_text ($v);
1155     }
1156     } else {
1157     __CODE{setTextParent}__;
1158     $parent->{text}->[-1]->manakai_append_text ($v);
1159     }
1160     }
1161     } (midTagLang) {
1162     lang:Perl ($v => $token.value) {
1163     CORE::delete $parent->{tr};
1164     if (defined $parent->{text}->[0]) {
1165     my $xuri = $parent->{text}->[-1]->manakai_expanded_uri;
1166     $v =~ /\@([A-Za-z0-9-]*)/;
1167     my $lang = $1;
1168     if ($xuri eq <Q::xhtml2|rb> or $xuri eq <Q::xhtml2|rt>) {
1169     push @{$parent->{text}},
1170     $parent->{text}->[-1]->parent_node
1171     ->append_child
1172     ($self->{doc}->create_element_ns
1173     (<Q::xhtml2|>,
1174     'h2:rt'));
1175     $parent->{text}->[-1]
1176     ->set_attribute_ns (<Q::xml|>, 'xml:lang', $lang);
1177     } elsif ($xuri eq <Q::sw010|qname>) {
1178     push @{$parent->{text}},
1179     $parent->{text}->[-1]->parent_node
1180     ->append_child
1181     ($self->{doc}->create_element_ns
1182     (<Q::sw010|>,
1183     'nsuri'));
1184     $parent->{text}->[-1]
1185     ->set_attribute_ns (<Q::xml|>, 'xml:lang', $lang);
1186     } else {
1187     __CODE{setTextParent}__;
1188     $parent->{text}->[-1]->manakai_append_text ($v);
1189     }
1190     } else {
1191     __CODE{setTextParent}__;
1192     $parent->{text}->[-1]->manakai_append_text ($v);
1193     }
1194     }
1195     } (endTag) {
1196     lang:Perl {
1197     my $iref;
1198     my $xref;
1199     __CODE{endTag:: $tagString => ']]'}__;
1200     }
1201     } (endTagAnchorNumberRef) {
1202     lang:Perl ($v => $token.value) {
1203     $v =~ />>([0-9]+)/;
1204     my $iref = $1;
1205     my $xref;
1206     __CODE{endTag:: $tagString => $v}__;
1207     }
1208     } (endTagExternalRefStart) {
1209     my $xref;
1210     lang:Perl {
1211     $xref = '';
1212     }
1213     ~* (text) {
1214     lang:Perl ($v => $token.value) {
1215     $xref .= $v;
1216     }
1217     } (quotedPair) {
1218     lang:Perl ($v => $token.value) {
1219     $xref .= $v;
1220     }
1221     } (lit) {
1222     lang:Perl {
1223     $xref .= '"';
1224     }
1225     }
1226     ~ (endTagExternalRefEnd) { }
1227     lang:Perl {
1228     my $iref;
1229     __CODE{endTag:: $tagString => {']<'.$xref.'>]'}}__;
1230     }
1231 wakaba 1.1 } (eol) {
1232     ~? (eol) {
1233     lang:Perl {
1234 wakaba 1.2 CORE::delete $parent->{tr};
1235     if ($state eq 'pre') {
1236     $parent->{text}->[-1]->manakai_append_text ("\x0A\x0A");
1237     } elsif ($state eq 'obspre') {
1238     $#{$parent->{block}}--;
1239     $parent->{text} = [];
1240     $state = 'section';
1241     } else {
1242     $parent->{block} = [$parent->{section}->[-1]];
1243     $parent->{quote} = [$parent->{block}->[-1]];
1244     $parent->{list} = [];
1245     $parent->{text} = [];
1246     $state = 'section';
1247     }
1248 wakaba 1.1 }
1249     } else {
1250     lang:Perl {
1251 wakaba 1.2 CORE::delete $parent->{tr};
1252 wakaba 1.1 if ($state eq 'heading') {
1253 wakaba 1.2 $parent->{text} = [];
1254 wakaba 1.1 $state = 'section';
1255 wakaba 1.2 } elsif ($state eq 'pre') {
1256     $parent->{text}->[-1]->manakai_append_text ("\x0A");
1257     } elsif (defined $parent->{text}->[0]) {
1258     $parent->{text}->[-1]->manakai_append_text ("\x0A");
1259 wakaba 1.1 }
1260     }
1261     }
1262 wakaba 1.2 } (anchorNumberDef) {
1263     lang:Perl ($v => $token.value) {
1264     CORE::delete $parent->{tr};
1265     __CODE{setTextParent}__;
1266     my $a_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'anchor-end');
1267     $a_el->set_attribute_ns (<Q::sw09|>, 'sw9:anchor',
1268     0+substr ($v, 1, length ($v) - 2));
1269     $a_el->text_content ($v);
1270     $parent->{text}->[-1]->append_child ($a_el);
1271     }
1272     } (anchorNumberRef) {
1273     lang:Perl ($v => $token.value) {
1274     CORE::delete $parent->{tr};
1275     __CODE{setTextParent}__;
1276     my $a_el = $self->{doc}
1277     ->create_element_ns (<Q::sw09|>, 'anchor-internal');
1278     $a_el->set_attribute_ns (<Q::sw09|>, 'sw9:anchor',
1279     0+substr ($v, 2));
1280     $a_el->text_content ($v);
1281     $parent->{text}->[-1]->append_child ($a_el);
1282     }
1283     } (externalRefStart) {
1284     my $xref;
1285     ~ (text) {
1286     lang:Perl ($v => $token.value) {
1287     $xref .= $v;
1288     }
1289     } (quotedPair) {
1290     lang:Perl ($v => $token.value) {
1291     $xref .= $v;
1292     }
1293     } (lit) {
1294     lang:Perl {
1295     $xref .= '"';
1296     }
1297     }
1298     ~ (externalRefEnd) { }
1299     lang:Perl {
1300     CORE::delete $parent->{tr};
1301     __CODE{setTextParent}__;
1302     my $a_el = $self->{doc}
1303     ->create_element_ns (<Q::sw09|>, 'anchor-external');
1304     my $data = $xref;
1305     my $scheme;
1306     if ($data =~ s/^([A-Z]+)://) {
1307     $scheme = $1;
1308     } else {
1309     $scheme = 'URI';
1310     }
1311     $a_el->set_attribute_ns (<Q::sw09|>, 'sw9:resScheme', $scheme);
1312     $a_el->set_attribute_ns (<Q::sw09|>, 'sw9:resParameter', $data);
1313     $a_el->text_content ($xref);
1314     $parent->{text}->[-1]->append_child ($a_el);
1315     }
1316 wakaba 1.1 } (listStart) {
1317     lang:Perl ($v => $token.value) {
1318 wakaba 1.2 CORE::delete $parent->{tr};
1319     if ($state eq 'pre' or $state eq 'obspre') {
1320     $parent->{text}->[-1]->manakai_append_text (substr $v, 1);
1321     } else {
1322     $v =~ /([-=]+)/;
1323     my $level = length ($1) - 1;
1324     my $type = substr ($1, -1) eq '-' ? 'ul' : 'ol';
1325     if (defined $parent->{list}->[$level]) {
1326     unless ($parent->{list}->[$level]->local_name eq $type) {
1327     $parent->{list}->[$level]
1328     = $parent->{list}->[$level]->parent_node
1329     ->append_child
1330     ($self->{doc}->create_element_ns
1331     (<Q::xhtml2|>, 'h2:'.$type));
1332     }
1333     } elsif (defined $parent->{list}->[0]) {
1334     my $parent_list = $parent->{list}->[-1];
1335     my $parent_lc = $parent_list->last_child;
1336     if (defined $parent_lc and
1337     $parent_lc->node_type eq <C::Node.ELEMENT_NODE>) {
1338     $parent->{list}->[$level]
1339     = $parent_lc->append_child
1340     ($self->{doc}->create_element_ns
1341 wakaba 1.1 (<Q::xhtml2|>, 'h2:'.$type));
1342 wakaba 1.2 } else {
1343     $parent->{list}->[$level]
1344     = $parent_list->append_child
1345     ($self->{doc}->create_element_ns
1346     (<Q::xhtml2|>, 'h2:li'))
1347     ->append_child
1348     ($self->{doc}->create_element_ns
1349     (<Q::xhtml2|>, 'h2:'.$type));
1350     }
1351 wakaba 1.1 } else {
1352     $parent->{list}->[$level]
1353 wakaba 1.2 = $parent->{block}->[-1]->append_child
1354     ($self->{doc}->create_element_ns
1355 wakaba 1.1 (<Q::xhtml2|>, 'h2:'.$type));
1356     }
1357 wakaba 1.2 push @{$parent->{block}},
1358     $parent->{list}->[$level]->append_child
1359     ($self->{doc}->create_element_ns
1360     (<Q::xhtml2|>, 'h2:li'));
1361     $parent->{text} = [$parent->{block}->[-1]];
1362     $state = 'section';
1363     }
1364     }
1365     } (dlistStart) {
1366     lang:Perl ($v => $token.value) {
1367     CORE::delete $parent->{tr};
1368     if ($state eq 'pre' or $state eq 'obspre') {
1369     $parent->{text}->[-1]->manakai_append_text (substr ($v, 1));
1370     } else {
1371     $v =~ /:([^:]*)/;
1372     my $dt_src = $1;
1373    
1374     my $dr_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'dr');
1375     my $dt_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:dt');
1376     my $dd_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:dd');
1377     $dr_el->append_child ($dt_el);
1378     $dr_el->append_child ($dd_el);
1379    
1380     if ($parent->{block}->[-1]->manakai_expanded_uri eq <Q::xhtml2|dd>) {
1381     $parent->{block}->[-1]->parent_node->parent_node
1382     ->append_child ($dr_el);
1383     } else {
1384     my $dl_el = $self->{doc}->create_element_ns
1385     (<Q::xhtml2|>, 'h2:dl');
1386     $dl_el->append_child ($dr_el);
1387     $parent->{block}->[-1]->append_child ($dl_el);
1388     }
1389     push @{$parent->{block}}, $dd_el;
1390     $parent->{text} = [$dd_el];
1391     $parent->{list} = [];
1392     $parent->{edit} = [];
1393     $state = 'section';
1394    
1395     my $original_pos = pos $self->{source};
1396     {
1397     local $self->{token} = [];
1398     local $self->{char} = [];
1399     local $self->{source} = $dt_src;
1400     pos ($self->{source}) = 0;
1401     local $self->{location} = {};
1402     local $self->{scanner} = $self->can ('_scan_Body');
1403     $self->_parse_Body ({
1404     block => [$dt_el],
1405     quote => [$dt_el],
1406     section => [null, $dt_el],
1407     text => [$dt_el],
1408     });
1409     }
1410     pos ($self->{source}) = $original_pos;
1411     }
1412     }
1413     } (emphasis2) {
1414     lang:Perl {
1415     CORE::delete $parent->{tr};
1416     if (defined $parent->{text}->[1] and
1417     $parent->{text}->[-1]->manakai_expanded_uri eq <Q::xhtml2|em>) {
1418     $#{$parent->{text}}--;
1419     } else {
1420     __CODE{setTextParent}__;
1421     my $em_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:em');
1422     $parent->{text}->[-1]->append_child ($em_el);
1423     push @{$parent->{text}}, $em_el;
1424     }
1425     }
1426     } (emphasis3) {
1427     lang:Perl {
1428     CORE::delete $parent->{tr};
1429     if (defined $parent->{text}->[1] and
1430     $parent->{text}->[-1]->manakai_expanded_uri
1431     eq <Q::xhtml2|strong>) {
1432     $#{$parent->{text}}--;
1433 wakaba 1.1 } else {
1434 wakaba 1.2 __CODE{setTextParent}__;
1435     my $em_el = $self->{doc}->create_element_ns
1436     (<Q::xhtml2|>, 'h2:strong');
1437     $parent->{text}->[-1]->append_child ($em_el);
1438     push @{$parent->{text}}, $em_el;
1439     }
1440     }
1441     } (quote) {
1442     lang:Perl ($v => $token.value) {
1443     CORE::delete $parent->{tr};
1444     if ($state eq 'pre' or $state eq 'obspre') {
1445     $parent->{text}->[-1]->manakai_append_text (substr ($v, 1));
1446     } else {
1447     $v =~ /(>+)/;
1448     my $level = length $1;
1449     if (defined $parent->{quote}->[$level]) {
1450     if (defined $parent->{quote}->[$level + 1]) {
1451     $#{$parent->{quote}} = $level;
1452     }
1453     } else {
1454     L: for my $i (1..$level) {
1455     next L if defined $parent->{quote}->[$i];
1456     $parent->{quote}->[$i]
1457     = $parent->{quote}->[$i - 1]
1458     ->append_child ($self->{doc}->create_element_ns
1459     (<Q::xhtml2|>, 'h2:blockquote'))
1460     ->append_child
1461     ($self->{doc}->create_element_ns
1462     (<Q::html3|>, 'h3:bodytext'));
1463     } # L
1464     }
1465     push @{$parent->{block}}, $parent->{quote}->[$level];
1466     $parent->{text} = [];
1467     $parent->{list} = [];
1468     $state = 'section';
1469 wakaba 1.1 }
1470     }
1471     } (headingStart) {
1472     lang:Perl ($v => $token.value) {
1473 wakaba 1.2 CORE::delete $parent->{tr};
1474     if ($state eq 'pre' or $state eq 'obspre') {
1475     $parent->{text}->[-1]->manakai_append_text (substr ($v, 1));
1476     } else {
1477     $v =~ /(\*+)/;
1478     my $level = length $1;
1479     if (defined $parent->{section}->[$level]) {
1480     if (defined $parent->{section}->[$level + 1]) {
1481     $#{$parent->{section}} = $level;
1482     }
1483     } else {
1484     L: for my $i (2..$level) {
1485     next L if defined $parent->{section}->[$i];
1486     $parent->{section}->[$i]
1487     = $self->{doc}->create_element_ns
1488     (<Q::xhtml2|>, 'h2:section');
1489     $parent->{section}->[$i - 1]
1490     ->append_child ($parent->{section}->[$i]);
1491     } # L
1492 wakaba 1.1 }
1493 wakaba 1.2 $parent->{section}->[$level + 1]
1494     = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:section');
1495     $parent->{section}->[$level]
1496     ->append_child ($parent->{section}->[$level + 1]);
1497     $parent->{block} = [$parent->{section}->[$level + 1]];
1498     $parent->{quote} = [$parent->{block}->[-1]];
1499     $parent->{text} = [$self->{doc}->create_element_ns
1500     (<Q::xhtml2|>, 'h2:h')];
1501     $parent->{block}->[-1]->append_child ($parent->{text}->[-1]);
1502     $parent->{list} = [];
1503     $state = 'heading';
1504     }
1505     }
1506     } (noteStart) {
1507     lang:Perl ($v => $token.value) {
1508     CORE::delete $parent->{tr};
1509     if ($state eq 'pre' or $state eq 'obspre') {
1510     $parent->{text}->[-1]->manakai_append_text
1511     (substr ($v, 1, length ($v) - 2) . "\x0A");
1512 wakaba 1.1 } else {
1513 wakaba 1.2 my $ed_el = $self->{doc}->create_element_ns
1514     (<Q::sw010|>, 'sw10:comment-p');
1515     $parent->{block}->[-1]->append_child ($ed_el);
1516     push @{$parent->{block}}, $ed_el;
1517     $parent->{list} = [];
1518     $parent->{quote} = [$ed_el];
1519     $parent->{text} = [$ed_el];
1520     $state = 'section';
1521     }
1522     }
1523     } (edStart) {
1524     lang:Perl ($v => $token.value) {
1525     CORE::delete $parent->{tr};
1526     if ($state eq 'pre' or $state eq 'obspre') {
1527     $parent->{text}->[-1]->manakai_append_text
1528     (substr ($v, 1, length ($v) - 2) . "\x0A");
1529     } else {
1530     my $ed_el = $self->{doc}->create_element_ns (<Q::sw010|>, 'sw10:ed');
1531     $parent->{block}->[-1]->append_child ($ed_el);
1532     push @{$parent->{block}}, $ed_el;
1533     $parent->{list} = [];
1534     $parent->{quote} = [$ed_el];
1535     $parent->{text} = [$ed_el];
1536     $state = 'section';
1537     }
1538     }
1539     } (preStartTag) {
1540     lang:Perl ($v => $token.value) {
1541     CORE::delete $parent->{tr};
1542     if ($state eq 'pre' or $state eq 'obspre') {
1543     $parent->{text}->[-1]->manakai_append_text
1544     (substr ($v, 1, length ($v) - 2) . "\x0A");
1545     } else {
1546     my $pre_el = $self->{doc}->create_element_ns
1547     (<Q::xhtml2|>, 'h2:pre');
1548     $pre_el->set_attribute_ns (<Q::xml|>, 'xml:space', 'preserve');
1549     $parent->{block}->[-1]->append_child ($pre_el);
1550     push @{$parent->{block}}, $pre_el;
1551     $parent->{text} = [$pre_el];
1552     $state = 'pre';
1553     }
1554     }
1555     } (preStartTagClass) {
1556     lang:Perl ($v => $token.value) {
1557     CORE::delete $parent->{tr};
1558     if ($state eq 'pre' or $state eq 'obspre') {
1559     $parent->{text}->[-1]->manakai_append_text
1560     (substr ($v, 1, length ($v) - 2) . "\x0A");
1561     } else {
1562     my $pre_el = $self->{doc}->create_element_ns
1563     (<Q::xhtml2|>, 'h2:pre');
1564     $pre_el->set_attribute_ns (<Q::xml|>, 'xml:space', 'preserve');
1565     $v =~ /\(([^()]*)/;
1566     $pre_el->set_attribute_ns (null, class => $1);
1567     $parent->{block}->[-1]->append_child ($pre_el);
1568     push @{$parent->{block}}, $pre_el;
1569     $parent->{text} = [$pre_el];
1570     $state = 'pre';
1571     }
1572     }
1573     } (obsPreStart) {
1574     lang:Perl ($v => $token.value) {
1575     CORE::delete $parent->{tr};
1576     unless ($state eq 'pre' or $state eq 'obspre') {
1577     my $pre_el = $self->{doc}->create_element_ns
1578     (<Q::xhtml2|>, 'h2:pre');
1579     $pre_el->set_attribute_ns (<Q::xml|>, 'xml:space', 'preserve');
1580     $parent->{block}->[-1]->append_child ($pre_el);
1581     push @{$parent->{block}}, $pre_el;
1582     $parent->{text} = [$pre_el];
1583     $state = 'obspre';
1584     }
1585     $parent->{text}->[-1]->manakai_append_text (substr ($v, 1));
1586     }
1587     } (preEndTag) {
1588     lang:Perl ($v => $token.value) {
1589     CORE::delete $parent->{tr};
1590     if ($state eq 'pre' or $state eq 'obspre') {
1591     $#{$parent->{block}}--;
1592     $parent->{text} = [];
1593     $parent->{list} = [];
1594     $parent->{quote} = [$parent->{block}->[-1]];
1595     $state = 'section';
1596     } else {
1597     __CODE{setTextParent}__;
1598     $parent->{text}->[-1]->manakai_append_text
1599     (substr ($v, 1, length ($v) - 2) . "\x0A");
1600     }
1601     }
1602     } (insStartTag) {
1603     lang:Perl ($v => $token.value) {
1604     CORE::delete $parent->{tr};
1605     if ($state eq 'pre' or $state eq 'obspre') {
1606     $parent->{text}->[-1]->manakai_append_text
1607     (substr ($v, 1, length ($v) - 2) . "\x0A");
1608     } else {
1609     my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'insert');
1610     $parent->{block}->[-1]->append_child ($ins_el);
1611     push @{$parent->{edit}}, {
1612     section => $parent->{section},
1613     block => $parent->{block},
1614     text => $parent->{text},
1615     list => $parent->{list},
1616     quote => $parent->{quote},
1617     type => 'insert',
1618     };
1619     $parent->{section} = [null, $ins_el];
1620     $parent->{block} = [$ins_el];
1621     $parent->{text} = [];
1622     $parent->{list} = [];
1623     $parent->{quote} = [$parent->{block}->[-1]];
1624     }
1625     }
1626     } (insStartTagClass) {
1627     lang:Perl ($v => $token.value) {
1628     CORE::delete $parent->{tr};
1629     if ($state eq 'pre' or $state eq 'obspre') {
1630     $parent->{text}->[-1]->manakai_append_text
1631     (substr ($v, 1, length ($v) - 2) . "\x0A");
1632     } else {
1633     my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'insert');
1634     $parent->{block}->[-1]->append_child ($ins_el);
1635     $v =~ /\(([^()]*)/;
1636     $ins_el->set_attribute_ns (null, class => $1);
1637     push @{$parent->{edit}}, {
1638     section => $parent->{section},
1639     block => $parent->{block},
1640     list => $parent->{list},
1641     quote => $parent->{quote},
1642     type => 'insert',
1643     };
1644     $parent->{section} = [null, $ins_el];
1645     $parent->{block} = [$ins_el];
1646     $parent->{text} = [];
1647     $parent->{list} = [];
1648     $parent->{quote} = [$parent->{block}->[-1]];
1649     }
1650     }
1651     } (insEndTag) {
1652     lang:Perl ($v => $token.value) {
1653     CORE::delete $parent->{tr};
1654     if ($state eq 'pre' or $state eq 'obspre') {
1655     $parent->{text}->[-1]->manakai_append_text
1656     (substr ($v, 1, length ($v) - 2) . "\x0A");
1657     } else {
1658     if (defined $parent->{edit}->[0] and
1659     $parent->{edit}->[-1]->{type} eq 'insert') {
1660     my $rp = pop @{$parent->{edit}};
1661     $parent->{$_} = $rp->{$_}
1662     for qw/section block list quote/;
1663     $parent->{text} = [];
1664     } else {
1665     $parent->{text}->[-1]->manakai_append_text
1666     (substr ($v, 1, length ($v) - 2) . "\x0A");
1667     }
1668     }
1669     }
1670     } (delStartTag) {
1671     lang:Perl ($v => $token.value) {
1672     CORE::delete $parent->{tr};
1673     if ($state eq 'pre' or $state eq 'obspre') {
1674     $parent->{text}->[-1]->manakai_append_text
1675     (substr ($v, 1, length ($v) - 2) . "\x0A");
1676     } else {
1677     my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'delete');
1678     $parent->{block}->[-1]->append_child ($ins_el);
1679     push @{$parent->{edit}}, {
1680     section => $parent->{section},
1681     block => $parent->{block},
1682     list => $parent->{list},
1683     quote => $parent->{quote},
1684     type => 'delete',
1685     };
1686     $parent->{section} = [null, $ins_el];
1687     $parent->{block} = [$ins_el];
1688     $parent->{text} = [];
1689     $parent->{list} = [];
1690     $parent->{quote} = [$parent->{block}->[-1]];
1691     }
1692     }
1693     } (delStartTagClass) {
1694     lang:Perl ($v => $token.value) {
1695     CORE::delete $parent->{tr};
1696     if ($state eq 'pre' or $state eq 'obspre') {
1697     $parent->{text}->[-1]->manakai_append_text
1698     (substr ($v, 1, length ($v) - 2) . "\x0A");
1699     } else {
1700     my $ins_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'delete');
1701     $parent->{block}->[-1]->append_child ($ins_el);
1702     $v =~ /\(([^()]*)/;
1703     $ins_el->set_attribute_ns (null, class => $1);
1704     push @{$parent->{edit}}, {
1705     section => $parent->{section},
1706     block => $parent->{block},
1707     list => $parent->{list},
1708     quote => $parent->{quote},
1709     type => 'delete',
1710     };
1711     $parent->{section} = [null, $ins_el];
1712     $parent->{block} = [$ins_el];
1713     $parent->{text} = [];
1714     $parent->{list} = [];
1715     $parent->{quote} = [$parent->{block}->[-1]];
1716     }
1717     }
1718     } (delEndTag) {
1719     lang:Perl ($v => $token.value) {
1720     CORE::delete $parent->{tr};
1721     if ($state eq 'pre' or $state eq 'obspre') {
1722     $parent->{text}->[-1]->manakai_append_text
1723     (substr ($v, 1, length ($v) - 2) . "\x0A");
1724     } else {
1725     if (defined $parent->{edit}->[0] and
1726     $parent->{edit}->[-1]->{type} eq 'delete') {
1727     my $rp = pop @{$parent->{edit}};
1728     $parent->{$_} = $rp->{$_}
1729     for qw/section block list quote/;
1730     $parent->{text} = [];
1731     } else {
1732     $parent->{text}->[-1]->manakai_append_text
1733     (substr ($v, 1, length ($v) - 2) . "\x0A");
1734     }
1735     }
1736     }
1737     } (tableLine) {
1738     lang:Perl ($v => $token.value) {
1739     if ($state eq 'pre' or $state eq 'obspre') {
1740     $parent->{text}->[-1]->manakai_append_text (substr ($v, 1));
1741     } else {
1742     my $tbody_el;
1743     if (defined $parent->{tr}) {
1744     $tbody_el = $parent->{tr};
1745     } else {
1746     my $tbl_el = $self->{doc}->create_element_ns
1747     (<Q::xhtml2|>, 'h2:table');
1748     my $tbody_el = $self->{doc}->create_element_ns
1749     (<Q::xhtml2|>, 'h2:tbody');
1750     $tbl_el->append_child ($tbody_el);
1751     $parent->{block}->[-1]->append_child ($tbl_el);
1752     $parent->{tr} = $tbody_el;
1753     }
1754    
1755     my $tr_el = $self->{doc}->create_element_ns (<Q::xhtml2|>, 'h2:tr');
1756     $parent->{tr}->append_child ($tr_el);
1757     my $src = substr ($v, 1, length ($v) - 2);
1758     my $prev_cell;
1759     C: while ($src =~ /\G,\s*/gc) {
1760     $src =~ /\G([^,"][^,]*|"(?>[^"\\]*)(?>(?>[^"\\]+|\\.)*)"\s*)/gc;
1761     my $cell = defined $1 ? $1 : '';
1762     if ($cell =~ s/^"//) {
1763     $cell =~ s/"\s*$//g;
1764     $cell =~ s/\\(.)/$1/gs;
1765     } else {
1766     $cell =~ s/\s+$//g;
1767     if ($cell eq '==') {
1768     if (ref $prev_cell) {
1769     my $colspan = $prev_cell->get_attribute_ns (null, 'colspan');
1770     $colspan = defined $colspan ? $colspan + 1 : 1;
1771     $prev_cell->set_attribute_ns (null, colspan => $colspan);
1772     next C;
1773     }
1774     }
1775     }
1776     $prev_cell = $self->{doc}->create_element_ns
1777     (<Q::xhtml2|>, 'h2:td');
1778     $tr_el->append_child ($prev_cell);
1779    
1780     my $original_pos = pos $self->{source};
1781     {
1782     local $self->{token} = [];
1783     local $self->{char} = [];
1784     local $self->{source} = $cell;
1785     pos ($self->{source}) = 0;
1786     local $self->{location} = {};
1787     local $self->{scanner} = $self->can ('_scan_Body');
1788     $self->_parse_Body ({
1789     block => [$prev_cell],
1790     quote => [$prev_cell],
1791     section => [null, $prev_cell],
1792     text => [$prev_cell],
1793     });
1794     }
1795     pos ($self->{source}) = $original_pos;
1796     }
1797     $parent->{text} = [];
1798     $state = 'section';
1799     }
1800     }
1801     } (formStart) {
1802     my $form_el;
1803     my $param;
1804     my $ref;
1805     lang:Perl ($v => $token.value) {
1806     CORE::delete $parent->{tr};
1807     $form_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'form');
1808     $v =~ /#([a-z-]+)/;
1809     $form_el->set_attribute_ns (null, ref => $ref = $1);
1810     $param = '';
1811     }
1812    
1813     ~* (text) {
1814     lang:Perl ($v => $token.value) {
1815     $param .= $v;
1816     }
1817     } (quotedPair) {
1818     lang:Perl ($v => $token.value) {
1819     $param .= $v;
1820     }
1821     } (lita) {
1822     lang:Perl ($v => $token.value) {
1823     $param .= "'";
1824     }
1825     }
1826    
1827     ~ (formEnd) { }
1828    
1829     lang:Perl {
1830     if ($param =~ s/^\(([^()]*)\)//) {
1831     $form_el->set_attribute_ns (null, id => $1);
1832     }
1833     if ($ref eq 'form' and
1834     $param =~ m{\A
1835     : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' ## input
1836     (?> : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' ## template
1837     (?> : ' ((?>[^\\']*)(?>(?>[^\\']+|\\.)*)) ' )? )? ## option
1838     \z}x) {
1839     my ($in, $te, $op) = ($1, defined $2 ? $2 : '',
1840     defined $3 ? $3 : '');
1841     s/\\(.)/$1/g for $in, $te, $op;
1842     $form_el->set_attribute_ns (null, input => $1);
1843     $form_el->set_attribute_ns (null, template => defined $2 ? $2 : '');
1844     $form_el->set_attribute_ns (null, option => defined $3 ? $3 : '');
1845     } else {
1846     $param =~ s/^://;
1847     $form_el->set_attribute_ns (null, parameter => $param);
1848     }
1849    
1850     if (defined $parent->{text}->[0]) {
1851     $parent->{text}->[-1]->append_child ($form_el);
1852     } else {
1853     $parent->{block}->[-1]->append_child ($form_el);
1854     }
1855     }
1856     } (magicVersionS) {
1857     lang:Perl ($v => $token.value) {
1858     CORE::delete $parent->{tr};
1859     __CODE{setTextParent}__;
1860     $parent->{text}->[-1]->manakai_append_text (substr ($v, 1));
1861     }
1862     ?lexmode Body;
1863     } (magicVersionI) {
1864     lang:Perl ($v => $token.value) {
1865     CORE::delete $parent->{tr};
1866     __CODE{setTextParent}__;
1867     $parent->{text}->[-1]->manakai_append_text ($v);
1868     }
1869     ?lexmode Body;
1870     } (entityRef) {
1871     lang:Perl ($v => $token.value) {
1872     CORE::delete $parent->{tr};
1873     my $ref_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'replace');
1874     $ref_el->set_attribute_ns
1875     (null, 'by', substr ($v, 4, length ($v) - 8));
1876     if (defined $parent->{text}->[0]) {
1877     $parent->{text}->[-1]->append_child ($ref_el);
1878     } else {
1879     $parent->{block}->[-1]->append_child ($ref_el);
1880     }
1881     }
1882     } (imageStart) {
1883     lang:Perl {
1884     my $img_el = $self->{doc}->create_element_ns (<Q::sw09|>, 'image');
1885    
1886     my $value = '';
1887     while (my $token = shift @{$self->{token}}) {
1888     $value .= $token->{value} if defined $token->{value};
1889     }
1890     $value =~ tr/\x0D//d;
1891     $img_el->manakai_append_text ($value);
1892     $value = '';
1893    
1894     while ((my $char = $self->_shift_char) >= 0) {
1895     if ($char == 0x000D) {
1896     $img_el->manakai_append_text ($value);
1897     $value = '';
1898     } else {
1899     $value .= ord $char;
1900     }
1901     }
1902     $img_el->manakai_append_text ($value);
1903    
1904     $self->{doc}->document_element->append_child ($img_el);
1905     }
1906     } (name) {
1907     lang:Perl ($v => $token.value) {
1908     CORE::delete $parent->{tr};
1909     __CODE{setTextParent}__;
1910     $parent->{text}->[-1]->manakai_append_text ($v);
1911     }
1912     } (vi) {
1913     lang:Perl ($v => $token.value) {
1914     CORE::delete $parent->{tr};
1915     __CODE{setTextParent}__;
1916     $parent->{text}->[-1]->manakai_append_text ('=');
1917     }
1918     } (lit) {
1919     lang:Perl ($v => $token.value) {
1920     CORE::delete $parent->{tr};
1921     __CODE{setTextParent}__;
1922     $parent->{text}->[-1]->manakai_append_text ($v);
1923 wakaba 1.1 }
1924     }
1925 wakaba 1.2 } // Body
1926 wakaba 1.1
1927     rule MagicParam {
1928     ~* (name) {
1929     my $param_el;
1930     my $value;
1931     lang:Perl ($v => $token.value) {
1932     $param_el = $self->{doc}->create_element_ns
1933     (<Q::sw09|>, 'parameter');
1934     $param_el->set_attribute_ns (null, 'name', $v);
1935     $value = '';
1936     }
1937    
1938     ~ (vi) { }
1939     ~ (lit) { }
1940     ~* (text) {
1941     lang:Perl ($v => $token.value) {
1942     $value .= $v;
1943     }
1944     } (quotedPair) {
1945     lang:Perl ($v => $token.value) {
1946     $value .= substr ($v, 1);
1947     }
1948     }
1949     ~ (lit) { }
1950    
1951     lang:Perl {
1952     for (split /,/, $value) {
1953     $param_el->append_child ($self->{doc}->create_element_ns
1954     (<Q::sw09|>, 'value'))
1955     ->manakai_append_text ($_);
1956     }
1957    
1958     $self->{docel}->head_element->append_child ($param_el);
1959     }
1960     }
1961    
1962     ~ (eol) { }
1963     } // MagicParam
1964    
1965     rule _StartTag ($parent, $element_type, $class_names, $lang_tag) {
1966     lang:Perl {
1967 wakaba 1.2 __CODE{setTextParent}__;
1968 wakaba 1.1 my @class_names = split /\s+/, $class_names;
1969     my $et = {
1970     ABBR => [<Q::xhtml2|>, 'abbr'],
1971     CODE => [<Q::xhtml2|>, 'code'],
1972     DEL => [<Q::xhtml2|>, 'del'],
1973     DFN => [<Q::xhtml2|>, 'dfn'],
1974     INS => [<Q::xhtml2|>, 'ins'],
1975     KBD => [<Q::xhtml2|>, 'kbd'],
1976     Q => [<Q::xhtml2|>, 'q'],
1977     RUBY => [<Q::xhtml2|>, 'ruby'],
1978     RUBYB=> [<Q::sw09|>, 'rubyb'],
1979     SAMP => [<Q::xhtml2|>, 'samp'],
1980     SUB => [<Q::xhtml2|>, 'sub'],
1981     SUP => [<Q::xhtml2|>, 'sup'],
1982     VAR => [<Q::xhtml2|>, 'var'],
1983     WEAK => [<Q::sw09|>, 'weak'],
1984     AA => [<Q::aa|>, 'aa'],
1985     CITE => [<Q::xhtml2|>, 'cite'],
1986     CSECTION => [<Q::sw010|>, 'csection'],
1987     KEY => [<Q::sw010|>, 'key'],
1988     QN => [<Q::sw010|>, 'qn'],
1989     SPAN => [<Q::xhtml2|>, 'span'],
1990     SRC => [<Q::sw010|>, 'src'],
1991     }->{$element_type};
1992     unless (defined $et) {
1993     $et = [<Q::xhtml2|>, 'code'];
1994     push @class_names, $element_type;
1995     }
1996 wakaba 1.2 my $el = $self->{doc}->create_element_ns ($et->[0], $et->[1]);
1997     $parent->{text}->[-1]->append_child ($el);
1998     $el->set_attribute_ns (null, 'class' => join ' ', @class_names)
1999 wakaba 1.1 if @class_names;
2000 wakaba 1.2 $el->set_attribute_ns (<Q::xml|>, 'xml:lang', $lang_tag)
2001 wakaba 1.1 if defined $lang_tag;
2002 wakaba 1.2
2003     if ($element_type eq 'RUBY' or $element_type eq 'RUBYB' or
2004     $element_type eq 'RUBYB') {
2005     $el = $el->append_child ($self->{doc}->create_element_ns
2006     (<Q::xhtml2|>, 'rb'));
2007     } elsif ($element_type eq 'QN') {
2008     $el = $el->append_child ($self->{doc}->create_element_ns
2009     (<Q::sw010|>, 'qname'));
2010     }
2011    
2012     push @{$parent->{text}}, $el;
2013 wakaba 1.1 }
2014     } // _StartTag
2015    
2016 wakaba 1.2 token-error default : default {
2017     //
2018     }
2019    
2020     @CODE:
2021     @@QName: setTextParent
2022 wakaba 1.1 @@PerlDef:
2023 wakaba 1.2 unless (defined $parent->{text}->[0]) {
2024     $parent->{text} = [$parent->{block}->[-1]
2025     ->append_child
2026     ($self->{doc}->create_element_ns
2027     (<Q::xhtml2|>, 'h2:p'))];
2028 wakaba 1.1 }
2029    
2030 wakaba 1.2 @CODE:
2031     @@QName: endTag
2032     @@PerlDef:
2033     if (defined $parent->{text}->[1]) {
2034     if (defined $iref) {
2035     $parent->{text}->[-1]->set_attribute_ns
2036     (<Q::sw09|>, 'sw9:anchor', 0+$iref);
2037     }
2038     if (defined $xref) {
2039     if ($xref =~ s/^([A-Z]+)://) {
2040     $parent->{text}->[-1]->set_attribute_ns
2041     (<Q::sw09|>, 'sw9:resScheme', $1);
2042     $parent->{text}->[-1]->set_attribute_ns
2043     (<Q::sw09|>, 'sw9:resParameter', $xref);
2044     } else {
2045     $parent->{text}->[-1]->set_attribute_ns
2046     (<Q::sw09|>, 'sw9:resScheme', 'URI');
2047     $parent->{text}->[-1]->set_attribute_ns
2048     (<Q::sw09|>, 'sw9:resParameter', $xref);
2049     }
2050     }
2051     $#{$parent->{text}}--;
2052     } else {
2053     __CODE{setTextParent}__;
2054     $parent->{text}->[-1]->manakai_append_text ($tagString);
2055     }
2056 wakaba 1.3
2057     @PTests:
2058     @@PTest:
2059     @@@QName: p.empty.test
2060     @@@DEnt:
2061     @@@@test:value:
2062     \
2063     @@@test:domTree:
2064     document {
2065     element {
2066     namespace-uri: 'urn:x-suika-fam-cx:markup:suikawiki:0:9:';
2067     local-name: 'document';
2068     markup-language-name: 'SuikaWiki';
2069     markup-language-version: '0.10';
2070     element {
2071     namespace-uri: 'http://www.w3.org/2002/06/xhtml2/';
2072     local-name: 'head';
2073     has-child-nodes: false;
2074     }
2075     element {
2076     namespace-uri: 'http://www.w3.org/2002/06/xhtml2/';
2077     local-name: 'body';
2078     has-child-nodes: false;
2079     }
2080     }
2081     }
2082     @@PTest:
2083     @@@QName: p.magic.sw09.test
2084     @@@DEnt:
2085     @@@@test:value:
2086     #?SuikaWiki/0.9
2087     @@@test:domTree:
2088     document {
2089     element {
2090     namespace-uri: 'urn:x-suika-fam-cx:markup:suikawiki:0:9:';
2091     local-name: 'document';
2092     markup-language-name: 'SuikaWiki';
2093     markup-language-version: '0.9';
2094     element {
2095     namespace-uri: 'http://www.w3.org/2002/06/xhtml2/';
2096     local-name: 'head';
2097     has-child-nodes: false;
2098     }
2099     element {
2100     namespace-uri: 'http://www.w3.org/2002/06/xhtml2/';
2101     local-name: 'body';
2102     has-child-nodes: false;
2103     }
2104     }
2105     }
2106     @@PTest:
2107     @@@QName: p.magic.swimg09.test
2108     @@@DEnt:
2109     @@@@test:value:
2110     #?SuikaWikiImage/0.9
2111     @@@test:domTree:
2112     document {
2113     element {
2114     namespace-uri: 'urn:x-suika-fam-cx:markup:suikawiki:0:9:';
2115     local-name: 'document';
2116     markup-language-name: 'SuikaWikiImage';
2117     markup-language-version: '0.9';
2118     element {
2119     namespace-uri: 'http://www.w3.org/2002/06/xhtml2/';
2120     local-name: 'head';
2121     has-child-nodes: false;
2122     }
2123     element {
2124     namespace-uri: 'http://www.w3.org/2002/06/xhtml2/';
2125     local-name: 'body';
2126     has-child-nodes: false;
2127     }
2128     }
2129     }
2130    
2131     @@PerlDef:
2132 wakaba 1.5 my $impl = $Message::DOM::ImplementationRegistry->get_dom_implementation ({
2133 wakaba 1.3 'Core' => '3.0',
2134     'XML' => '3.0',
2135     });
2136    
2137     for my $test_data (@$TestData) {
2138     my $parser = <Class::ManakaiSWDMLParser>->new ($impl);
2139    
2140     $test->start_new_test ($test_data->{uri});
2141     my $doc_ent = $test_data->{entity}->{$test_data->{root_uri}};
2142     my $not_ok;
2143    
2144     ## -- DOM Configuration Parameters
2145    
2146     my $pcfg = $parser->dom_config;
2147     for (keys %{$test_data->{dom_config}}) {
2148     $pcfg->set_parameter ($_ => $test_data->{dom_config}->{$_});
2149     }
2150    
2151     # $pcfg->set_parameter ('error-handler' => sub ($$) {
2152     # my (undef, $err) = @_;
2153     # my $err_type = $err->type;
2154     # if ($test_data->{dom_error}->{$err_type}) {
2155     # $test->assert_error_equals
2156     # (actual_value => $err,
2157     # expected_hash => shift @{$test_data->{dom_error}
2158     # ->{$err_type}});
2159     # } else { # Uncatched error
2160     # warn $err;
2161     # unless ($err->severity == <C::c|DOMError.SEVERITY_WARNING>) {
2162     # $test->failure_comment ('Unexpected error |'.$err->type.'|');
2163     # $not_ok = true;
2164     # }
2165     # }
2166     # return true; # continue as far as possible
2167     # });
2168    
2169     ## -- Test and Result
2170    
2171     my $doc;
2172     try {
2173     $doc = $parser->parse_string ($doc_ent->{<Q::test|value>});
2174     $test->assert_dom_tree_equals
2175     (actual_value => $doc,
2176     expected_hash => $test_data->{dom_tree});
2177     for (values %{$test_data->{dom_error}||{}}) {
2178     if (@$_) {
2179     $test->failure_comment
2180     (@$_.' |DOMError|s of type |'.
2181     $_->[0]->{type}->{value}.'| are not reported');
2182     $not_ok = true;
2183     }
2184     }
2185     $not_ok ? $test->not_ok : $test->ok;
2186     undef $doc;
2187     } catch Message::Util::IF::DTException with {
2188     require Message::DOM::SimpleLS;
2189     my $ls = Message::DOM::SimpleLS::ManakaiDOMSimpleXMLSerializer->new;
2190     print STDERR $ls->write_to_string ($doc);
2191     } otherwise {
2192     my $err = shift;
2193     warn $err;
2194     $test->not_ok;
2195     };
2196     }
2197     ##SWDMLParser
2198 wakaba 1.1

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24