/[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.10 - (hide annotations) (download)
Sun Dec 31 00:55:05 2006 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0, HEAD
Changes since 1.9: +1 -4 lines
++ manakai/lib/Message/Util/ChangeLog	31 Dec 2006 00:49:10 -0000
2006-12-31  Wakaba  <wakaba@suika.fam.cx>

	* DIS.dis (forMatch, readProperties): Support for the |For|
	property is removed.

++ manakai/lib/Message/Util/DIS/ChangeLog	31 Dec 2006 00:50:06 -0000
2006-12-31  Wakaba  <wakaba@suika.fam.cx>

	* DNLite.dis (forMatch, convert...): Support for the |For|
	property is removed.

++ manakai/lib/manakai/ChangeLog	31 Dec 2006 00:53:00 -0000
2006-12-31  Wakaba  <wakaba@suika.fam.cx>

	* DISCore.dis (for): Removed.

	* DISSource.dis (For): Removed.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24