OSDN Git Service

update the wiki image tag.
authorvisor <visor@users.sourceforge.jp>
Tue, 11 Jun 2013 14:49:26 +0000 (23:49 +0900)
committervisor <visor@users.sourceforge.jp>
Tue, 11 Jun 2013 14:49:26 +0000 (23:49 +0900)
update wiki functions.

modules/ml-encode.cc
modules/ml-encode.h
modules/ml-wiki.cc
modules/ml-wiki.h
wiki/wikiattrib.cc

index 065c135..bc76bea 100644 (file)
@@ -99,6 +99,45 @@ MNode*  ml_decode_control_char (MNode* cell, MlEnv* mlenv) {
 }
 
 /*DOC:
+===escape-wiki===
+ (escape-wiki STRING ...) -> STRING
+
+*/
+//#AFUNC       escape-wiki     ml_escape_wiki
+//#WIKIFUNC    escape-wiki
+MNode*  ml_escape_wiki (MNode* cell, MlEnv* mlenv) {
+    MNode*  arg = cell->cdr ();
+    ustring  text;
+    ustring  ans;
+    uiterator  b, e;
+    umatch  m;
+    static uregex  re ("([\\[\\]&|:])|(\n)");
+
+    while (arg) {
+       text.append (eval_str (arg->car (), mlenv));
+       nextNode (arg);
+    }
+    b = text.begin ();
+    e = text.end ();
+    while (b < e && usearch (b, e, m, re)) {
+       if (b < m[0].first)
+           ans.append (b, m[0].first);
+       if (m[1].matched) {
+           ans.append (uAmp).append (m[1].first, m[1].second).append (CharConst (";"));
+       } else if (m[2].matched) {
+           ans.append (uSPC);
+       } else {
+           assert (0);
+       }
+       b = m[0].second;
+    }
+    if (b < e)
+       ans.append (b, e);
+
+    return newMNode_str (new ustring (ans));
+}
+
+/*DOC:
 ===escape-wiki-q===
 // (escape-wiki STRING ...) -> STRING
  (escape-wiki-q STRING ...) -> STRING
index e65bb01..ac4f32f 100644 (file)
@@ -8,6 +8,7 @@ MNode*  ml_js (MNode* cell, MlEnv* mlenv);
 MNode*  ml_escape_regexp (MNode* cell, MlEnv* mlenv);
 MNode*  ml_encode_control_char (MNode* cell, MlEnv* mlenv);
 MNode*  ml_decode_control_char (MNode* cell, MlEnv* mlenv);
+MNode*  ml_escape_wiki (MNode* cell, MlEnv* mlenv);
 MNode*  ml_escape_wiki_q (MNode* cell, MlEnv* mlenv);
 MNode*  ml_percent_encode (MNode* cell, MlEnv* mlenv);
 MNode*  ml_percent_decode (MNode* cell, MlEnv* mlenv);
index e181686..2d1eb8a 100644 (file)
@@ -9,6 +9,8 @@
 #include "ustring.h"
 #include <exception>
 
+static ustring  kGuestuserFunction (CharConst ("guestuser-function"));
+
 /*DOC:
 ==wiki processing==
 
@@ -286,6 +288,20 @@ MNode*  ml_wiki_guestuser_function (MNode* cell, MlEnv* mlenv) {
 }
 
 /*DOC:
+===guestuser-function===
+ (guestuser-function) -> NIL
+
+*/
+//#AFUNC       guestuser-function      ml_guestuser_function
+MNode*  ml_guestuser_function (MNode* cell, MlEnv* mlenv) {
+    MNode*  arg = cell->cdr ();
+    if (arg)
+       throw (uErrorWrongNumber);
+
+    return NULL;
+}
+
+/*DOC:
 ===wiki-output===
  (wiki-output TEXT... [#flush | :flush BOOL]) -> NIL
 
index 071f2c4..7f05171 100644 (file)
@@ -14,6 +14,7 @@ MNode*  ml_defun_wiki_link (MNode* cell, MlEnv* mlenv);
 MNode*  ml_defun_wiki_command (MNode* cell, MlEnv* mlenv);
 MNode*  ml_get_wiki_command (MNode* cell, MlEnv* mlenv);
 MNode*  ml_wiki_guestuser_function (MNode* cell, MlEnv* mlenv);
+MNode*  ml_guestuser_function (MNode* cell, MlEnv* mlenv);
 MNode*  ml_wiki_output (MNode* cell, MlEnv* mlenv);
 
 #endif /* ML_WIKI_H */
index a0f9260..6e99e05 100644 (file)
@@ -578,7 +578,11 @@ void  WikiAttribTable::outputMore (MotorOutput* out) {
 /* ============================================================ */
 bool  WikiAttribImg::readAttribMore (const ustring& key, WikiMotorObjVec& vval, bool& ferr) {
     if (paramWidth (key, vval, width, ferr)) {
+       if (checkNum (width))
+           width.append (CharConst ("px"));
     } else if (paramHeight (key, vval, height, ferr)) {
+       if (checkNum (height))
+           height.append (CharConst ("px"));
     } else if (match (key, CharConst ("alt"))) {
        alt = vval.textOut (wiki);
     } else {
@@ -588,8 +592,16 @@ bool  WikiAttribImg::readAttribMore (const ustring& key, WikiMotorObjVec& vval,
 }
 
 void  WikiAttribImg::outputMore (MotorOutput* out) {
-    wiki->outputName (out, CharConst ("width"), width);
-    wiki->outputName (out, CharConst ("height"), height);
+//    wiki->outputName (out, CharConst ("width"), width);
+//    wiki->outputName (out, CharConst ("height"), height);
+    if (width.length () > 0 || height.length () > 0) {
+       out->out_raw (CharConst (" style=\""));
+       if (width.length () > 0)
+           out->out_raw (CharConst ("width:"))->out_toHTML_noCtrl (width)->out_raw (CharConst (";"));
+       if (height.length () > 0)
+           out->out_raw (CharConst ("height:"))->out_toHTML_noCtrl (height)->out_raw (CharConst (";"));
+       out->out_raw (CharConst ("\""));
+    }
     // longdesc
 }