ein-testing-cell.el 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ;;; ein-testing-cell.el --- Testing utilities for cell module
  2. ;; Copyright (C) 2012 Takafumi Arakaki
  3. ;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
  4. ;; This file is NOT part of GNU Emacs.
  5. ;; ein-testing-cell.el is free software: you can redistribute it
  6. ;; and/or modify it under the terms of the GNU General Public License
  7. ;; as published by the Free Software Foundation, either version 3 of
  8. ;; the License, or (at your option) any later version.
  9. ;; ein-testing-cell.el is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with ein-testing-cell.el.
  15. ;; If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;
  18. ;;; Code:
  19. (require 'json)
  20. (defvar ein:testing-example-svg "\
  21. <?xml version=\"1.0\" standalone=\"no\"?>
  22. <!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"
  23. \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">
  24. <svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">
  25. <circle cx=\"100\" cy=\"50\" r=\"40\" />
  26. </svg>")
  27. (defun ein:testing-codecell-pyout-data (text &optional prompt-number)
  28. "Create a plist representing JSON data for code-cell output.
  29. TEXT is a string and PROMPT-NUMBER is an integer."
  30. (list :output_type "pyout"
  31. :prompt_number (or prompt-number 0)
  32. :text text))
  33. (defun ein:testing-codecell-data (&optional input prompt-number outputs)
  34. "Create a plist representing JSON data for code-type cell.
  35. To make OUTPUTS data, use `ein:testing-codecell-pyout-data'."
  36. (list :cell_type "code"
  37. :input (or input "")
  38. :language "python"
  39. :outputs outputs
  40. :collapsed json-false
  41. :prompt_number prompt-number))
  42. (defun ein:testing-textcell-data (&optional source cell-type)
  43. (list :cell_type cell-type
  44. :source (or source "")))
  45. (defun ein:testing-markdowncell-data (&optional source)
  46. (ein:testing-textcell-data source "markdown"))
  47. (defun ein:testing-rawcell-data (&optional source)
  48. (ein:testing-textcell-data source "raw"))
  49. (defun ein:testing-htmlcell-data (&optional source)
  50. (ein:testing-textcell-data source "html"))
  51. (defun ein:testing-headingcell-data (&optional source level)
  52. (append (ein:testing-textcell-data source "heading")
  53. (list :level (or level 1))))
  54. (provide 'ein-testing-cell)
  55. ;;; ein-testing-cell.el ends here