administrate-field-simple_mde_markdown 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (419) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +72 -0
  3. data/.circleci/setup-rubygems.sh +3 -0
  4. data/.gitignore +11 -0
  5. data/.rspec +3 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +8 -0
  8. data/Gemfile.lock +196 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +44 -0
  11. data/Rakefile +8 -0
  12. data/administrate-field-simple_mde_markdown.gemspec +31 -0
  13. data/app/assets/javascripts/administrate-field-simple_mde_markdown/application.js +6 -0
  14. data/app/assets/stylesheets/administrate-field-simple_mde_markdown/application.css +3 -0
  15. data/app/views/fields/simple_mde_markdown/_form.html.erb +6 -0
  16. data/app/views/fields/simple_mde_markdown/_index.html.erb +1 -0
  17. data/app/views/fields/simple_mde_markdown/_show.html.erb +1 -0
  18. data/lib/administrate/field/simple_mde_markdown.rb +31 -0
  19. data/node_modules/.bin/marked +1 -0
  20. data/node_modules/codemirror-spell-checker/.eslintrc +23 -0
  21. data/node_modules/codemirror-spell-checker/.npmignore +2 -0
  22. data/node_modules/codemirror-spell-checker/.travis.yml +18 -0
  23. data/node_modules/codemirror-spell-checker/CONTRIBUTING 2.md +10 -0
  24. data/node_modules/codemirror-spell-checker/CONTRIBUTING.md +10 -0
  25. data/node_modules/codemirror-spell-checker/LICENSE +22 -0
  26. data/node_modules/codemirror-spell-checker/README.md +50 -0
  27. data/node_modules/codemirror-spell-checker/bower.json +27 -0
  28. data/node_modules/codemirror-spell-checker/debug/.spell-checker 2.css.icloud +0 -0
  29. data/node_modules/codemirror-spell-checker/debug/spell-checker.css +9 -0
  30. data/node_modules/codemirror-spell-checker/debug/spell-checker.debug.js +2844 -0
  31. data/node_modules/codemirror-spell-checker/debug/spell-checker.js +2841 -0
  32. data/node_modules/codemirror-spell-checker/dist/.spell-checker.min 2.css.icloud +0 -0
  33. data/node_modules/codemirror-spell-checker/dist/en_US.aff +201 -0
  34. data/node_modules/codemirror-spell-checker/dist/en_US.dic +62120 -0
  35. data/node_modules/codemirror-spell-checker/dist/spell-checker.min 2.js +7 -0
  36. data/node_modules/codemirror-spell-checker/dist/spell-checker.min.css +7 -0
  37. data/node_modules/codemirror-spell-checker/dist/spell-checker.min.js +7 -0
  38. data/node_modules/codemirror-spell-checker/gulpfile.js +94 -0
  39. data/node_modules/codemirror-spell-checker/package.json +75 -0
  40. data/node_modules/codemirror-spell-checker/src/css/spell-checker.css +3 -0
  41. data/node_modules/codemirror-spell-checker/src/data/en_US.aff +201 -0
  42. data/node_modules/codemirror-spell-checker/src/data/en_US.dic +62120 -0
  43. data/node_modules/codemirror-spell-checker/src/js/spell-checker.js +119 -0
  44. data/node_modules/codemirror/.package 2.json.icloud +0 -0
  45. data/node_modules/codemirror/AUTHORS +773 -0
  46. data/node_modules/codemirror/CHANGELOG.md +1486 -0
  47. data/node_modules/codemirror/CONTRIBUTING.md +92 -0
  48. data/node_modules/codemirror/LICENSE +21 -0
  49. data/node_modules/codemirror/README.md +49 -0
  50. data/node_modules/codemirror/addon/comment/comment.js +209 -0
  51. data/node_modules/codemirror/addon/comment/continuecomment.js +78 -0
  52. data/node_modules/codemirror/addon/dialog/dialog.css +32 -0
  53. data/node_modules/codemirror/addon/dialog/dialog.js +161 -0
  54. data/node_modules/codemirror/addon/display/autorefresh.js +47 -0
  55. data/node_modules/codemirror/addon/display/fullscreen.css +6 -0
  56. data/node_modules/codemirror/addon/display/fullscreen.js +41 -0
  57. data/node_modules/codemirror/addon/display/panel.js +127 -0
  58. data/node_modules/codemirror/addon/display/placeholder.js +63 -0
  59. data/node_modules/codemirror/addon/display/rulers.js +51 -0
  60. data/node_modules/codemirror/addon/edit/closebrackets.js +187 -0
  61. data/node_modules/codemirror/addon/edit/closetag.js +175 -0
  62. data/node_modules/codemirror/addon/edit/continuelist.js +89 -0
  63. data/node_modules/codemirror/addon/edit/matchbrackets.js +145 -0
  64. data/node_modules/codemirror/addon/edit/matchtags.js +66 -0
  65. data/node_modules/codemirror/addon/edit/trailingspace.js +27 -0
  66. data/node_modules/codemirror/addon/fold/brace-fold.js +105 -0
  67. data/node_modules/codemirror/addon/fold/comment-fold.js +59 -0
  68. data/node_modules/codemirror/addon/fold/foldcode.js +152 -0
  69. data/node_modules/codemirror/addon/fold/foldgutter.css +20 -0
  70. data/node_modules/codemirror/addon/fold/foldgutter.js +146 -0
  71. data/node_modules/codemirror/addon/fold/indent-fold.js +48 -0
  72. data/node_modules/codemirror/addon/fold/markdown-fold.js +49 -0
  73. data/node_modules/codemirror/addon/fold/xml-fold.js +184 -0
  74. data/node_modules/codemirror/addon/hint/anyword-hint.js +41 -0
  75. data/node_modules/codemirror/addon/hint/css-hint.js +60 -0
  76. data/node_modules/codemirror/addon/hint/html-hint.js +348 -0
  77. data/node_modules/codemirror/addon/hint/javascript-hint.js +157 -0
  78. data/node_modules/codemirror/addon/hint/show-hint.css +36 -0
  79. data/node_modules/codemirror/addon/hint/show-hint.js +434 -0
  80. data/node_modules/codemirror/addon/hint/sql-hint.js +299 -0
  81. data/node_modules/codemirror/addon/hint/xml-hint.js +110 -0
  82. data/node_modules/codemirror/addon/lint/coffeescript-lint.js +47 -0
  83. data/node_modules/codemirror/addon/lint/css-lint.js +40 -0
  84. data/node_modules/codemirror/addon/lint/html-lint.js +53 -0
  85. data/node_modules/codemirror/addon/lint/javascript-lint.js +63 -0
  86. data/node_modules/codemirror/addon/lint/json-lint.js +40 -0
  87. data/node_modules/codemirror/addon/lint/lint.css +73 -0
  88. data/node_modules/codemirror/addon/lint/lint.js +252 -0
  89. data/node_modules/codemirror/addon/lint/yaml-lint.js +41 -0
  90. data/node_modules/codemirror/addon/merge/merge.css +119 -0
  91. data/node_modules/codemirror/addon/merge/merge.js +1002 -0
  92. data/node_modules/codemirror/addon/mode/loadmode.js +64 -0
  93. data/node_modules/codemirror/addon/mode/multiplex.js +131 -0
  94. data/node_modules/codemirror/addon/mode/multiplex_test.js +33 -0
  95. data/node_modules/codemirror/addon/mode/overlay.js +90 -0
  96. data/node_modules/codemirror/addon/mode/simple.js +216 -0
  97. data/node_modules/codemirror/addon/runmode/colorize.js +40 -0
  98. data/node_modules/codemirror/addon/runmode/runmode-standalone.js +158 -0
  99. data/node_modules/codemirror/addon/runmode/runmode.js +72 -0
  100. data/node_modules/codemirror/addon/runmode/runmode.node.js +197 -0
  101. data/node_modules/codemirror/addon/scroll/annotatescrollbar.js +122 -0
  102. data/node_modules/codemirror/addon/scroll/scrollpastend.js +48 -0
  103. data/node_modules/codemirror/addon/scroll/simplescrollbars.css +66 -0
  104. data/node_modules/codemirror/addon/scroll/simplescrollbars.js +152 -0
  105. data/node_modules/codemirror/addon/search/jump-to-line.js +50 -0
  106. data/node_modules/codemirror/addon/search/match-highlighter.js +165 -0
  107. data/node_modules/codemirror/addon/search/matchesonscrollbar.css +8 -0
  108. data/node_modules/codemirror/addon/search/matchesonscrollbar.js +97 -0
  109. data/node_modules/codemirror/addon/search/search.js +258 -0
  110. data/node_modules/codemirror/addon/search/searchcursor.js +293 -0
  111. data/node_modules/codemirror/addon/selection/active-line.js +72 -0
  112. data/node_modules/codemirror/addon/selection/mark-selection.js +119 -0
  113. data/node_modules/codemirror/addon/selection/selection-pointer.js +98 -0
  114. data/node_modules/codemirror/addon/tern/tern.css +87 -0
  115. data/node_modules/codemirror/addon/tern/tern.js +718 -0
  116. data/node_modules/codemirror/addon/tern/worker.js +44 -0
  117. data/node_modules/codemirror/addon/wrap/hardwrap.js +145 -0
  118. data/node_modules/codemirror/bin/source-highlight +48 -0
  119. data/node_modules/codemirror/keymap/emacs.js +417 -0
  120. data/node_modules/codemirror/keymap/sublime.js +691 -0
  121. data/node_modules/codemirror/keymap/vim.js +5467 -0
  122. data/node_modules/codemirror/lib/codemirror.css +346 -0
  123. data/node_modules/codemirror/lib/codemirror.js +9698 -0
  124. data/node_modules/codemirror/mode/apl/apl.js +174 -0
  125. data/node_modules/codemirror/mode/asciiarmor/asciiarmor.js +74 -0
  126. data/node_modules/codemirror/mode/asn.1/asn.1.js +204 -0
  127. data/node_modules/codemirror/mode/asterisk/asterisk.js +196 -0
  128. data/node_modules/codemirror/mode/brainfuck/brainfuck.js +85 -0
  129. data/node_modules/codemirror/mode/clike/clike.js +879 -0
  130. data/node_modules/codemirror/mode/clojure/clojure.js +292 -0
  131. data/node_modules/codemirror/mode/cmake/cmake.js +97 -0
  132. data/node_modules/codemirror/mode/cobol/cobol.js +255 -0
  133. data/node_modules/codemirror/mode/coffeescript/coffeescript.js +359 -0
  134. data/node_modules/codemirror/mode/commonlisp/commonlisp.js +124 -0
  135. data/node_modules/codemirror/mode/crystal/crystal.js +433 -0
  136. data/node_modules/codemirror/mode/css/css.js +832 -0
  137. data/node_modules/codemirror/mode/cypher/cypher.js +150 -0
  138. data/node_modules/codemirror/mode/d/d.js +223 -0
  139. data/node_modules/codemirror/mode/dart/dart.js +157 -0
  140. data/node_modules/codemirror/mode/diff/diff.js +47 -0
  141. data/node_modules/codemirror/mode/django/django.js +356 -0
  142. data/node_modules/codemirror/mode/dockerfile/dockerfile.js +211 -0
  143. data/node_modules/codemirror/mode/dtd/dtd.js +142 -0
  144. data/node_modules/codemirror/mode/dylan/dylan.js +352 -0
  145. data/node_modules/codemirror/mode/ebnf/ebnf.js +195 -0
  146. data/node_modules/codemirror/mode/ecl/ecl.js +206 -0
  147. data/node_modules/codemirror/mode/eiffel/eiffel.js +160 -0
  148. data/node_modules/codemirror/mode/elm/elm.js +205 -0
  149. data/node_modules/codemirror/mode/erlang/erlang.js +619 -0
  150. data/node_modules/codemirror/mode/factor/factor.js +85 -0
  151. data/node_modules/codemirror/mode/fcl/fcl.js +173 -0
  152. data/node_modules/codemirror/mode/forth/forth.js +180 -0
  153. data/node_modules/codemirror/mode/fortran/fortran.js +188 -0
  154. data/node_modules/codemirror/mode/gas/gas.js +345 -0
  155. data/node_modules/codemirror/mode/gfm/gfm.js +129 -0
  156. data/node_modules/codemirror/mode/gherkin/gherkin.js +178 -0
  157. data/node_modules/codemirror/mode/go/go.js +187 -0
  158. data/node_modules/codemirror/mode/groovy/groovy.js +230 -0
  159. data/node_modules/codemirror/mode/haml/haml.js +161 -0
  160. data/node_modules/codemirror/mode/handlebars/handlebars.js +66 -0
  161. data/node_modules/codemirror/mode/haskell-literate/haskell-literate.js +43 -0
  162. data/node_modules/codemirror/mode/haskell/haskell.js +268 -0
  163. data/node_modules/codemirror/mode/haxe/haxe.js +515 -0
  164. data/node_modules/codemirror/mode/htmlembedded/htmlembedded.js +37 -0
  165. data/node_modules/codemirror/mode/htmlmixed/htmlmixed.js +152 -0
  166. data/node_modules/codemirror/mode/http/http.js +113 -0
  167. data/node_modules/codemirror/mode/idl/idl.js +290 -0
  168. data/node_modules/codemirror/mode/javascript/javascript.js +899 -0
  169. data/node_modules/codemirror/mode/jinja2/jinja2.js +144 -0
  170. data/node_modules/codemirror/mode/jsx/jsx.js +148 -0
  171. data/node_modules/codemirror/mode/julia/julia.js +433 -0
  172. data/node_modules/codemirror/mode/livescript/livescript.js +280 -0
  173. data/node_modules/codemirror/mode/lua/lua.js +159 -0
  174. data/node_modules/codemirror/mode/markdown/markdown.js +884 -0
  175. data/node_modules/codemirror/mode/mathematica/mathematica.js +176 -0
  176. data/node_modules/codemirror/mode/mbox/mbox.js +129 -0
  177. data/node_modules/codemirror/mode/meta.js +217 -0
  178. data/node_modules/codemirror/mode/mirc/mirc.js +193 -0
  179. data/node_modules/codemirror/mode/mllike/mllike.js +359 -0
  180. data/node_modules/codemirror/mode/modelica/modelica.js +245 -0
  181. data/node_modules/codemirror/mode/mscgen/mscgen.js +175 -0
  182. data/node_modules/codemirror/mode/mumps/mumps.js +148 -0
  183. data/node_modules/codemirror/mode/nginx/nginx.js +178 -0
  184. data/node_modules/codemirror/mode/nsis/nsis.js +95 -0
  185. data/node_modules/codemirror/mode/ntriples/ntriples.js +195 -0
  186. data/node_modules/codemirror/mode/octave/octave.js +139 -0
  187. data/node_modules/codemirror/mode/oz/oz.js +252 -0
  188. data/node_modules/codemirror/mode/pascal/pascal.js +121 -0
  189. data/node_modules/codemirror/mode/pegjs/pegjs.js +114 -0
  190. data/node_modules/codemirror/mode/perl/perl.js +837 -0
  191. data/node_modules/codemirror/mode/php/php.js +234 -0
  192. data/node_modules/codemirror/mode/pig/pig.js +178 -0
  193. data/node_modules/codemirror/mode/powershell/powershell.js +398 -0
  194. data/node_modules/codemirror/mode/properties/properties 2.js +78 -0
  195. data/node_modules/codemirror/mode/properties/properties.js +78 -0
  196. data/node_modules/codemirror/mode/protobuf/protobuf.js +69 -0
  197. data/node_modules/codemirror/mode/pug/pug.js +591 -0
  198. data/node_modules/codemirror/mode/puppet/puppet.js +220 -0
  199. data/node_modules/codemirror/mode/python/python.js +409 -0
  200. data/node_modules/codemirror/mode/q/q.js +139 -0
  201. data/node_modules/codemirror/mode/r/r.js +190 -0
  202. data/node_modules/codemirror/mode/rpm/changes/index.html +66 -0
  203. data/node_modules/codemirror/mode/rpm/rpm.js +109 -0
  204. data/node_modules/codemirror/mode/rst/rst.js +557 -0
  205. data/node_modules/codemirror/mode/ruby/ruby.js +296 -0
  206. data/node_modules/codemirror/mode/rust/rust.js +72 -0
  207. data/node_modules/codemirror/mode/sas/sas.js +303 -0
  208. data/node_modules/codemirror/mode/sass/sass.js +454 -0
  209. data/node_modules/codemirror/mode/scheme/scheme.js +265 -0
  210. data/node_modules/codemirror/mode/shell/shell.js +152 -0
  211. data/node_modules/codemirror/mode/sieve/sieve.js +193 -0
  212. data/node_modules/codemirror/mode/slim/slim.js +575 -0
  213. data/node_modules/codemirror/mode/smalltalk/smalltalk.js +168 -0
  214. data/node_modules/codemirror/mode/smarty/smarty.js +225 -0
  215. data/node_modules/codemirror/mode/solr/solr.js +104 -0
  216. data/node_modules/codemirror/mode/soy/soy 2.js +359 -0
  217. data/node_modules/codemirror/mode/soy/soy.js +235 -0
  218. data/node_modules/codemirror/mode/sparql/sparql.js +180 -0
  219. data/node_modules/codemirror/mode/spreadsheet/spreadsheet.js +112 -0
  220. data/node_modules/codemirror/mode/sql/sql.js +499 -0
  221. data/node_modules/codemirror/mode/stex/stex.js +264 -0
  222. data/node_modules/codemirror/mode/stylus/stylus.js +771 -0
  223. data/node_modules/codemirror/mode/swift/swift.js +219 -0
  224. data/node_modules/codemirror/mode/tcl/tcl.js +139 -0
  225. data/node_modules/codemirror/mode/textile/textile.js +469 -0
  226. data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
  227. data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.js +308 -0
  228. data/node_modules/codemirror/mode/tiki/tiki.css +26 -0
  229. data/node_modules/codemirror/mode/tiki/tiki.js +312 -0
  230. data/node_modules/codemirror/mode/toml/toml.js +88 -0
  231. data/node_modules/codemirror/mode/tornado/tornado.js +68 -0
  232. data/node_modules/codemirror/mode/troff/troff.js +84 -0
  233. data/node_modules/codemirror/mode/ttcn-cfg/ttcn-cfg.js +214 -0
  234. data/node_modules/codemirror/mode/ttcn/ttcn.js +283 -0
  235. data/node_modules/codemirror/mode/turtle/turtle.js +162 -0
  236. data/node_modules/codemirror/mode/twig/twig.js +141 -0
  237. data/node_modules/codemirror/mode/vb/vb.js +275 -0
  238. data/node_modules/codemirror/mode/vbscript/vbscript.js +350 -0
  239. data/node_modules/codemirror/mode/velocity/velocity.js +201 -0
  240. data/node_modules/codemirror/mode/verilog/verilog.js +675 -0
  241. data/node_modules/codemirror/mode/vhdl/vhdl.js +189 -0
  242. data/node_modules/codemirror/mode/vue/vue.js +77 -0
  243. data/node_modules/codemirror/mode/webidl/webidl.js +195 -0
  244. data/node_modules/codemirror/mode/xml/xml.js +402 -0
  245. data/node_modules/codemirror/mode/xquery/xquery.js +448 -0
  246. data/node_modules/codemirror/mode/yacas/yacas.js +204 -0
  247. data/node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +68 -0
  248. data/node_modules/codemirror/mode/yaml/yaml.js +120 -0
  249. data/node_modules/codemirror/mode/z80/z80.js +116 -0
  250. data/node_modules/codemirror/package.json +2395 -0
  251. data/node_modules/codemirror/rollup.config.js +20 -0
  252. data/node_modules/codemirror/src/codemirror.js +3 -0
  253. data/node_modules/codemirror/src/display/Display.js +106 -0
  254. data/node_modules/codemirror/src/display/focus.js +47 -0
  255. data/node_modules/codemirror/src/display/gutters.js +34 -0
  256. data/node_modules/codemirror/src/display/highlight_worker.js +55 -0
  257. data/node_modules/codemirror/src/display/line_numbers.js +48 -0
  258. data/node_modules/codemirror/src/display/mode_state.js +22 -0
  259. data/node_modules/codemirror/src/display/operations.js +205 -0
  260. data/node_modules/codemirror/src/display/scroll_events.js +115 -0
  261. data/node_modules/codemirror/src/display/scrollbars.js +193 -0
  262. data/node_modules/codemirror/src/display/scrolling.js +184 -0
  263. data/node_modules/codemirror/src/display/selection.js +158 -0
  264. data/node_modules/codemirror/src/display/update_display.js +260 -0
  265. data/node_modules/codemirror/src/display/update_line.js +188 -0
  266. data/node_modules/codemirror/src/display/update_lines.js +64 -0
  267. data/node_modules/codemirror/src/display/view_tracking.js +153 -0
  268. data/node_modules/codemirror/src/edit/CodeMirror.js +215 -0
  269. data/node_modules/codemirror/src/edit/commands.js +178 -0
  270. data/node_modules/codemirror/src/edit/deleteNearSelection.js +30 -0
  271. data/node_modules/codemirror/src/edit/drop_events.js +119 -0
  272. data/node_modules/codemirror/src/edit/fromTextArea.js +61 -0
  273. data/node_modules/codemirror/src/edit/global_events.js +42 -0
  274. data/node_modules/codemirror/src/edit/key_events.js +159 -0
  275. data/node_modules/codemirror/src/edit/legacy.js +62 -0
  276. data/node_modules/codemirror/src/edit/main.js +69 -0
  277. data/node_modules/codemirror/src/edit/methods.js +544 -0
  278. data/node_modules/codemirror/src/edit/mouse_events.js +407 -0
  279. data/node_modules/codemirror/src/edit/options.js +193 -0
  280. data/node_modules/codemirror/src/edit/utils.js +7 -0
  281. data/node_modules/codemirror/src/input/ContentEditableInput.js +527 -0
  282. data/node_modules/codemirror/src/input/TextareaInput.js +355 -0
  283. data/node_modules/codemirror/src/input/indent.js +71 -0
  284. data/node_modules/codemirror/src/input/input.js +135 -0
  285. data/node_modules/codemirror/src/input/keymap.js +148 -0
  286. data/node_modules/codemirror/src/input/keynames.js +17 -0
  287. data/node_modules/codemirror/src/input/movement.js +110 -0
  288. data/node_modules/codemirror/src/line/highlight.js +284 -0
  289. data/node_modules/codemirror/src/line/line_data.js +339 -0
  290. data/node_modules/codemirror/src/line/pos.js +40 -0
  291. data/node_modules/codemirror/src/line/saw_special_spans.js +10 -0
  292. data/node_modules/codemirror/src/line/spans.js +382 -0
  293. data/node_modules/codemirror/src/line/utils_line.js +85 -0
  294. data/node_modules/codemirror/src/measurement/position_measurement.js +699 -0
  295. data/node_modules/codemirror/src/measurement/widgets.js +26 -0
  296. data/node_modules/codemirror/src/model/Doc.js +432 -0
  297. data/node_modules/codemirror/src/model/change_measurement.js +61 -0
  298. data/node_modules/codemirror/src/model/changes.js +333 -0
  299. data/node_modules/codemirror/src/model/chunk.js +167 -0
  300. data/node_modules/codemirror/src/model/document_data.js +111 -0
  301. data/node_modules/codemirror/src/model/history.js +228 -0
  302. data/node_modules/codemirror/src/model/line_widget.js +78 -0
  303. data/node_modules/codemirror/src/model/mark_text.js +292 -0
  304. data/node_modules/codemirror/src/model/selection.js +84 -0
  305. data/node_modules/codemirror/src/model/selection_updates.js +208 -0
  306. data/node_modules/codemirror/src/modes.js +96 -0
  307. data/node_modules/codemirror/src/util/StringStream.js +90 -0
  308. data/node_modules/codemirror/src/util/bidi.js +214 -0
  309. data/node_modules/codemirror/src/util/browser.js +33 -0
  310. data/node_modules/codemirror/src/util/dom.js +97 -0
  311. data/node_modules/codemirror/src/util/event.js +103 -0
  312. data/node_modules/codemirror/src/util/feature_detection.js +84 -0
  313. data/node_modules/codemirror/src/util/misc.js +150 -0
  314. data/node_modules/codemirror/src/util/operation_group.js +72 -0
  315. data/node_modules/codemirror/theme/3024-day.css +41 -0
  316. data/node_modules/codemirror/theme/3024-night.css +39 -0
  317. data/node_modules/codemirror/theme/abcdef.css +32 -0
  318. data/node_modules/codemirror/theme/ambiance-mobile.css +5 -0
  319. data/node_modules/codemirror/theme/ambiance.css +74 -0
  320. data/node_modules/codemirror/theme/base16-dark.css +38 -0
  321. data/node_modules/codemirror/theme/base16-light.css +38 -0
  322. data/node_modules/codemirror/theme/bespin.css +34 -0
  323. data/node_modules/codemirror/theme/blackboard.css +32 -0
  324. data/node_modules/codemirror/theme/cobalt.css +25 -0
  325. data/node_modules/codemirror/theme/colorforth.css +33 -0
  326. data/node_modules/codemirror/theme/darcula.css +46 -0
  327. data/node_modules/codemirror/theme/dracula.css +40 -0
  328. data/node_modules/codemirror/theme/duotone-dark.css +35 -0
  329. data/node_modules/codemirror/theme/duotone-light.css +36 -0
  330. data/node_modules/codemirror/theme/eclipse.css +23 -0
  331. data/node_modules/codemirror/theme/elegant.css +13 -0
  332. data/node_modules/codemirror/theme/erlang-dark.css +34 -0
  333. data/node_modules/codemirror/theme/gruvbox-dark.css +37 -0
  334. data/node_modules/codemirror/theme/hopscotch.css +34 -0
  335. data/node_modules/codemirror/theme/icecoder.css +43 -0
  336. data/node_modules/codemirror/theme/idea.css +42 -0
  337. data/node_modules/codemirror/theme/isotope.css +34 -0
  338. data/node_modules/codemirror/theme/lesser-dark.css +47 -0
  339. data/node_modules/codemirror/theme/liquibyte.css +95 -0
  340. data/node_modules/codemirror/theme/lucario.css +37 -0
  341. data/node_modules/codemirror/theme/material.css +53 -0
  342. data/node_modules/codemirror/theme/mbo.css +37 -0
  343. data/node_modules/codemirror/theme/mdn-like.css +46 -0
  344. data/node_modules/codemirror/theme/midnight.css +43 -0
  345. data/node_modules/codemirror/theme/monokai.css +41 -0
  346. data/node_modules/codemirror/theme/neat.css +12 -0
  347. data/node_modules/codemirror/theme/neo.css +43 -0
  348. data/node_modules/codemirror/theme/night.css +27 -0
  349. data/node_modules/codemirror/theme/oceanic-next.css +44 -0
  350. data/node_modules/codemirror/theme/panda-syntax.css +85 -0
  351. data/node_modules/codemirror/theme/paraiso-dark.css +38 -0
  352. data/node_modules/codemirror/theme/paraiso-light.css +38 -0
  353. data/node_modules/codemirror/theme/pastel-on-dark.css +52 -0
  354. data/node_modules/codemirror/theme/railscasts.css +34 -0
  355. data/node_modules/codemirror/theme/rubyblue.css +25 -0
  356. data/node_modules/codemirror/theme/seti.css +44 -0
  357. data/node_modules/codemirror/theme/shadowfox.css +52 -0
  358. data/node_modules/codemirror/theme/solarized.css +168 -0
  359. data/node_modules/codemirror/theme/ssms.css +16 -0
  360. data/node_modules/codemirror/theme/the-matrix.css +30 -0
  361. data/node_modules/codemirror/theme/tomorrow-night-bright.css +35 -0
  362. data/node_modules/codemirror/theme/tomorrow-night-eighties.css +38 -0
  363. data/node_modules/codemirror/theme/ttcn.css +64 -0
  364. data/node_modules/codemirror/theme/twilight.css +32 -0
  365. data/node_modules/codemirror/theme/vibrant-ink.css +34 -0
  366. data/node_modules/codemirror/theme/xq-dark.css +53 -0
  367. data/node_modules/codemirror/theme/xq-light.css +43 -0
  368. data/node_modules/codemirror/theme/yeti.css +44 -0
  369. data/node_modules/codemirror/theme/zenburn.css +37 -0
  370. data/node_modules/marked/.editorconfig +16 -0
  371. data/node_modules/marked/.eslintignore +1 -0
  372. data/node_modules/marked/.eslintrc.json +28 -0
  373. data/node_modules/marked/.package 2.json.icloud +0 -0
  374. data/node_modules/marked/.travis.yml +47 -0
  375. data/node_modules/marked/Makefile +15 -0
  376. data/node_modules/marked/Makefile 2 +15 -0
  377. data/node_modules/marked/README 2.md +75 -0
  378. data/node_modules/marked/README.md +75 -0
  379. data/node_modules/marked/bin/marked +199 -0
  380. data/node_modules/marked/bower.json +23 -0
  381. data/node_modules/marked/component.json +10 -0
  382. data/node_modules/marked/index.js +1 -0
  383. data/node_modules/marked/jasmine.json +11 -0
  384. data/node_modules/marked/lib/marked 2.js +1604 -0
  385. data/node_modules/marked/lib/marked.js +1604 -0
  386. data/node_modules/marked/man/marked.1 +91 -0
  387. data/node_modules/marked/man/marked.1.txt +96 -0
  388. data/node_modules/marked/marked.min.js +6 -0
  389. data/node_modules/marked/package.json +95 -0
  390. data/node_modules/simplemde/.eslintrc +23 -0
  391. data/node_modules/simplemde/.npmignore +9 -0
  392. data/node_modules/simplemde/.travis.yml +18 -0
  393. data/node_modules/simplemde/CONTRIBUTING 2.md +10 -0
  394. data/node_modules/simplemde/CONTRIBUTING.md +10 -0
  395. data/node_modules/simplemde/LICENSE +22 -0
  396. data/node_modules/simplemde/README.md +331 -0
  397. data/node_modules/simplemde/bower.json +23 -0
  398. data/node_modules/simplemde/debug/.simplemde 2.css.icloud +0 -0
  399. data/node_modules/simplemde/debug/simplemde.css +676 -0
  400. data/node_modules/simplemde/debug/simplemde.debug.js +17023 -0
  401. data/node_modules/simplemde/debug/simplemde.js +17019 -0
  402. data/node_modules/simplemde/dist/simplemde.min.css +7 -0
  403. data/node_modules/simplemde/dist/simplemde.min.js +15 -0
  404. data/node_modules/simplemde/gulpfile.js +96 -0
  405. data/node_modules/simplemde/package.json +73 -0
  406. data/node_modules/simplemde/src/css/simplemde.css +328 -0
  407. data/node_modules/simplemde/src/js/codemirror/tablist 2.js +44 -0
  408. data/node_modules/simplemde/src/js/codemirror/tablist.js +44 -0
  409. data/node_modules/simplemde/src/js/simplemde.js +2028 -0
  410. data/node_modules/typo-js/README.md +45 -0
  411. data/node_modules/typo-js/dictionaries/en_US/.en_US 2.dic.icloud +0 -0
  412. data/node_modules/typo-js/dictionaries/en_US/README.md +7 -0
  413. data/node_modules/typo-js/dictionaries/en_US/en_US.aff +201 -0
  414. data/node_modules/typo-js/dictionaries/en_US/en_US.dic +62120 -0
  415. data/node_modules/typo-js/package.json +56 -0
  416. data/node_modules/typo-js/typo.js +931 -0
  417. data/package-lock.json +40 -0
  418. data/package.json +7 -0
  419. metadata +557 -0
@@ -0,0 +1,56 @@
1
+ {
2
+ "_from": "typo-js@*",
3
+ "_id": "typo-js@1.0.3",
4
+ "_inBundle": false,
5
+ "_integrity": "sha1-VNjrx5SfGngQkItgAsaEFSbJnVo=",
6
+ "_location": "/typo-js",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "range",
10
+ "registry": true,
11
+ "raw": "typo-js@*",
12
+ "name": "typo-js",
13
+ "escapedName": "typo-js",
14
+ "rawSpec": "*",
15
+ "saveSpec": null,
16
+ "fetchSpec": "*"
17
+ },
18
+ "_requiredBy": [
19
+ "/codemirror-spell-checker"
20
+ ],
21
+ "_resolved": "https://registry.npmjs.org/typo-js/-/typo-js-1.0.3.tgz",
22
+ "_shasum": "54d8ebc7949f1a7810908b6002c6841526c99d5a",
23
+ "_spec": "typo-js@*",
24
+ "_where": "/Users/stuart/Documents/administrate-field-markdown/node_modules/codemirror-spell-checker",
25
+ "author": {
26
+ "name": "Christopher Finke",
27
+ "email": "cfinke@gmail.com",
28
+ "url": "http://www.chrisfinke.com/"
29
+ },
30
+ "browser": {
31
+ "fs": false
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/cfinke/Typo.js/issues"
35
+ },
36
+ "bundleDependencies": false,
37
+ "deprecated": false,
38
+ "description": "A Hunspell-style spellchecker.",
39
+ "homepage": "https://github.com/cfinke/Typo.js#readme",
40
+ "keywords": [
41
+ "spellcheck",
42
+ "spellchecker",
43
+ "hunspell",
44
+ "typo",
45
+ "speling"
46
+ ],
47
+ "license": "BSD-3-Clause",
48
+ "main": "typo.js",
49
+ "name": "typo-js",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git://github.com/cfinke/Typo.js.git"
53
+ },
54
+ "tonicExample": "var Typo = require('typo-js'); var dictionary = new Typo('en_US'); dictionary.check('mispelled');",
55
+ "version": "1.0.3"
56
+ }
@@ -0,0 +1,931 @@
1
+ /* globals chrome: false */
2
+ /* globals __dirname: false */
3
+ /* globals require: false */
4
+ /* globals Buffer: false */
5
+ /* globals module: false */
6
+
7
+ /**
8
+ * Typo is a JavaScript implementation of a spellchecker using hunspell-style
9
+ * dictionaries.
10
+ */
11
+
12
+ var Typo;
13
+
14
+ (function () {
15
+ "use strict";
16
+
17
+ /**
18
+ * Typo constructor.
19
+ *
20
+ * @param {String} [dictionary] The locale code of the dictionary being used. e.g.,
21
+ * "en_US". This is only used to auto-load dictionaries.
22
+ * @param {String} [affData] The data from the dictionary's .aff file. If omitted
23
+ * and Typo.js is being used in a Chrome extension, the .aff
24
+ * file will be loaded automatically from
25
+ * lib/typo/dictionaries/[dictionary]/[dictionary].aff
26
+ * In other environments, it will be loaded from
27
+ * [settings.dictionaryPath]/dictionaries/[dictionary]/[dictionary].aff
28
+ * @param {String} [wordsData] The data from the dictionary's .dic file. If omitted
29
+ * and Typo.js is being used in a Chrome extension, the .dic
30
+ * file will be loaded automatically from
31
+ * lib/typo/dictionaries/[dictionary]/[dictionary].dic
32
+ * In other environments, it will be loaded from
33
+ * [settings.dictionaryPath]/dictionaries/[dictionary]/[dictionary].dic
34
+ * @param {Object} [settings] Constructor settings. Available properties are:
35
+ * {String} [dictionaryPath]: path to load dictionary from in non-chrome
36
+ * environment.
37
+ * {Object} [flags]: flag information.
38
+ * {Boolean} [asyncLoad]: If true, affData and wordsData will be loaded
39
+ * asynchronously.
40
+ * {Function} [loadedCallback]: Called when both affData and wordsData
41
+ * have been loaded. Only used if asyncLoad is set to true. The parameter
42
+ * is the instantiated Typo object.
43
+ *
44
+ * @returns {Typo} A Typo object.
45
+ */
46
+
47
+ Typo = function (dictionary, affData, wordsData, settings) {
48
+ settings = settings || {};
49
+
50
+ this.dictionary = null;
51
+
52
+ this.rules = {};
53
+ this.dictionaryTable = {};
54
+
55
+ this.compoundRules = [];
56
+ this.compoundRuleCodes = {};
57
+
58
+ this.replacementTable = [];
59
+
60
+ this.flags = settings.flags || {};
61
+
62
+ this.memoized = {};
63
+
64
+ this.loaded = false;
65
+
66
+ var self = this;
67
+
68
+ var path;
69
+
70
+ // Loop-control variables.
71
+ var i, j, _len, _jlen;
72
+
73
+ if (dictionary) {
74
+ self.dictionary = dictionary;
75
+
76
+ // If the data is preloaded, just setup the Typo object.
77
+ if (affData && wordsData) {
78
+ setup();
79
+ }
80
+ // Loading data for Chrome extentions.
81
+ else if (typeof window !== 'undefined' && 'chrome' in window && 'extension' in window.chrome && 'getURL' in window.chrome.extension) {
82
+ if (settings.dictionaryPath) {
83
+ path = settings.dictionaryPath;
84
+ }
85
+ else {
86
+ path = "typo/dictionaries";
87
+ }
88
+
89
+ if (!affData) readDataFile(chrome.extension.getURL(path + "/" + dictionary + "/" + dictionary + ".aff"), setAffData);
90
+ if (!wordsData) readDataFile(chrome.extension.getURL(path + "/" + dictionary + "/" + dictionary + ".dic"), setWordsData);
91
+ }
92
+ else {
93
+ if (settings.dictionaryPath) {
94
+ path = settings.dictionaryPath;
95
+ }
96
+ else if (typeof __dirname !== 'undefined') {
97
+ path = __dirname + '/dictionaries';
98
+ }
99
+ else {
100
+ path = './dictionaries';
101
+ }
102
+
103
+ if (!affData) readDataFile(path + "/" + dictionary + "/" + dictionary + ".aff", setAffData);
104
+ if (!wordsData) readDataFile(path + "/" + dictionary + "/" + dictionary + ".dic", setWordsData);
105
+ }
106
+ }
107
+
108
+ function readDataFile(url, setFunc) {
109
+ var response = self._readFile(url, null, settings.asyncLoad);
110
+
111
+ if (settings.asyncLoad) {
112
+ response.then(function(data) {
113
+ setFunc(data);
114
+ });
115
+ }
116
+ else {
117
+ setFunc(response);
118
+ }
119
+ }
120
+
121
+ function setAffData(data) {
122
+ affData = data;
123
+
124
+ if (wordsData) {
125
+ setup();
126
+ }
127
+ }
128
+
129
+ function setWordsData(data) {
130
+ wordsData = data;
131
+
132
+ if (affData) {
133
+ setup();
134
+ }
135
+ }
136
+
137
+ function setup() {
138
+ self.rules = self._parseAFF(affData);
139
+
140
+ // Save the rule codes that are used in compound rules.
141
+ self.compoundRuleCodes = {};
142
+
143
+ for (i = 0, _len = self.compoundRules.length; i < _len; i++) {
144
+ var rule = self.compoundRules[i];
145
+
146
+ for (j = 0, _jlen = rule.length; j < _jlen; j++) {
147
+ self.compoundRuleCodes[rule[j]] = [];
148
+ }
149
+ }
150
+
151
+ // If we add this ONLYINCOMPOUND flag to self.compoundRuleCodes, then _parseDIC
152
+ // will do the work of saving the list of words that are compound-only.
153
+ if ("ONLYINCOMPOUND" in self.flags) {
154
+ self.compoundRuleCodes[self.flags.ONLYINCOMPOUND] = [];
155
+ }
156
+
157
+ self.dictionaryTable = self._parseDIC(wordsData);
158
+
159
+ // Get rid of any codes from the compound rule codes that are never used
160
+ // (or that were special regex characters). Not especially necessary...
161
+ for (i in self.compoundRuleCodes) {
162
+ if (self.compoundRuleCodes[i].length === 0) {
163
+ delete self.compoundRuleCodes[i];
164
+ }
165
+ }
166
+
167
+ // Build the full regular expressions for each compound rule.
168
+ // I have a feeling (but no confirmation yet) that this method of
169
+ // testing for compound words is probably slow.
170
+ for (i = 0, _len = self.compoundRules.length; i < _len; i++) {
171
+ var ruleText = self.compoundRules[i];
172
+
173
+ var expressionText = "";
174
+
175
+ for (j = 0, _jlen = ruleText.length; j < _jlen; j++) {
176
+ var character = ruleText[j];
177
+
178
+ if (character in self.compoundRuleCodes) {
179
+ expressionText += "(" + self.compoundRuleCodes[character].join("|") + ")";
180
+ }
181
+ else {
182
+ expressionText += character;
183
+ }
184
+ }
185
+
186
+ self.compoundRules[i] = new RegExp(expressionText, "i");
187
+ }
188
+
189
+ self.loaded = true;
190
+
191
+ if (settings.asyncLoad && settings.loadedCallback) {
192
+ settings.loadedCallback(self);
193
+ }
194
+ }
195
+
196
+ return this;
197
+ };
198
+
199
+ Typo.prototype = {
200
+ /**
201
+ * Loads a Typo instance from a hash of all of the Typo properties.
202
+ *
203
+ * @param object obj A hash of Typo properties, probably gotten from a JSON.parse(JSON.stringify(typo_instance)).
204
+ */
205
+
206
+ load : function (obj) {
207
+ for (var i in obj) {
208
+ if (obj.hasOwnProperty(i)) {
209
+ this[i] = obj[i];
210
+ }
211
+ }
212
+
213
+ return this;
214
+ },
215
+
216
+ /**
217
+ * Read the contents of a file.
218
+ *
219
+ * @param {String} path The path (relative) to the file.
220
+ * @param {String} [charset="ISO8859-1"] The expected charset of the file
221
+ * @param {Boolean} async If true, the file will be read asynchronously. For node.js this does nothing, all
222
+ * files are read synchronously.
223
+ * @returns {String} The file data if async is false, otherwise a promise object. If running node.js, the data is
224
+ * always returned.
225
+ */
226
+
227
+ _readFile : function (path, charset, async) {
228
+ charset = charset || "utf8";
229
+
230
+ if (typeof XMLHttpRequest !== 'undefined') {
231
+ var promise;
232
+ var req = new XMLHttpRequest();
233
+ req.open("GET", path, async);
234
+
235
+ if (async) {
236
+ promise = new Promise(function(resolve, reject) {
237
+ req.onload = function() {
238
+ if (req.status === 200) {
239
+ resolve(req.responseText);
240
+ }
241
+ else {
242
+ reject(req.statusText);
243
+ }
244
+ };
245
+
246
+ req.onerror = function() {
247
+ reject(req.statusText);
248
+ }
249
+ });
250
+ }
251
+
252
+ if (req.overrideMimeType)
253
+ req.overrideMimeType("text/plain; charset=" + charset);
254
+
255
+ req.send(null);
256
+
257
+ return async ? promise : req.responseText;
258
+ }
259
+ else if (typeof require !== 'undefined') {
260
+ // Node.js
261
+ var fs = require("fs");
262
+
263
+ try {
264
+ if (fs.existsSync(path)) {
265
+ var stats = fs.statSync(path);
266
+
267
+ var fileDescriptor = fs.openSync(path, 'r');
268
+
269
+ var buffer = new Buffer(stats.size);
270
+
271
+ fs.readSync(fileDescriptor, buffer, 0, buffer.length, null);
272
+
273
+ return buffer.toString(charset, 0, buffer.length);
274
+ }
275
+ else {
276
+ console.log("Path " + path + " does not exist.");
277
+ }
278
+ } catch (e) {
279
+ console.log(e);
280
+ return '';
281
+ }
282
+ }
283
+ },
284
+
285
+ /**
286
+ * Parse the rules out from a .aff file.
287
+ *
288
+ * @param {String} data The contents of the affix file.
289
+ * @returns object The rules from the file.
290
+ */
291
+
292
+ _parseAFF : function (data) {
293
+ var rules = {};
294
+
295
+ var line, subline, numEntries, lineParts;
296
+ var i, j, _len, _jlen;
297
+
298
+ // Remove comment lines
299
+ data = this._removeAffixComments(data);
300
+
301
+ var lines = data.split("\n");
302
+
303
+ for (i = 0, _len = lines.length; i < _len; i++) {
304
+ line = lines[i];
305
+
306
+ var definitionParts = line.split(/\s+/);
307
+
308
+ var ruleType = definitionParts[0];
309
+
310
+ if (ruleType == "PFX" || ruleType == "SFX") {
311
+ var ruleCode = definitionParts[1];
312
+ var combineable = definitionParts[2];
313
+ numEntries = parseInt(definitionParts[3], 10);
314
+
315
+ var entries = [];
316
+
317
+ for (j = i + 1, _jlen = i + 1 + numEntries; j < _jlen; j++) {
318
+ subline = lines[j];
319
+
320
+ lineParts = subline.split(/\s+/);
321
+ var charactersToRemove = lineParts[2];
322
+
323
+ var additionParts = lineParts[3].split("/");
324
+
325
+ var charactersToAdd = additionParts[0];
326
+ if (charactersToAdd === "0") charactersToAdd = "";
327
+
328
+ var continuationClasses = this.parseRuleCodes(additionParts[1]);
329
+
330
+ var regexToMatch = lineParts[4];
331
+
332
+ var entry = {};
333
+ entry.add = charactersToAdd;
334
+
335
+ if (continuationClasses.length > 0) entry.continuationClasses = continuationClasses;
336
+
337
+ if (regexToMatch !== ".") {
338
+ if (ruleType === "SFX") {
339
+ entry.match = new RegExp(regexToMatch + "$");
340
+ }
341
+ else {
342
+ entry.match = new RegExp("^" + regexToMatch);
343
+ }
344
+ }
345
+
346
+ if (charactersToRemove != "0") {
347
+ if (ruleType === "SFX") {
348
+ entry.remove = new RegExp(charactersToRemove + "$");
349
+ }
350
+ else {
351
+ entry.remove = charactersToRemove;
352
+ }
353
+ }
354
+
355
+ entries.push(entry);
356
+ }
357
+
358
+ rules[ruleCode] = { "type" : ruleType, "combineable" : (combineable == "Y"), "entries" : entries };
359
+
360
+ i += numEntries;
361
+ }
362
+ else if (ruleType === "COMPOUNDRULE") {
363
+ numEntries = parseInt(definitionParts[1], 10);
364
+
365
+ for (j = i + 1, _jlen = i + 1 + numEntries; j < _jlen; j++) {
366
+ line = lines[j];
367
+
368
+ lineParts = line.split(/\s+/);
369
+ this.compoundRules.push(lineParts[1]);
370
+ }
371
+
372
+ i += numEntries;
373
+ }
374
+ else if (ruleType === "REP") {
375
+ lineParts = line.split(/\s+/);
376
+
377
+ if (lineParts.length === 3) {
378
+ this.replacementTable.push([ lineParts[1], lineParts[2] ]);
379
+ }
380
+ }
381
+ else {
382
+ // ONLYINCOMPOUND
383
+ // COMPOUNDMIN
384
+ // FLAG
385
+ // KEEPCASE
386
+ // NEEDAFFIX
387
+
388
+ this.flags[ruleType] = definitionParts[1];
389
+ }
390
+ }
391
+
392
+ return rules;
393
+ },
394
+
395
+ /**
396
+ * Removes comment lines and then cleans up blank lines and trailing whitespace.
397
+ *
398
+ * @param {String} data The data from an affix file.
399
+ * @return {String} The cleaned-up data.
400
+ */
401
+
402
+ _removeAffixComments : function (data) {
403
+ // Remove comments
404
+ // This used to remove any string starting with '#' up to the end of the line,
405
+ // but some COMPOUNDRULE definitions include '#' as part of the rule.
406
+ // I haven't seen any affix files that use comments on the same line as real data,
407
+ // so I don't think this will break anything.
408
+ data = data.replace(/^\s*#.*$/mg, "");
409
+
410
+ // Trim each line
411
+ data = data.replace(/^\s\s*/m, '').replace(/\s\s*$/m, '');
412
+
413
+ // Remove blank lines.
414
+ data = data.replace(/\n{2,}/g, "\n");
415
+
416
+ // Trim the entire string
417
+ data = data.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
418
+
419
+ return data;
420
+ },
421
+
422
+ /**
423
+ * Parses the words out from the .dic file.
424
+ *
425
+ * @param {String} data The data from the dictionary file.
426
+ * @returns object The lookup table containing all of the words and
427
+ * word forms from the dictionary.
428
+ */
429
+
430
+ _parseDIC : function (data) {
431
+ data = this._removeDicComments(data);
432
+
433
+ var lines = data.split("\n");
434
+ var dictionaryTable = {};
435
+
436
+ function addWord(word, rules) {
437
+ // Some dictionaries will list the same word multiple times with different rule sets.
438
+ if (!dictionaryTable.hasOwnProperty(word)) {
439
+ dictionaryTable[word] = null;
440
+ }
441
+
442
+ if (rules.length > 0) {
443
+ if (dictionaryTable[word] === null) {
444
+ dictionaryTable[word] = [];
445
+ }
446
+
447
+ dictionaryTable[word].push(rules);
448
+ }
449
+ }
450
+
451
+ // The first line is the number of words in the dictionary.
452
+ for (var i = 1, _len = lines.length; i < _len; i++) {
453
+ var line = lines[i];
454
+
455
+ var parts = line.split("/", 2);
456
+
457
+ var word = parts[0];
458
+
459
+ // Now for each affix rule, generate that form of the word.
460
+ if (parts.length > 1) {
461
+ var ruleCodesArray = this.parseRuleCodes(parts[1]);
462
+
463
+ // Save the ruleCodes for compound word situations.
464
+ if (!("NEEDAFFIX" in this.flags) || ruleCodesArray.indexOf(this.flags.NEEDAFFIX) == -1) {
465
+ addWord(word, ruleCodesArray);
466
+ }
467
+
468
+ for (var j = 0, _jlen = ruleCodesArray.length; j < _jlen; j++) {
469
+ var code = ruleCodesArray[j];
470
+
471
+ var rule = this.rules[code];
472
+
473
+ if (rule) {
474
+ var newWords = this._applyRule(word, rule);
475
+
476
+ for (var ii = 0, _iilen = newWords.length; ii < _iilen; ii++) {
477
+ var newWord = newWords[ii];
478
+
479
+ addWord(newWord, []);
480
+
481
+ if (rule.combineable) {
482
+ for (var k = j + 1; k < _jlen; k++) {
483
+ var combineCode = ruleCodesArray[k];
484
+
485
+ var combineRule = this.rules[combineCode];
486
+
487
+ if (combineRule) {
488
+ if (combineRule.combineable && (rule.type != combineRule.type)) {
489
+ var otherNewWords = this._applyRule(newWord, combineRule);
490
+
491
+ for (var iii = 0, _iiilen = otherNewWords.length; iii < _iiilen; iii++) {
492
+ var otherNewWord = otherNewWords[iii];
493
+ addWord(otherNewWord, []);
494
+ }
495
+ }
496
+ }
497
+ }
498
+ }
499
+ }
500
+ }
501
+
502
+ if (code in this.compoundRuleCodes) {
503
+ this.compoundRuleCodes[code].push(word);
504
+ }
505
+ }
506
+ }
507
+ else {
508
+ addWord(word.trim(), []);
509
+ }
510
+ }
511
+
512
+ return dictionaryTable;
513
+ },
514
+
515
+
516
+ /**
517
+ * Removes comment lines and then cleans up blank lines and trailing whitespace.
518
+ *
519
+ * @param {String} data The data from a .dic file.
520
+ * @return {String} The cleaned-up data.
521
+ */
522
+
523
+ _removeDicComments : function (data) {
524
+ // I can't find any official documentation on it, but at least the de_DE
525
+ // dictionary uses tab-indented lines as comments.
526
+
527
+ // Remove comments
528
+ data = data.replace(/^\t.*$/mg, "");
529
+
530
+ return data;
531
+ },
532
+
533
+ parseRuleCodes : function (textCodes) {
534
+ if (!textCodes) {
535
+ return [];
536
+ }
537
+ else if (!("FLAG" in this.flags)) {
538
+ return textCodes.split("");
539
+ }
540
+ else if (this.flags.FLAG === "long") {
541
+ var flags = [];
542
+
543
+ for (var i = 0, _len = textCodes.length; i < _len; i += 2) {
544
+ flags.push(textCodes.substr(i, 2));
545
+ }
546
+
547
+ return flags;
548
+ }
549
+ else if (this.flags.FLAG === "num") {
550
+ return textCodes.split(",");
551
+ }
552
+ },
553
+
554
+ /**
555
+ * Applies an affix rule to a word.
556
+ *
557
+ * @param {String} word The base word.
558
+ * @param {Object} rule The affix rule.
559
+ * @returns {String[]} The new words generated by the rule.
560
+ */
561
+
562
+ _applyRule : function (word, rule) {
563
+ var entries = rule.entries;
564
+ var newWords = [];
565
+
566
+ for (var i = 0, _len = entries.length; i < _len; i++) {
567
+ var entry = entries[i];
568
+
569
+ if (!entry.match || word.match(entry.match)) {
570
+ var newWord = word;
571
+
572
+ if (entry.remove) {
573
+ newWord = newWord.replace(entry.remove, "");
574
+ }
575
+
576
+ if (rule.type === "SFX") {
577
+ newWord = newWord + entry.add;
578
+ }
579
+ else {
580
+ newWord = entry.add + newWord;
581
+ }
582
+
583
+ newWords.push(newWord);
584
+
585
+ if ("continuationClasses" in entry) {
586
+ for (var j = 0, _jlen = entry.continuationClasses.length; j < _jlen; j++) {
587
+ var continuationRule = this.rules[entry.continuationClasses[j]];
588
+
589
+ if (continuationRule) {
590
+ newWords = newWords.concat(this._applyRule(newWord, continuationRule));
591
+ }
592
+ /*
593
+ else {
594
+ // This shouldn't happen, but it does, at least in the de_DE dictionary.
595
+ // I think the author mistakenly supplied lower-case rule codes instead
596
+ // of upper-case.
597
+ }
598
+ */
599
+ }
600
+ }
601
+ }
602
+ }
603
+
604
+ return newWords;
605
+ },
606
+
607
+ /**
608
+ * Checks whether a word or a capitalization variant exists in the current dictionary.
609
+ * The word is trimmed and several variations of capitalizations are checked.
610
+ * If you want to check a word without any changes made to it, call checkExact()
611
+ *
612
+ * @see http://blog.stevenlevithan.com/archives/faster-trim-javascript re:trimming function
613
+ *
614
+ * @param {String} aWord The word to check.
615
+ * @returns {Boolean}
616
+ */
617
+
618
+ check : function (aWord) {
619
+ if (!this.loaded) {
620
+ throw "Dictionary not loaded.";
621
+ }
622
+
623
+ // Remove leading and trailing whitespace
624
+ var trimmedWord = aWord.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
625
+
626
+ if (this.checkExact(trimmedWord)) {
627
+ return true;
628
+ }
629
+
630
+ // The exact word is not in the dictionary.
631
+ if (trimmedWord.toUpperCase() === trimmedWord) {
632
+ // The word was supplied in all uppercase.
633
+ // Check for a capitalized form of the word.
634
+ var capitalizedWord = trimmedWord[0] + trimmedWord.substring(1).toLowerCase();
635
+
636
+ if (this.hasFlag(capitalizedWord, "KEEPCASE")) {
637
+ // Capitalization variants are not allowed for this word.
638
+ return false;
639
+ }
640
+
641
+ if (this.checkExact(capitalizedWord)) {
642
+ return true;
643
+ }
644
+ }
645
+
646
+ var lowercaseWord = trimmedWord.toLowerCase();
647
+
648
+ if (lowercaseWord !== trimmedWord) {
649
+ if (this.hasFlag(lowercaseWord, "KEEPCASE")) {
650
+ // Capitalization variants are not allowed for this word.
651
+ return false;
652
+ }
653
+
654
+ // Check for a lowercase form
655
+ if (this.checkExact(lowercaseWord)) {
656
+ return true;
657
+ }
658
+ }
659
+
660
+ return false;
661
+ },
662
+
663
+ /**
664
+ * Checks whether a word exists in the current dictionary.
665
+ *
666
+ * @param {String} word The word to check.
667
+ * @returns {Boolean}
668
+ */
669
+
670
+ checkExact : function (word) {
671
+ if (!this.loaded) {
672
+ throw "Dictionary not loaded.";
673
+ }
674
+
675
+ var ruleCodes = this.dictionaryTable[word];
676
+
677
+ var i, _len;
678
+
679
+ if (typeof ruleCodes === 'undefined') {
680
+ // Check if this might be a compound word.
681
+ if ("COMPOUNDMIN" in this.flags && word.length >= this.flags.COMPOUNDMIN) {
682
+ for (i = 0, _len = this.compoundRules.length; i < _len; i++) {
683
+ if (word.match(this.compoundRules[i])) {
684
+ return true;
685
+ }
686
+ }
687
+ }
688
+ }
689
+ else if (ruleCodes === null) {
690
+ // a null (but not undefined) value for an entry in the dictionary table
691
+ // means that the word is in the dictionary but has no flags.
692
+ return true;
693
+ }
694
+ else if (typeof ruleCodes === 'object') { // this.dictionary['hasOwnProperty'] will be a function.
695
+ for (i = 0, _len = ruleCodes.length; i < _len; i++) {
696
+ if (!this.hasFlag(word, "ONLYINCOMPOUND", ruleCodes[i])) {
697
+ return true;
698
+ }
699
+ }
700
+ }
701
+
702
+ return false;
703
+ },
704
+
705
+ /**
706
+ * Looks up whether a given word is flagged with a given flag.
707
+ *
708
+ * @param {String} word The word in question.
709
+ * @param {String} flag The flag in question.
710
+ * @return {Boolean}
711
+ */
712
+
713
+ hasFlag : function (word, flag, wordFlags) {
714
+ if (!this.loaded) {
715
+ throw "Dictionary not loaded.";
716
+ }
717
+
718
+ if (flag in this.flags) {
719
+ if (typeof wordFlags === 'undefined') {
720
+ wordFlags = Array.prototype.concat.apply([], this.dictionaryTable[word]);
721
+ }
722
+
723
+ if (wordFlags && wordFlags.indexOf(this.flags[flag]) !== -1) {
724
+ return true;
725
+ }
726
+ }
727
+
728
+ return false;
729
+ },
730
+
731
+ /**
732
+ * Returns a list of suggestions for a misspelled word.
733
+ *
734
+ * @see http://www.norvig.com/spell-correct.html for the basis of this suggestor.
735
+ * This suggestor is primitive, but it works.
736
+ *
737
+ * @param {String} word The misspelling.
738
+ * @param {Number} [limit=5] The maximum number of suggestions to return.
739
+ * @returns {String[]} The array of suggestions.
740
+ */
741
+
742
+ alphabet : "",
743
+
744
+ suggest : function (word, limit) {
745
+ if (!this.loaded) {
746
+ throw "Dictionary not loaded.";
747
+ }
748
+
749
+ limit = limit || 5;
750
+
751
+ if (this.memoized.hasOwnProperty(word)) {
752
+ var memoizedLimit = this.memoized[word]['limit'];
753
+
754
+ // Only return the cached list if it's big enough or if there weren't enough suggestions
755
+ // to fill a smaller limit.
756
+ if (limit <= memoizedLimit || this.memoized[word]['suggestions'].length < memoizedLimit) {
757
+ return this.memoized[word]['suggestions'].slice(0, limit);
758
+ }
759
+ }
760
+
761
+ if (this.check(word)) return [];
762
+
763
+ // Check the replacement table.
764
+ for (var i = 0, _len = this.replacementTable.length; i < _len; i++) {
765
+ var replacementEntry = this.replacementTable[i];
766
+
767
+ if (word.indexOf(replacementEntry[0]) !== -1) {
768
+ var correctedWord = word.replace(replacementEntry[0], replacementEntry[1]);
769
+
770
+ if (this.check(correctedWord)) {
771
+ return [ correctedWord ];
772
+ }
773
+ }
774
+ }
775
+
776
+ var self = this;
777
+ self.alphabet = "abcdefghijklmnopqrstuvwxyz";
778
+
779
+ /*
780
+ if (!self.alphabet) {
781
+ // Use the alphabet as implicitly defined by the words in the dictionary.
782
+ var alphaHash = {};
783
+
784
+ for (var i in self.dictionaryTable) {
785
+ for (var j = 0, _len = i.length; j < _len; j++) {
786
+ alphaHash[i[j]] = true;
787
+ }
788
+ }
789
+
790
+ for (var i in alphaHash) {
791
+ self.alphabet += i;
792
+ }
793
+
794
+ var alphaArray = self.alphabet.split("");
795
+ alphaArray.sort();
796
+ self.alphabet = alphaArray.join("");
797
+ }
798
+ */
799
+
800
+ function edits1(words) {
801
+ var rv = [];
802
+
803
+ var ii, i, j, _iilen, _len, _jlen;
804
+
805
+ for (ii = 0, _iilen = words.length; ii < _iilen; ii++) {
806
+ var word = words[ii];
807
+
808
+ for (i = 0, _len = word.length + 1; i < _len; i++) {
809
+ var s = [ word.substring(0, i), word.substring(i) ];
810
+
811
+ if (s[1]) {
812
+ rv.push(s[0] + s[1].substring(1));
813
+ }
814
+
815
+ // Eliminate transpositions of identical letters
816
+ if (s[1].length > 1 && s[1][1] !== s[1][0]) {
817
+ rv.push(s[0] + s[1][1] + s[1][0] + s[1].substring(2));
818
+ }
819
+
820
+ if (s[1]) {
821
+ for (j = 0, _jlen = self.alphabet.length; j < _jlen; j++) {
822
+ // Eliminate replacement of a letter by itself
823
+ if (self.alphabet[j] != s[1].substring(0,1)){
824
+ rv.push(s[0] + self.alphabet[j] + s[1].substring(1));
825
+ }
826
+ }
827
+ }
828
+
829
+ if (s[1]) {
830
+ for (j = 0, _jlen = self.alphabet.length; j < _jlen; j++) {
831
+ rv.push(s[0] + self.alphabet[j] + s[1]);
832
+ }
833
+ }
834
+ }
835
+ }
836
+
837
+ return rv;
838
+ }
839
+
840
+ function known(words) {
841
+ var rv = [];
842
+
843
+ for (var i = 0, _len = words.length; i < _len; i++) {
844
+ if (self.check(words[i])) {
845
+ rv.push(words[i]);
846
+ }
847
+ }
848
+
849
+ return rv;
850
+ }
851
+
852
+ function correct(word) {
853
+ // Get the edit-distance-1 and edit-distance-2 forms of this word.
854
+ var ed1 = edits1([word]);
855
+ var ed2 = edits1(ed1);
856
+
857
+ var corrections = known(ed1.concat(ed2));
858
+
859
+ var i, _len;
860
+
861
+ // Sort the edits based on how many different ways they were created.
862
+ var weighted_corrections = {};
863
+
864
+ for (i = 0, _len = corrections.length; i < _len; i++) {
865
+ if (!(corrections[i] in weighted_corrections)) {
866
+ weighted_corrections[corrections[i]] = 1;
867
+ }
868
+ else {
869
+ weighted_corrections[corrections[i]] += 1;
870
+ }
871
+ }
872
+
873
+ var sorted_corrections = [];
874
+
875
+ for (i in weighted_corrections) {
876
+ if (weighted_corrections.hasOwnProperty(i)) {
877
+ sorted_corrections.push([ i, weighted_corrections[i] ]);
878
+ }
879
+ }
880
+
881
+ function sorter(a, b) {
882
+ if (a[1] < b[1]) {
883
+ return -1;
884
+ }
885
+
886
+ return 1;
887
+ }
888
+
889
+ sorted_corrections.sort(sorter).reverse();
890
+
891
+ var rv = [];
892
+
893
+ var capitalization_scheme = "lowercase";
894
+
895
+ if (word.toUpperCase() === word) {
896
+ capitalization_scheme = "uppercase";
897
+ }
898
+ else if (word.substr(0, 1).toUpperCase() + word.substr(1).toLowerCase() === word) {
899
+ capitalization_scheme = "capitalized";
900
+ }
901
+
902
+ for (i = 0, _len = Math.min(limit, sorted_corrections.length); i < _len; i++) {
903
+ if ("uppercase" === capitalization_scheme) {
904
+ sorted_corrections[i][0] = sorted_corrections[i][0].toUpperCase();
905
+ }
906
+ else if ("capitalized" === capitalization_scheme) {
907
+ sorted_corrections[i][0] = sorted_corrections[i][0].substr(0, 1).toUpperCase() + sorted_corrections[i][0].substr(1);
908
+ }
909
+
910
+ if (!self.hasFlag(sorted_corrections[i][0], "NOSUGGEST")) {
911
+ rv.push(sorted_corrections[i][0]);
912
+ }
913
+ }
914
+
915
+ return rv;
916
+ }
917
+
918
+ this.memoized[word] = {
919
+ 'suggestions': correct(word),
920
+ 'limit': limit
921
+ };
922
+
923
+ return this.memoized[word]['suggestions'];
924
+ }
925
+ };
926
+ })();
927
+
928
+ // Support for use as a node.js module.
929
+ if (typeof module !== 'undefined') {
930
+ module.exports = Typo;
931
+ }