10 struct CommentList *next;
14 invalid_file (char *filename)
16 fprintf (stderr, "Invalid input method file: %s\n", filename);
23 main (int argc, char **argv)
27 MSymbol language, name;
31 struct CommentList *head_comment = NULL, *cur_comment = NULL;
32 MSymbol Minput_method, Mutf8;
34 setlocale (LC_ALL, "");
36 Minput_method = msymbol ("input-method");
37 Mutf8 = msymbol ("utf-8");
41 fprintf (stderr, "Usage: imdoc FILE\n");
44 fp = fopen (argv[1], "r");
47 fprintf (stderr, "Usage: imdoc FILE\n");
50 while (fgets (buf, 256, fp)
53 if (buf[0] == ';' && buf[1] == ';' && buf[2] == ';')
57 cur_comment = head_comment = alloca (sizeof (struct CommentList));
61 cur_comment->next = alloca (sizeof (struct CommentList));
62 cur_comment = cur_comment->next;
64 strcpy (cur_comment->line, buf + 4);
65 cur_comment->next = NULL;
69 invalid_file (argv[1]);
70 mt = mtext_from_data (buf, strlen (buf), MTEXT_FORMAT_US_ASCII);
71 plist = mplist_deserialize (mt);
72 m17n_object_unref (mt);
74 invalid_file (argv[1]);
75 plist = mplist_value (plist);
76 if (mplist_value (plist) != Minput_method)
77 invalid_file (argv[1]);
78 plist = mplist_next (plist);
79 language = mplist_value (plist);
80 plist = mplist_next (plist);
81 name = mplist_value (plist);
82 plist = mplist_next (plist);
83 if (mplist_key (plist) != Mnil)
84 language = mplist_value (plist), name = Mnil;
85 m17n_object_unref (plist);
87 file = basename (strdup (argv[1]));
93 printf ("*/\n/***ja\n<li> %s (language:", file);
95 printf ("generic name:%s", msymbol_name (name));
97 printf ("%s name:%s", msymbol_name (language), msymbol_name (name));
98 printf (")*/\n/***en\n<li> %s (language:", file);
100 printf ("generic name:%s", msymbol_name (name));
102 printf ("%s name:%s", msymbol_name (language), msymbol_name (name));
103 plist = minput_get_title_icon (language, name);
106 MText *title = mplist_value (plist);
108 #ifndef INHIBIT_TITLE
109 printf ("@htmlonly\n title:\"");
111 printf ("@htmlonly\n");
113 plist = mplist_next (plist);
114 #ifndef INHIBIT_TITLE
115 mconv_encode_stream (Mutf8, title, stdout);
118 if (mplist_key (plist) != Mnil)
120 MText *icon = mplist_value (plist);
121 char *iconfile = mtext_data (icon, MTEXT_FORMAT_US_ASCII,
127 base = basename (strdup (iconfile));
128 sprintf (cmd, "convert -resize 50%% %s images/icon-%s",
130 result = system (cmd);
133 fprintf (stderr, "Command fail: %s", cmd);
136 printf (" icon:<img src=\"icon-%s\" border=\"1\" style=\"vertical-align:middle;\">\n", base);
139 printf (" icon:none\n");
140 printf ("@endhtmlonly\n");
142 printf (")*/\n/***\n");
145 printf ("<li> %s (extra-name:%s, only for inclusion)\n", file,
146 msymbol_name (name));
148 mt = minput_get_description (language, name);
151 printf ("Not yet officially released.\n");
154 else if (head_comment)
156 for (; head_comment; head_comment = head_comment->next)
158 char *p = head_comment->line;
160 if (p[0] == '|' && p[1] == '|')
161 printf ("<tr><td align=\"center\">"), p += 2;
167 printf ("</td></tr>"), p += 2;
169 printf ("</td><td align=\"center\">"), p++;
178 int len = mtext_len (mt), i, c;
180 for (i = 0; i < len; i++)
182 c = mtext_ref_char (mt, i);
187 printf ("@htmlonly\n<div class=\"fragment\"><pre class=\"fragment\">\n");
189 printf ("@verbatim\n");
190 mconv_encode_stream (Mutf8, mt, stdout);
191 if (mtext_ref_char (mt, mtext_len (mt) - 1) != '\n')
195 MConverter *converter = mconv_stream_converter (Mutf8, stdout);
198 printf ("</pre></div><p>\n@endhtmlonly\n");
199 printf ("@latexonly\n\\begin{verbatim}\n");
201 mconv_encode_range (converter, mt, 0, i);
202 for (from = i; i < len; i++)
204 c = mtext_ref_char (mt, i);
208 mconv_encode_range (converter, mt, from, i);
209 printf ("U+%04X", c);
214 mconv_encode_range (converter, mt, from, i);
215 printf ("\\end{verbatim}\n@endlatexonly\n");
216 mconv_free_converter (converter);
219 printf ("@endverbatim\n");