/[pub]/suikawiki/script/lib/SuikaWiki/Plugin/WikiView.wp2
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Plugin/WikiView.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Mon Dec 29 13:02:25 2003 UTC (21 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.4: +14 -5 lines
(*/char): Downgrade for old browsers

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiView
5     @Description:
6     @@@: WikiView interface for template context
7     @@lang:en
8     @License: %%GPL%%
9     @Author:
10     @@Name:
11     @@@@: Wakaba
12     @@@lang:ja
13     @@@script:Latn
14     @@Mail[list]: w@suika.fam.cx
15 wakaba 1.5 @Date.RCS: $Date: 2003/12/26 06:34:26 $
16 wakaba 1.3 @Use:
17 wakaba 1.4 use Message::Markup::XML::Node qw(SGML_HEX_CHAR_REF SGML_NCR);
18 wakaba 1.1
19     PluginConst:
20     @NS_XHTML1:
21     http://www.w3.org/1999/xhtml
22    
23     FormattingRule:
24     @Category[list]: view
25     @Name: template
26     @Description:
27     @@@:
28     Instantiate template.
29 wakaba 1.3 \
30 wakaba 1.1 In addition to normal parameters, parameter name prefixed by "-"
31     can be specified to replace "%apply-template (name => (name w/o prefix));"
32     in instantiated template.
33 wakaba 1.3 \
34 wakaba 1.1 Warning: Attemplt to apply template which directly or indirectly referring
35     "parent" template will make a infinite loop.
36     @@lang: en
37     @Parameter:
38     @@Name: name
39     @@Type: name
40     @@Default: #REQUIRED
41     @@Description:
42     @@@@: Template name
43     @@@lang:en
44     @Formatting:
45 wakaba 1.3 local $o->{var}->{wv__children} = $p;
46 wakaba 1.1 my $formatter = $o->formatter ('view');
47 wakaba 1.3 $formatter->replace ($o->{wiki}->{view}->assemble_template ($p->{name}),
48     param => $o, -parent => $p->{-parent});
49 wakaba 1.1
50     FormattingRule:
51     @Category[list]: view
52     @Name: apply-template
53     @Description:
54     @@@:
55     Instantiate template defined as a "-" prefixed parameter of "parent"
56     %template; rule.
57     @@lang: en
58     @Parameter:
59     @@Name: name
60     @@Type: name
61     @@Default: #REQUIRED
62     @@Description:
63     @@@@: Name of parameter defining the template, without "-" prefix
64     @@@lang:en
65     @Formatting:
66     my $template = $o->{var}->{wv__children}->{'_'.$p->{name}};
67     if (length $template) {
68 wakaba 1.3 $o->formatter ('view')->replace ($template,
69     param => $o, -parent => $p->{-parent});
70 wakaba 1.1 }
71    
72     FormattingRule:
73 wakaba 1.3 @Category[list]:
74     view
75     view-resource
76     form-input
77 wakaba 1.1 @Name: -bare-text
78     @Formatting:
79 wakaba 1.3 $p->{-parent}->append_text ($p->{-bare_text});
80    
81     FormattingRule:
82     @Category[list]:
83     view
84     view-resource
85     form-input
86     page-link
87 wakaba 1.4 link-to-wikipage
88 wakaba 1.3 we--edit
89     @Name: -undef
90     @Formatting:
91     $p->{-parent}->append_text
92     ("[$f->{-category_name}/$rule_name: not defined]");
93 wakaba 1.1
94     FormattingRule:
95     @Category[list]:
96     view
97     view-resource
98     page-link
99     @Name: char
100     @Description:
101     @@@:
102     A character
103     @@lang: en
104     @Parameter:
105     @@Name: ucs
106     @@Type: "U+hhhh / U+hhhhhh / U-hhhhhhhh"
107     @@Default: #REQUIRED
108     @@Description:
109     @@@@: UCS code position of the character
110     @@@lang:en
111     @Formatting:
112 wakaba 1.3 __ATTRTEXT:%ucs__;
113 wakaba 1.1 if ($p->{ucs} =~ /^U\+([0-9A-Fa-f]{4,6})$/) {
114 wakaba 1.5 my $char = hex $1;
115     if ($o->{wiki}->{var}->{client}->{downgrade}->{html_no_latin1}
116     and $char <= 0x00FF and 0x00A0 <= $char) {
117     $p->{-parent}->append_text ({
118     0xA0 => ' ',
119     0xA9 => '(C)',
120     }->{$char} || sprintf '&#x%02X;', $char);
121     } else {
122     $p->{-parent}->append_new_node
123     (type => '#reference',
124     namespace_uri => SGML_NCR,
125     value => hex $1);
126     }
127 wakaba 1.4 ## Note: NC4 does not support hexdecimal character reference.
128 wakaba 1.1 } elsif ($p->{ucs} =~ /^U-([0-9A-Fa-f]{8})$/) {
129 wakaba 1.3 $p->{-parent}->append_new_node
130     (type => '#reference',
131     namespace_uri => SGML_HEX_CHAR_REF,
132 wakaba 1.1 value => hex $1);
133     } else {
134 wakaba 1.3 $p->{-parent}->append_new_node
135     (type => '#reference',
136     namespace_uri => SGML_HEX_CHAR_REF,
137     value => 0x0000FFFD);
138 wakaba 1.1 }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24