Prechádzať zdrojové kódy

Merge branch 'maint'

Bastien Guerry 3 rokov pred
rodič
commit
97a2022382
2 zmenil súbory, kde vykonal 43 pridanie a 23 odobranie
  1. 34 16
      lisp/ob-C.el
  2. 9 7
      lisp/ox-html.el

+ 34 - 16
lisp/ob-C.el

@@ -342,7 +342,9 @@ FORMAT can be either a format string or a function which is called with VAL."
       `(,(car type)
 	(lambda (val)
 	  (cons
-	   (format "[%d][%d]" (length val) (length (car val)))
+           (pcase org-babel-c-variant
+             ((or `c `cpp) (format "[%d][%d]" (length val) (length (car val))))
+             (`d           (format "[%d][%d]" (length (car val)) (length val))))
 	   (concat
 	    (if (eq org-babel-c-variant 'd) "[\n" "{\n")
 	    (mapconcat
@@ -403,11 +405,23 @@ of the same value."
 	   (formatted (org-babel-C-format-val type-data val))
 	   (suffix (car formatted))
 	   (data (cdr formatted)))
-      (format "%s %s%s = %s;"
-	      type
-	      var
-	      suffix
-	      data))))
+      (pcase org-babel-c-variant
+        ((or `c `cpp)
+         (format "%s\n%s"
+	         (format "typedef %s %s_type;" type var)
+                 (format "%s %s%s = %s;"
+	                 type
+	                 var
+	                 suffix
+	                 data)))
+        (`d
+         (format "%s\n%s"
+                 (format "alias %s_type = %s;" var type)
+                 (format "%s%s %s = %s;"
+	              type
+	              suffix
+	              var
+	              data)))))))
 
 (defun org-babel-C-table-sizes-to-C (pair)
   "Create constants of table dimensions, if PAIR is a table."
@@ -456,23 +470,27 @@ specifying a variable with the name of the table."
   (let ((table (car head))
         (headers (cdr head)))
     (concat
-     (format
       (pcase org-babel-c-variant
-	((or `c `cpp) "const char* %s_header[%d] = {%s};")
-	(`d "string %s_header[%d] = [%s];"))
-      table
-      (length headers)
-      (mapconcat (lambda (h) (format "%S" h)) headers ","))
+	((or `c `cpp)
+         (format "const char* %s_header[%d] = {%s};"
+                 table
+                 (length headers)
+                 (mapconcat (lambda (h) (format "%S" h)) headers ",")))
+	(`d
+         (format "string[%d] %s_header = [%s];"
+                 (length headers)
+                 table
+                 (mapconcat (lambda (h) (format "%S" h)) headers ","))))
      "\n"
      (pcase org-babel-c-variant
        ((or `c `cpp)
 	(format
-	 "const char* %s_h (int row, const char* col) { return %s[row][get_column_num(%d,%s_header,col)]; }"
-	 table table (length headers) table))
+	 "%s_type %s_h (int row, const char* col) { return %s[row][get_column_num(%d,%s_header,col)]; }"
+	 table table table (length headers) table))
        (`d
 	(format
-	 "string %s_h (size_t row, string col) { return %s[row][get_column_num(%s_header,col)]; }"
-	 table table table))))))
+	 "%s_type %s_h (size_t row, string col) { return %s[row][get_column_num(%s_header,col)]; }"
+	 table table table table))))))
 
 (provide 'ob-C)
 

+ 9 - 7
lisp/ox-html.el

@@ -234,23 +234,25 @@ property on the headline itself.")
 
 (defconst org-html-scripts
   "<script type=\"text/javascript\">
-// @license magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt Public Domain
+// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&amp;dn=gpl-3.0.txt GPL-v3-or-Later
 <!--/*--><![CDATA[/*><!--*/
      function CodeHighlightOn(elem, id)
      {
        var target = document.getElementById(id);
        if(null != target) {
-         elem.classList.add(\"code-highlighted\");
-         target.classList.add(\"code-highlighted\");
+         elem.cacheClassElem = elem.className;
+         elem.cacheClassTarget = target.className;
+         target.className = \"code-highlighted\";
+         elem.className   = \"code-highlighted\";
        }
      }
      function CodeHighlightOff(elem, id)
      {
        var target = document.getElementById(id);
-       if(null != target) {
-         elem.classList.remove(\"code-highlighted\");
-         target.classList.remove(\"code-highlighted\");
-       }
+       if(elem.cacheClassElem)
+         elem.className = elem.cacheClassElem;
+       if(elem.cacheClassTarget)
+         target.className = elem.cacheClassTarget;
      }
     /*]]>*///-->
 // @license-end