/[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.4 - (hide annotations) (download)
Sat May 6 16:01:04 2006 UTC (18 years, 6 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-3-2
Changes since 1.3: +2 -2 lines
++ manakai/lib/Message/Markup/ChangeLog	6 May 2006 16:00:58 -0000
	* Atom.dis (contentElement): New attribute.

	* H2H.dis (H2HFeature10): The |Version| was incorrect.
	(new): Finds |XML| feature-implemented object.

	* SuikaWiki.dis (new): Finds |XML| feature-implemented object.

2006-05-06  Wakaba  <wakaba@suika.fam.cx>

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24