/[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.9 - (hide annotations) (download)
Sat Dec 30 13:25:34 2006 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +2 -5 lines
++ manakai/lib/Message/Util/DIS/ChangeLog	30 Dec 2006 13:23:58 -0000
	* Perl.dis (plCodeFragment): Support for |f:provides|
	is removed.

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

++ manakai/lib/Message/DOM/ChangeLog	30 Dec 2006 13:22:55 -0000
	* DOMFeature.dis (ForDef): Removed.
	(f:provides, f:through): Removed.
	(Version): Removed.
	(implementFeature): Removed.

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

++ manakai/lib/manakai/ChangeLog	30 Dec 2006 13:25:24 -0000
	* DISIDL.dis, Java.dis, ECMAScript.dis,
	Document.dis, DISPerl.dis, XML.dis (ForDef): Removed.

	* DISMarkup.dis (ForET): Removed.

	* |DefaultFor| properties are removed.

	* DISCore.dis (DefaultFor): Removed.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24