/[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.2 - (hide annotations) (download)
Fri May 5 09:07:19 2006 UTC (18 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +917 -116 lines
++ manakai/lib/Message/Markup/ChangeLog	5 May 2006 09:06:04 -0000
2006-05-05  Wakaba  <wakaba@suika.fam.cx>

	* SuikaWiki.dis: SuikaWiki/0.9, SuikaWikiImage/0.9, and
	SuikaWiki/0.10 parsing is implemented.

++ manakai/lib/Message/Util/DIS/ChangeLog	5 May 2006 09:07:13 -0000
2006-05-05  Wakaba  <wakaba@suika.fam.cx>

	* DPG.dis: A |cloneNode| operation was missing.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24