praxis 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/CHANGELOG.md +16 -0
  4. data/lib/api_browser/Gruntfile.js +125 -16
  5. data/lib/api_browser/app/index.html +5 -1
  6. data/lib/api_browser/app/js/directives/fixed_if_fits.js +28 -17
  7. data/lib/api_browser/app/js/directives/highlight.js +14 -0
  8. data/lib/api_browser/app/js/directives/request_examples.js +29 -0
  9. data/lib/api_browser/app/js/factories/Documentation.js +6 -0
  10. data/lib/api_browser/app/js/factories/Example.js +47 -0
  11. data/lib/api_browser/app/js/factories/prepare_template.js +15 -0
  12. data/lib/api_browser/app/js/factories/template_for.js +2 -12
  13. data/lib/api_browser/app/sass/modules/_sidebar.scss +2 -0
  14. data/lib/api_browser/app/views/action.html +6 -24
  15. data/lib/api_browser/app/views/examples/general.html +26 -0
  16. data/lib/api_browser/{bower.json → bower_template.json} +13 -3
  17. data/lib/api_browser/package.json +3 -1
  18. data/lib/praxis/application.rb +2 -0
  19. data/lib/praxis/docs/generator.rb +4 -2
  20. data/lib/praxis/extensions/field_selection/field_selector.rb +1 -0
  21. data/lib/praxis/media_type.rb +1 -1
  22. data/lib/praxis/plugin.rb +4 -0
  23. data/lib/praxis/plugin_concern.rb +2 -1
  24. data/lib/praxis/tasks/api_docs.rb +9 -2
  25. data/lib/praxis/version.rb +1 -1
  26. data/praxis.gemspec +2 -2
  27. data/spec/praxis/action_definition_spec.rb +26 -1
  28. data/spec/praxis/extensions/field_selection/field_selector_spec.rb +4 -0
  29. data/spec/praxis/media_type_spec.rb +4 -3
  30. data/spec/support/spec_media_types.rb +5 -1
  31. metadata +12 -242
  32. data/lib/api_browser/app/bower_components/angular-mocks/.bower.json +0 -19
  33. data/lib/api_browser/app/bower_components/angular-mocks/README.md +0 -63
  34. data/lib/api_browser/app/bower_components/angular-mocks/angular-mocks.js +0 -2452
  35. data/lib/api_browser/app/bower_components/angular-mocks/bower.json +0 -9
  36. data/lib/api_browser/app/bower_components/angular-mocks/ngAnimateMock.js +0 -2
  37. data/lib/api_browser/app/bower_components/angular-mocks/ngMock.js +0 -2
  38. data/lib/api_browser/app/bower_components/angular-mocks/ngMockE2E.js +0 -2
  39. data/lib/api_browser/app/bower_components/angular-mocks/package.json +0 -27
  40. data/lib/api_browser/app/bower_components/angular-sanitize/.bower.json +0 -19
  41. data/lib/api_browser/app/bower_components/angular-sanitize/README.md +0 -68
  42. data/lib/api_browser/app/bower_components/angular-sanitize/angular-sanitize.js +0 -683
  43. data/lib/api_browser/app/bower_components/angular-sanitize/angular-sanitize.min.js +0 -16
  44. data/lib/api_browser/app/bower_components/angular-sanitize/angular-sanitize.min.js.map +0 -8
  45. data/lib/api_browser/app/bower_components/angular-sanitize/bower.json +0 -9
  46. data/lib/api_browser/app/bower_components/angular-sanitize/index.js +0 -2
  47. data/lib/api_browser/app/bower_components/angular-sanitize/package.json +0 -26
  48. data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/.bower.json +0 -31
  49. data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/bower.json +0 -19
  50. data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap-csp.css +0 -6
  51. data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.js +0 -4840
  52. data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js +0 -10
  53. data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap.js +0 -4461
  54. data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap.min.js +0 -9
  55. data/lib/api_browser/app/bower_components/angular-ui-router/.bower.json +0 -33
  56. data/lib/api_browser/app/bower_components/angular-ui-router/CHANGELOG.md +0 -228
  57. data/lib/api_browser/app/bower_components/angular-ui-router/CONTRIBUTING.md +0 -65
  58. data/lib/api_browser/app/bower_components/angular-ui-router/LICENSE +0 -21
  59. data/lib/api_browser/app/bower_components/angular-ui-router/README.md +0 -245
  60. data/lib/api_browser/app/bower_components/angular-ui-router/api/angular-ui-router.d.ts +0 -126
  61. data/lib/api_browser/app/bower_components/angular-ui-router/bower.json +0 -23
  62. data/lib/api_browser/app/bower_components/angular-ui-router/release/angular-ui-router.js +0 -4370
  63. data/lib/api_browser/app/bower_components/angular-ui-router/release/angular-ui-router.min.js +0 -7
  64. data/lib/api_browser/app/bower_components/angular-ui-router/src/common.js +0 -292
  65. data/lib/api_browser/app/bower_components/angular-ui-router/src/resolve.js +0 -252
  66. data/lib/api_browser/app/bower_components/angular-ui-router/src/state.js +0 -1465
  67. data/lib/api_browser/app/bower_components/angular-ui-router/src/stateDirectives.js +0 -285
  68. data/lib/api_browser/app/bower_components/angular-ui-router/src/stateFilters.js +0 -39
  69. data/lib/api_browser/app/bower_components/angular-ui-router/src/templateFactory.js +0 -110
  70. data/lib/api_browser/app/bower_components/angular-ui-router/src/urlMatcherFactory.js +0 -1050
  71. data/lib/api_browser/app/bower_components/angular-ui-router/src/urlRouter.js +0 -427
  72. data/lib/api_browser/app/bower_components/angular-ui-router/src/view.js +0 -71
  73. data/lib/api_browser/app/bower_components/angular-ui-router/src/viewDirective.js +0 -303
  74. data/lib/api_browser/app/bower_components/angular-ui-router/src/viewScroll.js +0 -52
  75. data/lib/api_browser/app/bower_components/angular/.bower.json +0 -17
  76. data/lib/api_browser/app/bower_components/angular/README.md +0 -64
  77. data/lib/api_browser/app/bower_components/angular/angular-csp.css +0 -21
  78. data/lib/api_browser/app/bower_components/angular/angular.js +0 -28133
  79. data/lib/api_browser/app/bower_components/angular/angular.min.js +0 -289
  80. data/lib/api_browser/app/bower_components/angular/angular.min.js.gzip +0 -0
  81. data/lib/api_browser/app/bower_components/angular/angular.min.js.map +0 -8
  82. data/lib/api_browser/app/bower_components/angular/bower.json +0 -8
  83. data/lib/api_browser/app/bower_components/angular/index.js +0 -2
  84. data/lib/api_browser/app/bower_components/angular/package.json +0 -25
  85. data/lib/api_browser/app/bower_components/bootstrap-sass/.bower.json +0 -41
  86. data/lib/api_browser/app/bower_components/bootstrap-sass/CHANGELOG.md +0 -108
  87. data/lib/api_browser/app/bower_components/bootstrap-sass/CONTRIBUTING.md +0 -79
  88. data/lib/api_browser/app/bower_components/bootstrap-sass/README.md +0 -218
  89. data/lib/api_browser/app/bower_components/bootstrap-sass/bower.json +0 -22
  90. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
  91. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +0 -229
  92. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
  93. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
  94. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap.js +0 -12
  95. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/affix.js +0 -126
  96. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/alert.js +0 -98
  97. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/button.js +0 -115
  98. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/carousel.js +0 -217
  99. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/collapse.js +0 -179
  100. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/dropdown.js +0 -154
  101. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/modal.js +0 -246
  102. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/popover.js +0 -117
  103. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/scrollspy.js +0 -158
  104. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/tab.js +0 -135
  105. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/tooltip.js +0 -386
  106. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/transition.js +0 -56
  107. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap.scss +0 -1
  108. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_alerts.scss +0 -67
  109. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_badges.scss +0 -51
  110. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +0 -23
  111. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_button-groups.scss +0 -227
  112. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_buttons.scss +0 -155
  113. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_carousel.scss +0 -232
  114. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_close.scss +0 -35
  115. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_code.scss +0 -53
  116. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_component-animations.scss +0 -29
  117. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +0 -188
  118. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_forms.scss +0 -374
  119. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_glyphicons.scss +0 -237
  120. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_grid.scss +0 -79
  121. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_input-groups.scss +0 -136
  122. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_jumbotron.scss +0 -46
  123. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_labels.scss +0 -64
  124. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_list-group.scss +0 -88
  125. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_media.scss +0 -56
  126. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_mixins.scss +0 -848
  127. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_modals.scss +0 -129
  128. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_navbar.scss +0 -616
  129. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_navs.scss +0 -242
  130. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_normalize.scss +0 -406
  131. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_pager.scss +0 -55
  132. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_pagination.scss +0 -85
  133. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_panels.scss +0 -182
  134. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_popovers.scss +0 -133
  135. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_print.scss +0 -105
  136. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +0 -80
  137. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_responsive-utilities.scss +0 -198
  138. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +0 -119
  139. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_tables.scss +0 -231
  140. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_theme.scss +0 -247
  141. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +0 -38
  142. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_tooltip.scss +0 -95
  143. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_type.scss +0 -281
  144. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_utilities.scss +0 -56
  145. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_variables.scss +0 -646
  146. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/_wells.scss +0 -29
  147. data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap/bootstrap.scss +0 -49
  148. data/lib/api_browser/app/bower_components/jquery/.bower.json +0 -38
  149. data/lib/api_browser/app/bower_components/jquery/MIT-LICENSE.txt +0 -21
  150. data/lib/api_browser/app/bower_components/jquery/bower.json +0 -27
  151. data/lib/api_browser/app/bower_components/jquery/dist/jquery.js +0 -9190
  152. data/lib/api_browser/app/bower_components/jquery/dist/jquery.min.js +0 -5
  153. data/lib/api_browser/app/bower_components/jquery/dist/jquery.min.map +0 -1
  154. data/lib/api_browser/app/bower_components/jquery/src/ajax.js +0 -806
  155. data/lib/api_browser/app/bower_components/jquery/src/ajax/jsonp.js +0 -89
  156. data/lib/api_browser/app/bower_components/jquery/src/ajax/load.js +0 -75
  157. data/lib/api_browser/app/bower_components/jquery/src/ajax/parseJSON.js +0 -13
  158. data/lib/api_browser/app/bower_components/jquery/src/ajax/parseXML.js +0 -28
  159. data/lib/api_browser/app/bower_components/jquery/src/ajax/script.js +0 -64
  160. data/lib/api_browser/app/bower_components/jquery/src/ajax/var/nonce.js +0 -5
  161. data/lib/api_browser/app/bower_components/jquery/src/ajax/var/rquery.js +0 -3
  162. data/lib/api_browser/app/bower_components/jquery/src/ajax/xhr.js +0 -135
  163. data/lib/api_browser/app/bower_components/jquery/src/attributes.js +0 -11
  164. data/lib/api_browser/app/bower_components/jquery/src/attributes/attr.js +0 -143
  165. data/lib/api_browser/app/bower_components/jquery/src/attributes/classes.js +0 -158
  166. data/lib/api_browser/app/bower_components/jquery/src/attributes/prop.js +0 -96
  167. data/lib/api_browser/app/bower_components/jquery/src/attributes/support.js +0 -35
  168. data/lib/api_browser/app/bower_components/jquery/src/attributes/val.js +0 -163
  169. data/lib/api_browser/app/bower_components/jquery/src/callbacks.js +0 -205
  170. data/lib/api_browser/app/bower_components/jquery/src/core.js +0 -498
  171. data/lib/api_browser/app/bower_components/jquery/src/core/access.js +0 -60
  172. data/lib/api_browser/app/bower_components/jquery/src/core/init.js +0 -123
  173. data/lib/api_browser/app/bower_components/jquery/src/core/parseHTML.js +0 -39
  174. data/lib/api_browser/app/bower_components/jquery/src/core/ready.js +0 -97
  175. data/lib/api_browser/app/bower_components/jquery/src/core/var/rsingleTag.js +0 -4
  176. data/lib/api_browser/app/bower_components/jquery/src/css.js +0 -451
  177. data/lib/api_browser/app/bower_components/jquery/src/css/addGetHookIf.js +0 -24
  178. data/lib/api_browser/app/bower_components/jquery/src/css/curCSS.js +0 -57
  179. data/lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js +0 -70
  180. data/lib/api_browser/app/bower_components/jquery/src/css/hiddenVisibleSelectors.js +0 -15
  181. data/lib/api_browser/app/bower_components/jquery/src/css/support.js +0 -91
  182. data/lib/api_browser/app/bower_components/jquery/src/css/swap.js +0 -28
  183. data/lib/api_browser/app/bower_components/jquery/src/css/var/cssExpand.js +0 -3
  184. data/lib/api_browser/app/bower_components/jquery/src/css/var/getStyles.js +0 -5
  185. data/lib/api_browser/app/bower_components/jquery/src/css/var/isHidden.js +0 -13
  186. data/lib/api_browser/app/bower_components/jquery/src/css/var/rmargin.js +0 -3
  187. data/lib/api_browser/app/bower_components/jquery/src/css/var/rnumnonpx.js +0 -5
  188. data/lib/api_browser/app/bower_components/jquery/src/data.js +0 -179
  189. data/lib/api_browser/app/bower_components/jquery/src/data/Data.js +0 -181
  190. data/lib/api_browser/app/bower_components/jquery/src/data/accepts.js +0 -20
  191. data/lib/api_browser/app/bower_components/jquery/src/data/var/data_priv.js +0 -5
  192. data/lib/api_browser/app/bower_components/jquery/src/data/var/data_user.js +0 -5
  193. data/lib/api_browser/app/bower_components/jquery/src/deferred.js +0 -149
  194. data/lib/api_browser/app/bower_components/jquery/src/deprecated.js +0 -13
  195. data/lib/api_browser/app/bower_components/jquery/src/dimensions.js +0 -50
  196. data/lib/api_browser/app/bower_components/jquery/src/effects.js +0 -649
  197. data/lib/api_browser/app/bower_components/jquery/src/effects/Tween.js +0 -114
  198. data/lib/api_browser/app/bower_components/jquery/src/effects/animatedSelector.js +0 -13
  199. data/lib/api_browser/app/bower_components/jquery/src/event.js +0 -868
  200. data/lib/api_browser/app/bower_components/jquery/src/event/alias.js +0 -39
  201. data/lib/api_browser/app/bower_components/jquery/src/event/support.js +0 -9
  202. data/lib/api_browser/app/bower_components/jquery/src/exports/amd.js +0 -24
  203. data/lib/api_browser/app/bower_components/jquery/src/exports/global.js +0 -32
  204. data/lib/api_browser/app/bower_components/jquery/src/intro.js +0 -44
  205. data/lib/api_browser/app/bower_components/jquery/src/jquery.js +0 -36
  206. data/lib/api_browser/app/bower_components/jquery/src/manipulation.js +0 -582
  207. data/lib/api_browser/app/bower_components/jquery/src/manipulation/_evalUrl.js +0 -18
  208. data/lib/api_browser/app/bower_components/jquery/src/manipulation/support.js +0 -31
  209. data/lib/api_browser/app/bower_components/jquery/src/manipulation/var/rcheckableType.js +0 -3
  210. data/lib/api_browser/app/bower_components/jquery/src/offset.js +0 -204
  211. data/lib/api_browser/app/bower_components/jquery/src/outro.js +0 -1
  212. data/lib/api_browser/app/bower_components/jquery/src/queue.js +0 -142
  213. data/lib/api_browser/app/bower_components/jquery/src/queue/delay.js +0 -22
  214. data/lib/api_browser/app/bower_components/jquery/src/selector-native.js +0 -172
  215. data/lib/api_browser/app/bower_components/jquery/src/selector-sizzle.js +0 -14
  216. data/lib/api_browser/app/bower_components/jquery/src/selector.js +0 -1
  217. data/lib/api_browser/app/bower_components/jquery/src/serialize.js +0 -111
  218. data/lib/api_browser/app/bower_components/jquery/src/sizzle/dist/sizzle.js +0 -2044
  219. data/lib/api_browser/app/bower_components/jquery/src/sizzle/dist/sizzle.min.js +0 -3
  220. data/lib/api_browser/app/bower_components/jquery/src/sizzle/dist/sizzle.min.map +0 -1
  221. data/lib/api_browser/app/bower_components/jquery/src/traversing.js +0 -200
  222. data/lib/api_browser/app/bower_components/jquery/src/traversing/findFilter.js +0 -100
  223. data/lib/api_browser/app/bower_components/jquery/src/traversing/var/rneedsContext.js +0 -6
  224. data/lib/api_browser/app/bower_components/jquery/src/var/arr.js +0 -3
  225. data/lib/api_browser/app/bower_components/jquery/src/var/class2type.js +0 -4
  226. data/lib/api_browser/app/bower_components/jquery/src/var/concat.js +0 -5
  227. data/lib/api_browser/app/bower_components/jquery/src/var/hasOwn.js +0 -5
  228. data/lib/api_browser/app/bower_components/jquery/src/var/indexOf.js +0 -5
  229. data/lib/api_browser/app/bower_components/jquery/src/var/pnum.js +0 -3
  230. data/lib/api_browser/app/bower_components/jquery/src/var/push.js +0 -5
  231. data/lib/api_browser/app/bower_components/jquery/src/var/rnotwhite.js +0 -3
  232. data/lib/api_browser/app/bower_components/jquery/src/var/slice.js +0 -5
  233. data/lib/api_browser/app/bower_components/jquery/src/var/strundefined.js +0 -3
  234. data/lib/api_browser/app/bower_components/jquery/src/var/support.js +0 -4
  235. data/lib/api_browser/app/bower_components/jquery/src/var/toString.js +0 -5
  236. data/lib/api_browser/app/bower_components/jquery/src/wrap.js +0 -78
  237. data/lib/api_browser/app/bower_components/lodash/.bower.json +0 -30
  238. data/lib/api_browser/app/bower_components/lodash/LICENSE.txt +0 -22
  239. data/lib/api_browser/app/bower_components/lodash/bower.json +0 -20
  240. data/lib/api_browser/app/bower_components/lodash/lodash.js +0 -12235
  241. data/lib/api_browser/app/bower_components/lodash/lodash.min.js +0 -98
  242. data/lib/api_browser/app/bower_components/showdown/.bower.json +0 -39
  243. data/lib/api_browser/app/bower_components/showdown/.jshintignore +0 -2
  244. data/lib/api_browser/app/bower_components/showdown/.travis.yml +0 -8
  245. data/lib/api_browser/app/bower_components/showdown/Gruntfile.js +0 -100
  246. data/lib/api_browser/app/bower_components/showdown/README.md +0 -317
  247. data/lib/api_browser/app/bower_components/showdown/bower.json +0 -26
  248. data/lib/api_browser/app/bower_components/showdown/compressed/Showdown.js +0 -1606
  249. data/lib/api_browser/app/bower_components/showdown/compressed/Showdown.js.map +0 -1
  250. data/lib/api_browser/app/bower_components/showdown/compressed/Showdown.min.js +0 -2
  251. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/github.min.js +0 -2
  252. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/github.min.js.map +0 -1
  253. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/prettify.min.js +0 -2
  254. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/prettify.min.js.map +0 -1
  255. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/table.min.js +0 -2
  256. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/table.min.js.map +0 -1
  257. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/twitter.min.js +0 -2
  258. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/twitter.min.js.map +0 -1
  259. data/lib/api_browser/app/bower_components/showdown/license.txt +0 -34
  260. data/lib/api_browser/app/bower_components/showdown/package.json +0 -47
  261. data/lib/api_browser/app/bower_components/showdown/src/extensions/github.js +0 -25
  262. data/lib/api_browser/app/bower_components/showdown/src/extensions/prettify.js +0 -29
  263. data/lib/api_browser/app/bower_components/showdown/src/extensions/table.js +0 -106
  264. data/lib/api_browser/app/bower_components/showdown/src/extensions/twitter.js +0 -42
  265. data/lib/api_browser/app/bower_components/showdown/src/ng-showdown.js +0 -150
  266. data/lib/api_browser/app/bower_components/showdown/src/showdown.js +0 -1454
@@ -1,26 +0,0 @@
1
- {
2
- "name": "showdown",
3
- "description": "JavaScript port of Markdown",
4
- "homepage": "https://github.com/showdownjs/showdown",
5
- "authors": [
6
- "John Fraser",
7
- "Corey Innis (https://github.com/coreyti)",
8
- "Pascal Deschênes (https://github.com/pdeschen)",
9
- "Estevão Santos (https://github.com/tivie)"
10
- ],
11
- "main": ["src/showdown.js"],
12
- "ignore": [
13
- ".jshintrc",
14
- "perlMarkdown/*"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/showdownjs/showdown.git"
19
- },
20
- "keywords": [
21
- "markdown",
22
- "md",
23
- "mdown"
24
- ],
25
- "license": "https://github.com/showdownjs/showdown/blob/master/license.txt"
26
- }
@@ -1,1606 +0,0 @@
1
- //
2
- // showdown.js -- A javascript port of Markdown.
3
- //
4
- // Copyright (c) 2007 John Fraser.
5
- //
6
- // Original Markdown Copyright (c) 2004-2005 John Gruber
7
- // <http://daringfireball.net/projects/markdown/>
8
- //
9
- // Redistributable under a BSD-style open source license.
10
- // See license.txt for more information.
11
- //
12
- // The full source distribution is at:
13
- //
14
- // A A L
15
- // T C A
16
- // T K B
17
- //
18
- // <http://www.attacklab.net/>
19
- //
20
-
21
- //
22
- // Wherever possible, Showdown is a straight, line-by-line port
23
- // of the Perl version of Markdown.
24
- //
25
- // This is not a normal parser design; it's basically just a
26
- // series of string substitutions. It's hard to read and
27
- // maintain this way, but keeping Showdown close to the original
28
- // design makes it easier to port new features.
29
- //
30
- // More importantly, Showdown behaves like markdown.pl in most
31
- // edge cases. So web applications can do client-side preview
32
- // in Javascript, and then build identical HTML on the server.
33
- //
34
- // This port needs the new RegExp functionality of ECMA 262,
35
- // 3rd Edition (i.e. Javascript 1.5). Most modern web browsers
36
- // should do fine. Even with the new regular expression features,
37
- // We do a lot of work to emulate Perl's regex functionality.
38
- // The tricky changes in this file mostly have the "attacklab:"
39
- // label. Major or self-explanatory changes don't.
40
- //
41
- // Smart diff tools like Araxis Merge will be able to match up
42
- // this file with markdown.pl in a useful way. A little tweaking
43
- // helps: in a copy of markdown.pl, replace "#" with "//" and
44
- // replace "$text" with "text". Be sure to ignore whitespace
45
- // and line endings.
46
- //
47
-
48
-
49
- //
50
- // Showdown usage:
51
- //
52
- // var text = "Markdown *rocks*.";
53
- //
54
- // var converter = new Showdown.converter();
55
- // var html = converter.makeHtml(text);
56
- //
57
- // alert(html);
58
- //
59
- // Note: move the sample code to the bottom of this
60
- // file before uncommenting it.
61
- //
62
-
63
-
64
- //
65
- // Showdown namespace
66
- //
67
- var Showdown = {extensions: {}};
68
-
69
- //
70
- // forEach
71
- //
72
- var forEach = Showdown.forEach = function (obj, callback) {
73
- if (typeof obj.forEach === 'function') {
74
- obj.forEach(callback);
75
- } else {
76
- var i, len = obj.length;
77
- for (i = 0; i < len; i++) {
78
- callback(obj[i], i, obj);
79
- }
80
- }
81
- };
82
-
83
- //
84
- // Standard extension naming
85
- //
86
- var stdExtName = function (s) {
87
- return s.replace(/[_-]||\s/g, '').toLowerCase();
88
- };
89
-
90
- //
91
- // converter
92
- //
93
- // Wraps all "globals" so that the only thing
94
- // exposed is makeHtml().
95
- //
96
- Showdown.converter = function (converter_options) {
97
-
98
- //
99
- // Globals:
100
- //
101
-
102
- // Global hashes, used by various utility routines
103
- var g_urls;
104
- var g_titles;
105
- var g_html_blocks;
106
-
107
- // Used to track when we're inside an ordered or unordered list
108
- // (see _ProcessListItems() for details):
109
- var g_list_level = 0;
110
-
111
- // Global extensions
112
- var g_lang_extensions = [];
113
- var g_output_modifiers = [];
114
-
115
-
116
- //
117
- // Automatic Extension Loading (node only):
118
- //
119
- if (typeof module !== 'undefined' && typeof exports !== 'undefined' && typeof require !== 'undefined') {
120
- var fs = require('fs');
121
-
122
- if (fs) {
123
- // Search extensions folder
124
- var extensions = fs.readdirSync((__dirname || '.') + '/extensions').filter(function (file) {
125
- return ~file.indexOf('.js');
126
- }).map(function (file) {
127
- return file.replace(/\.js$/, '');
128
- });
129
- // Load extensions into Showdown namespace
130
- Showdown.forEach(extensions, function (ext) {
131
- var name = stdExtName(ext);
132
- Showdown.extensions[name] = require('./extensions/' + ext);
133
- });
134
- }
135
- }
136
-
137
- this.makeHtml = function (text) {
138
- //
139
- // Main function. The order in which other subs are called here is
140
- // essential. Link and image substitutions need to happen before
141
- // _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
142
- // and <img> tags get encoded.
143
- //
144
-
145
- // Clear the global hashes. If we don't clear these, you get conflicts
146
- // from other articles when generating a page which contains more than
147
- // one article (e.g. an index page that shows the N most recent
148
- // articles):
149
- g_urls = {};
150
- g_titles = {};
151
- g_html_blocks = [];
152
-
153
- // attacklab: Replace ~ with ~T
154
- // This lets us use tilde as an escape char to avoid md5 hashes
155
- // The choice of character is arbitray; anything that isn't
156
- // magic in Markdown will work.
157
- text = text.replace(/~/g, "~T");
158
-
159
- // attacklab: Replace $ with ~D
160
- // RegExp interprets $ as a special character
161
- // when it's in a replacement string
162
- text = text.replace(/\$/g, "~D");
163
-
164
- // Standardize line endings
165
- text = text.replace(/\r\n/g, "\n"); // DOS to Unix
166
- text = text.replace(/\r/g, "\n"); // Mac to Unix
167
-
168
- // Make sure text begins and ends with a couple of newlines:
169
- text = "\n\n" + text + "\n\n";
170
-
171
- // Convert all tabs to spaces.
172
- text = _Detab(text);
173
-
174
- // Strip any lines consisting only of spaces and tabs.
175
- // This makes subsequent regexen easier to write, because we can
176
- // match consecutive blank lines with /\n+/ instead of something
177
- // contorted like /[ \t]*\n+/ .
178
- text = text.replace(/^[ \t]+$/mg, "");
179
-
180
- // Run language extensions
181
- Showdown.forEach(g_lang_extensions, function (x) {
182
- text = _ExecuteExtension(x, text);
183
- });
184
-
185
- // Handle github codeblocks prior to running HashHTML so that
186
- // HTML contained within the codeblock gets escaped propertly
187
- text = _DoGithubCodeBlocks(text);
188
-
189
- // Turn block-level HTML blocks into hash entries
190
- text = _HashHTMLBlocks(text);
191
-
192
- // Strip link definitions, store in hashes.
193
- text = _StripLinkDefinitions(text);
194
-
195
- text = _RunBlockGamut(text);
196
-
197
- text = _UnescapeSpecialChars(text);
198
-
199
- // attacklab: Restore dollar signs
200
- text = text.replace(/~D/g, "$$");
201
-
202
- // attacklab: Restore tildes
203
- text = text.replace(/~T/g, "~");
204
-
205
- // Run output modifiers
206
- Showdown.forEach(g_output_modifiers, function (x) {
207
- text = _ExecuteExtension(x, text);
208
- });
209
-
210
- return text;
211
- };
212
-
213
-
214
- //
215
- // Options:
216
- //
217
-
218
- // Parse extensions options into separate arrays
219
- if (converter_options && converter_options.extensions) {
220
-
221
- var self = this;
222
-
223
- // Iterate over each plugin
224
- Showdown.forEach(converter_options.extensions, function (plugin) {
225
-
226
- // Assume it's a bundled plugin if a string is given
227
- if (typeof plugin === 'string') {
228
- plugin = Showdown.extensions[stdExtName(plugin)];
229
- }
230
-
231
- if (typeof plugin === 'function') {
232
- // Iterate over each extension within that plugin
233
- Showdown.forEach(plugin(self), function (ext) {
234
- // Sort extensions by type
235
- if (ext.type) {
236
- if (ext.type === 'language' || ext.type === 'lang') {
237
- g_lang_extensions.push(ext);
238
- } else if (ext.type === 'output' || ext.type === 'html') {
239
- g_output_modifiers.push(ext);
240
- }
241
- } else {
242
- // Assume language extension
243
- g_output_modifiers.push(ext);
244
- }
245
- });
246
- } else {
247
- throw "Extension '" + plugin + "' could not be loaded. It was either not found or is not a valid extension.";
248
- }
249
- });
250
- }
251
-
252
-
253
- var _ExecuteExtension = function (ext, text) {
254
- if (ext.regex) {
255
- var re = new RegExp(ext.regex, 'g');
256
- return text.replace(re, ext.replace);
257
- } else if (ext.filter) {
258
- return ext.filter(text);
259
- }
260
- };
261
-
262
- var _StripLinkDefinitions = function (text) {
263
- //
264
- // Strips link definitions from text, stores the URLs and titles in
265
- // hash references.
266
- //
267
-
268
- // Link defs are in the form: ^[id]: url "optional title"
269
-
270
- /*
271
- var text = text.replace(/
272
- ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
273
- [ \t]*
274
- \n? // maybe *one* newline
275
- [ \t]*
276
- <?(\S+?)>? // url = $2
277
- [ \t]*
278
- \n? // maybe one newline
279
- [ \t]*
280
- (?:
281
- (\n*) // any lines skipped = $3 attacklab: lookbehind removed
282
- ["(]
283
- (.+?) // title = $4
284
- [")]
285
- [ \t]*
286
- )? // title is optional
287
- (?:\n+|$)
288
- /gm,
289
- function(){...});
290
- */
291
-
292
- // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
293
- text += "~0";
294
-
295
- text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,
296
- function (wholeMatch, m1, m2, m3, m4) {
297
- m1 = m1.toLowerCase();
298
- g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
299
- if (m3) {
300
- // Oops, found blank lines, so it's not a title.
301
- // Put back the parenthetical statement we stole.
302
- return m3 + m4;
303
- } else if (m4) {
304
- g_titles[m1] = m4.replace(/"/g, "&quot;");
305
- }
306
-
307
- // Completely remove the definition from the text
308
- return "";
309
- }
310
- );
311
-
312
- // attacklab: strip sentinel
313
- text = text.replace(/~0/, "");
314
-
315
- return text;
316
- }
317
-
318
- var _HashHTMLBlocks = function (text) {
319
- // attacklab: Double up blank lines to reduce lookaround
320
- text = text.replace(/\n/g, "\n\n");
321
-
322
- // Hashify HTML blocks:
323
- // We only want to do this for block-level HTML tags, such as headers,
324
- // lists, and tables. That's because we still want to wrap <p>s around
325
- // "paragraphs" that are wrapped in non-block-level tags, such as anchors,
326
- // phrase emphasis, and spans. The list of tags we're looking for is
327
- // hard-coded:
328
- var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|section|header|footer|nav|article|aside";
329
- var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside";
330
-
331
- // First, look for nested blocks, e.g.:
332
- // <div>
333
- // <div>
334
- // tags for inner block must be indented.
335
- // </div>
336
- // </div>
337
- //
338
- // The outermost tags must start at the left margin for this to match, and
339
- // the inner nested divs must be indented.
340
- // We need to do this before the next, more liberal match, because the next
341
- // match will start at the first `<div>` and stop at the first `</div>`.
342
-
343
- // attacklab: This regex can be expensive when it fails.
344
- /*
345
- var text = text.replace(/
346
- ( // save in $1
347
- ^ // start of line (with /m)
348
- <($block_tags_a) // start tag = $2
349
- \b // word break
350
- // attacklab: hack around khtml/pcre bug...
351
- [^\r]*?\n // any number of lines, minimally matching
352
- </\2> // the matching end tag
353
- [ \t]* // trailing spaces/tabs
354
- (?=\n+) // followed by a newline
355
- ) // attacklab: there are sentinel newlines at end of document
356
- /gm,function(){...}};
357
- */
358
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm, hashElement);
359
-
360
- //
361
- // Now match more liberally, simply from `\n<tag>` to `</tag>\n`
362
- //
363
-
364
- /*
365
- var text = text.replace(/
366
- ( // save in $1
367
- ^ // start of line (with /m)
368
- <($block_tags_b) // start tag = $2
369
- \b // word break
370
- // attacklab: hack around khtml/pcre bug...
371
- [^\r]*? // any number of lines, minimally matching
372
- </\2> // the matching end tag
373
- [ \t]* // trailing spaces/tabs
374
- (?=\n+) // followed by a newline
375
- ) // attacklab: there are sentinel newlines at end of document
376
- /gm,function(){...}};
377
- */
378
- text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm, hashElement);
379
-
380
- // Special case just for <hr />. It was easier to make a special case than
381
- // to make the other regex more complicated.
382
-
383
- /*
384
- text = text.replace(/
385
- ( // save in $1
386
- \n\n // Starting after a blank line
387
- [ ]{0,3}
388
- (<(hr) // start tag = $2
389
- \b // word break
390
- ([^<>])*? //
391
- \/?>) // the matching end tag
392
- [ \t]*
393
- (?=\n{2,}) // followed by a blank line
394
- )
395
- /g,hashElement);
396
- */
397
- text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, hashElement);
398
-
399
- // Special case for standalone HTML comments:
400
-
401
- /*
402
- text = text.replace(/
403
- ( // save in $1
404
- \n\n // Starting after a blank line
405
- [ ]{0,3} // attacklab: g_tab_width - 1
406
- <!
407
- (--[^\r]*?--\s*)+
408
- >
409
- [ \t]*
410
- (?=\n{2,}) // followed by a blank line
411
- )
412
- /g,hashElement);
413
- */
414
- text = text.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g, hashElement);
415
-
416
- // PHP and ASP-style processor instructions (<?...?> and <%...%>)
417
-
418
- /*
419
- text = text.replace(/
420
- (?:
421
- \n\n // Starting after a blank line
422
- )
423
- ( // save in $1
424
- [ ]{0,3} // attacklab: g_tab_width - 1
425
- (?:
426
- <([?%]) // $2
427
- [^\r]*?
428
- \2>
429
- )
430
- [ \t]*
431
- (?=\n{2,}) // followed by a blank line
432
- )
433
- /g,hashElement);
434
- */
435
- text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, hashElement);
436
-
437
- // attacklab: Undo double lines (see comment at top of this function)
438
- text = text.replace(/\n\n/g, "\n");
439
- return text;
440
- }
441
-
442
- var hashElement = function (wholeMatch, m1) {
443
- var blockText = m1;
444
-
445
- // Undo double lines
446
- blockText = blockText.replace(/\n\n/g, "\n");
447
- blockText = blockText.replace(/^\n/, "");
448
-
449
- // strip trailing blank lines
450
- blockText = blockText.replace(/\n+$/g, "");
451
-
452
- // Replace the element text with a marker ("~KxK" where x is its key)
453
- blockText = "\n\n~K" + (g_html_blocks.push(blockText) - 1) + "K\n\n";
454
-
455
- return blockText;
456
- };
457
-
458
- var _RunBlockGamut = function (text) {
459
- //
460
- // These are all the transformations that form block-level
461
- // tags like paragraphs, headers, and list items.
462
- //
463
- text = _DoHeaders(text);
464
-
465
- // Do Horizontal Rules:
466
- var key = hashBlock("<hr />");
467
- text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, key);
468
- text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm, key);
469
- text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm, key);
470
-
471
- text = _DoLists(text);
472
- text = _DoCodeBlocks(text);
473
- text = _DoBlockQuotes(text);
474
-
475
- // We already ran _HashHTMLBlocks() before, in Markdown(), but that
476
- // was to escape raw HTML in the original Markdown source. This time,
477
- // we're escaping the markup we've just created, so that we don't wrap
478
- // <p> tags around block-level tags.
479
- text = _HashHTMLBlocks(text);
480
- text = _FormParagraphs(text);
481
-
482
- return text;
483
- };
484
-
485
- var _RunSpanGamut = function (text) {
486
- //
487
- // These are all the transformations that occur *within* block-level
488
- // tags like paragraphs, headers, and list items.
489
- //
490
-
491
- text = _DoCodeSpans(text);
492
- text = _EscapeSpecialCharsWithinTagAttributes(text);
493
- text = _EncodeBackslashEscapes(text);
494
-
495
- // Process anchor and image tags. Images must come first,
496
- // because ![foo][f] looks like an anchor.
497
- text = _DoImages(text);
498
- text = _DoAnchors(text);
499
-
500
- // Make links out of things like `<http://example.com/>`
501
- // Must come after _DoAnchors(), because you can use < and >
502
- // delimiters in inline links like [this](<url>).
503
- text = _DoAutoLinks(text);
504
- text = _EncodeAmpsAndAngles(text);
505
- text = _DoItalicsAndBold(text);
506
-
507
- // Do hard breaks:
508
- text = text.replace(/ +\n/g, " <br />\n");
509
-
510
- return text;
511
- }
512
-
513
- var _EscapeSpecialCharsWithinTagAttributes = function (text) {
514
- //
515
- // Within tags -- meaning between < and > -- encode [\ ` * _] so they
516
- // don't conflict with their use in Markdown for code, italics and strong.
517
- //
518
-
519
- // Build a regex to find HTML tags and comments. See Friedl's
520
- // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
521
- var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
522
-
523
- text = text.replace(regex, function (wholeMatch) {
524
- var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, "$1`");
525
- tag = escapeCharacters(tag, "\\`*_");
526
- return tag;
527
- });
528
-
529
- return text;
530
- }
531
-
532
- var _DoAnchors = function (text) {
533
- //
534
- // Turn Markdown link shortcuts into XHTML <a> tags.
535
- //
536
- //
537
- // First, handle reference-style links: [link text] [id]
538
- //
539
-
540
- /*
541
- text = text.replace(/
542
- ( // wrap whole match in $1
543
- \[
544
- (
545
- (?:
546
- \[[^\]]*\] // allow brackets nested one level
547
- |
548
- [^\[] // or anything else
549
- )*
550
- )
551
- \]
552
-
553
- [ ]? // one optional space
554
- (?:\n[ ]*)? // one optional newline followed by spaces
555
-
556
- \[
557
- (.*?) // id = $3
558
- \]
559
- )()()()() // pad remaining backreferences
560
- /g,_DoAnchors_callback);
561
- */
562
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeAnchorTag);
563
-
564
- //
565
- // Next, inline-style links: [link text](url "optional title")
566
- //
567
-
568
- /*
569
- text = text.replace(/
570
- ( // wrap whole match in $1
571
- \[
572
- (
573
- (?:
574
- \[[^\]]*\] // allow brackets nested one level
575
- |
576
- [^\[\]] // or anything else
577
- )
578
- )
579
- \]
580
- \( // literal paren
581
- [ \t]*
582
- () // no id, so leave $3 empty
583
- <?(.*?)>? // href = $4
584
- [ \t]*
585
- ( // $5
586
- (['"]) // quote char = $6
587
- (.*?) // Title = $7
588
- \6 // matching quote
589
- [ \t]* // ignore any spaces/tabs between closing quote and )
590
- )? // title is optional
591
- \)
592
- )
593
- /g,writeAnchorTag);
594
- */
595
- text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeAnchorTag);
596
-
597
- //
598
- // Last, handle reference-style shortcuts: [link text]
599
- // These must come last in case you've also got [link test][1]
600
- // or [link test](/foo)
601
- //
602
-
603
- /*
604
- text = text.replace(/
605
- ( // wrap whole match in $1
606
- \[
607
- ([^\[\]]+) // link text = $2; can't contain '[' or ']'
608
- \]
609
- )()()()()() // pad rest of backreferences
610
- /g, writeAnchorTag);
611
- */
612
- text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
613
-
614
- return text;
615
- }
616
-
617
- var writeAnchorTag = function (wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
618
- if (m7 == undefined) m7 = "";
619
- var whole_match = m1;
620
- var link_text = m2;
621
- var link_id = m3.toLowerCase();
622
- var url = m4;
623
- var title = m7;
624
-
625
- if (url == "") {
626
- if (link_id == "") {
627
- // lower-case and turn embedded newlines into spaces
628
- link_id = link_text.toLowerCase().replace(/ ?\n/g, " ");
629
- }
630
- url = "#" + link_id;
631
-
632
- if (g_urls[link_id] != undefined) {
633
- url = g_urls[link_id];
634
- if (g_titles[link_id] != undefined) {
635
- title = g_titles[link_id];
636
- }
637
- }
638
- else {
639
- if (whole_match.search(/\(\s*\)$/m) > -1) {
640
- // Special case for explicit empty url
641
- url = "";
642
- } else {
643
- return whole_match;
644
- }
645
- }
646
- }
647
-
648
- url = escapeCharacters(url, "*_");
649
- var result = "<a href=\"" + url + "\"";
650
-
651
- if (title != "") {
652
- title = title.replace(/"/g, "&quot;");
653
- title = escapeCharacters(title, "*_");
654
- result += " title=\"" + title + "\"";
655
- }
656
-
657
- result += ">" + link_text + "</a>";
658
-
659
- return result;
660
- }
661
-
662
- var _DoImages = function (text) {
663
- //
664
- // Turn Markdown image shortcuts into <img> tags.
665
- //
666
-
667
- //
668
- // First, handle reference-style labeled images: ![alt text][id]
669
- //
670
-
671
- /*
672
- text = text.replace(/
673
- ( // wrap whole match in $1
674
- !\[
675
- (.*?) // alt text = $2
676
- \]
677
-
678
- [ ]? // one optional space
679
- (?:\n[ ]*)? // one optional newline followed by spaces
680
-
681
- \[
682
- (.*?) // id = $3
683
- \]
684
- )()()()() // pad rest of backreferences
685
- /g,writeImageTag);
686
- */
687
- text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeImageTag);
688
-
689
- //
690
- // Next, handle inline images: ![alt text](url "optional title")
691
- // Don't forget: encode * and _
692
-
693
- /*
694
- text = text.replace(/
695
- ( // wrap whole match in $1
696
- !\[
697
- (.*?) // alt text = $2
698
- \]
699
- \s? // One optional whitespace character
700
- \( // literal paren
701
- [ \t]*
702
- () // no id, so leave $3 empty
703
- <?(\S+?)>? // src url = $4
704
- [ \t]*
705
- ( // $5
706
- (['"]) // quote char = $6
707
- (.*?) // title = $7
708
- \6 // matching quote
709
- [ \t]*
710
- )? // title is optional
711
- \)
712
- )
713
- /g,writeImageTag);
714
- */
715
- text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeImageTag);
716
-
717
- return text;
718
- }
719
-
720
- var writeImageTag = function (wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
721
- var whole_match = m1;
722
- var alt_text = m2;
723
- var link_id = m3.toLowerCase();
724
- var url = m4;
725
- var title = m7;
726
-
727
- if (!title) title = "";
728
-
729
- if (url == "") {
730
- if (link_id == "") {
731
- // lower-case and turn embedded newlines into spaces
732
- link_id = alt_text.toLowerCase().replace(/ ?\n/g, " ");
733
- }
734
- url = "#" + link_id;
735
-
736
- if (g_urls[link_id] != undefined) {
737
- url = g_urls[link_id];
738
- if (g_titles[link_id] != undefined) {
739
- title = g_titles[link_id];
740
- }
741
- }
742
- else {
743
- return whole_match;
744
- }
745
- }
746
-
747
- alt_text = alt_text.replace(/"/g, "&quot;");
748
- url = escapeCharacters(url, "*_");
749
- var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
750
-
751
- // attacklab: Markdown.pl adds empty title attributes to images.
752
- // Replicate this bug.
753
-
754
- //if (title != "") {
755
- title = title.replace(/"/g, "&quot;");
756
- title = escapeCharacters(title, "*_");
757
- result += " title=\"" + title + "\"";
758
- //}
759
-
760
- result += " />";
761
-
762
- return result;
763
- }
764
-
765
- var _DoHeaders = function (text) {
766
-
767
- // Setext-style headers:
768
- // Header 1
769
- // ========
770
- //
771
- // Header 2
772
- // --------
773
- //
774
- text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
775
- function (wholeMatch, m1) {
776
- return hashBlock('<h1 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h1>");
777
- });
778
-
779
- text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
780
- function (matchFound, m1) {
781
- return hashBlock('<h2 id="' + headerId(m1) + '">' + _RunSpanGamut(m1) + "</h2>");
782
- });
783
-
784
- // atx-style headers:
785
- // # Header 1
786
- // ## Header 2
787
- // ## Header 2 with closing hashes ##
788
- // ...
789
- // ###### Header 6
790
- //
791
-
792
- /*
793
- text = text.replace(/
794
- ^(\#{1,6}) // $1 = string of #'s
795
- [ \t]*
796
- (.+?) // $2 = Header text
797
- [ \t]*
798
- \#* // optional closing #'s (not counted)
799
- \n+
800
- /gm, function() {...});
801
- */
802
-
803
- text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
804
- function (wholeMatch, m1, m2) {
805
- var h_level = m1.length;
806
- return hashBlock("<h" + h_level + ' id="' + headerId(m2) + '">' + _RunSpanGamut(m2) + "</h" + h_level + ">");
807
- });
808
-
809
- function headerId(m) {
810
- return m.replace(/[^\w]/g, '').toLowerCase();
811
- }
812
-
813
- return text;
814
- }
815
-
816
- // This declaration keeps Dojo compressor from outputting garbage:
817
- var _ProcessListItems;
818
-
819
- var _DoLists = function (text) {
820
- //
821
- // Form HTML ordered (numbered) and unordered (bulleted) lists.
822
- //
823
-
824
- // attacklab: add sentinel to hack around khtml/safari bug:
825
- // http://bugs.webkit.org/show_bug.cgi?id=11231
826
- text += "~0";
827
-
828
- // Re-usable pattern to match any entirel ul or ol list:
829
-
830
- /*
831
- var whole_list = /
832
- ( // $1 = whole list
833
- ( // $2
834
- [ ]{0,3} // attacklab: g_tab_width - 1
835
- ([*+-]|\d+[.]) // $3 = first list item marker
836
- [ \t]+
837
- )
838
- [^\r]+?
839
- ( // $4
840
- ~0 // sentinel for workaround; should be $
841
- |
842
- \n{2,}
843
- (?=\S)
844
- (?! // Negative lookahead for another list item marker
845
- [ \t]*
846
- (?:[*+-]|\d+[.])[ \t]+
847
- )
848
- )
849
- )/g
850
- */
851
- var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
852
-
853
- if (g_list_level) {
854
- text = text.replace(whole_list, function (wholeMatch, m1, m2) {
855
- var list = m1;
856
- var list_type = (m2.search(/[*+-]/g) > -1) ? "ul" : "ol";
857
-
858
- // Turn double returns into triple returns, so that we can make a
859
- // paragraph for the last item in a list, if necessary:
860
- list = list.replace(/\n{2,}/g, "\n\n\n");
861
- ;
862
- var result = _ProcessListItems(list);
863
-
864
- // Trim any trailing whitespace, to put the closing `</$list_type>`
865
- // up on the preceding line, to get it past the current stupid
866
- // HTML block parser. This is a hack to work around the terrible
867
- // hack that is the HTML block parser.
868
- result = result.replace(/\s+$/, "");
869
- result = "<" + list_type + ">" + result + "</" + list_type + ">\n";
870
- return result;
871
- });
872
- } else {
873
- whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
874
- text = text.replace(whole_list, function (wholeMatch, m1, m2, m3) {
875
- var runup = m1;
876
- var list = m2;
877
-
878
- var list_type = (m3.search(/[*+-]/g) > -1) ? "ul" : "ol";
879
- // Turn double returns into triple returns, so that we can make a
880
- // paragraph for the last item in a list, if necessary:
881
- var list = list.replace(/\n{2,}/g, "\n\n\n");
882
- ;
883
- var result = _ProcessListItems(list);
884
- result = runup + "<" + list_type + ">\n" + result + "</" + list_type + ">\n";
885
- return result;
886
- });
887
- }
888
-
889
- // attacklab: strip sentinel
890
- text = text.replace(/~0/, "");
891
-
892
- return text;
893
- }
894
-
895
- _ProcessListItems = function (list_str) {
896
- //
897
- // Process the contents of a single ordered or unordered list, splitting it
898
- // into individual list items.
899
- //
900
- // The $g_list_level global keeps track of when we're inside a list.
901
- // Each time we enter a list, we increment it; when we leave a list,
902
- // we decrement. If it's zero, we're not in a list anymore.
903
- //
904
- // We do this because when we're not inside a list, we want to treat
905
- // something like this:
906
- //
907
- // I recommend upgrading to version
908
- // 8. Oops, now this line is treated
909
- // as a sub-list.
910
- //
911
- // As a single paragraph, despite the fact that the second line starts
912
- // with a digit-period-space sequence.
913
- //
914
- // Whereas when we're inside a list (or sub-list), that line will be
915
- // treated as the start of a sub-list. What a kludge, huh? This is
916
- // an aspect of Markdown's syntax that's hard to parse perfectly
917
- // without resorting to mind-reading. Perhaps the solution is to
918
- // change the syntax rules such that sub-lists must start with a
919
- // starting cardinal number; e.g. "1." or "a.".
920
-
921
- g_list_level++;
922
-
923
- // trim trailing blank lines:
924
- list_str = list_str.replace(/\n{2,}$/, "\n");
925
-
926
- // attacklab: add sentinel to emulate \z
927
- list_str += "~0";
928
-
929
- /*
930
- list_str = list_str.replace(/
931
- (\n)? // leading line = $1
932
- (^[ \t]*) // leading whitespace = $2
933
- ([*+-]|\d+[.]) [ \t]+ // list marker = $3
934
- ([^\r]+? // list item text = $4
935
- (\n{1,2}))
936
- (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+))
937
- /gm, function(){...});
938
- */
939
- list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
940
- function (wholeMatch, m1, m2, m3, m4) {
941
- var item = m4;
942
- var leading_line = m1;
943
- var leading_space = m2;
944
-
945
- if (leading_line || (item.search(/\n{2,}/) > -1)) {
946
- item = _RunBlockGamut(_Outdent(item));
947
- }
948
- else {
949
- // Recursion for sub-lists:
950
- item = _DoLists(_Outdent(item));
951
- item = item.replace(/\n$/, ""); // chomp(item)
952
- item = _RunSpanGamut(item);
953
- }
954
-
955
- return "<li>" + item + "</li>\n";
956
- }
957
- );
958
-
959
- // attacklab: strip sentinel
960
- list_str = list_str.replace(/~0/g, "");
961
-
962
- g_list_level--;
963
- return list_str;
964
- }
965
-
966
- var _DoCodeBlocks = function (text) {
967
- //
968
- // Process Markdown `<pre><code>` blocks.
969
- //
970
-
971
- /*
972
- text = text.replace(text,
973
- /(?:\n\n|^)
974
- ( // $1 = the code block -- one or more lines, starting with a space/tab
975
- (?:
976
- (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
977
- .*\n+
978
- )+
979
- )
980
- (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
981
- /g,function(){...});
982
- */
983
-
984
- // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
985
- text += "~0";
986
-
987
- text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
988
- function (wholeMatch, m1, m2) {
989
- var codeblock = m1;
990
- var nextChar = m2;
991
-
992
- codeblock = _EncodeCode(_Outdent(codeblock));
993
- codeblock = _Detab(codeblock);
994
- codeblock = codeblock.replace(/^\n+/g, ""); // trim leading newlines
995
- codeblock = codeblock.replace(/\n+$/g, ""); // trim trailing whitespace
996
-
997
- codeblock = "<pre><code>" + codeblock + "\n</code></pre>";
998
-
999
- return hashBlock(codeblock) + nextChar;
1000
- }
1001
- );
1002
-
1003
- // attacklab: strip sentinel
1004
- text = text.replace(/~0/, "");
1005
-
1006
- return text;
1007
- };
1008
-
1009
- var _DoGithubCodeBlocks = function (text) {
1010
- //
1011
- // Process Github-style code blocks
1012
- // Example:
1013
- // ```ruby
1014
- // def hello_world(x)
1015
- // puts "Hello, #{x}"
1016
- // end
1017
- // ```
1018
- //
1019
-
1020
-
1021
- // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
1022
- text += "~0";
1023
-
1024
- text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,
1025
- function (wholeMatch, m1, m2) {
1026
- var language = m1;
1027
- var codeblock = m2;
1028
-
1029
- codeblock = _EncodeCode(codeblock);
1030
- codeblock = _Detab(codeblock);
1031
- codeblock = codeblock.replace(/^\n+/g, ""); // trim leading newlines
1032
- codeblock = codeblock.replace(/\n+$/g, ""); // trim trailing whitespace
1033
-
1034
- codeblock = "<pre><code" + (language ? " class=\"" + language + '"' : "") + ">" + codeblock + "\n</code></pre>";
1035
-
1036
- return hashBlock(codeblock);
1037
- }
1038
- );
1039
-
1040
- // attacklab: strip sentinel
1041
- text = text.replace(/~0/, "");
1042
-
1043
- return text;
1044
- }
1045
-
1046
- var hashBlock = function (text) {
1047
- text = text.replace(/(^\n+|\n+$)/g, "");
1048
- return "\n\n~K" + (g_html_blocks.push(text) - 1) + "K\n\n";
1049
- }
1050
-
1051
- var _DoCodeSpans = function (text) {
1052
- //
1053
- // * Backtick quotes are used for <code></code> spans.
1054
- //
1055
- // * You can use multiple backticks as the delimiters if you want to
1056
- // include literal backticks in the code span. So, this input:
1057
- //
1058
- // Just type ``foo `bar` baz`` at the prompt.
1059
- //
1060
- // Will translate to:
1061
- //
1062
- // <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
1063
- //
1064
- // There's no arbitrary limit to the number of backticks you
1065
- // can use as delimters. If you need three consecutive backticks
1066
- // in your code, use four for delimiters, etc.
1067
- //
1068
- // * You can use spaces to get literal backticks at the edges:
1069
- //
1070
- // ... type `` `bar` `` ...
1071
- //
1072
- // Turns to:
1073
- //
1074
- // ... type <code>`bar`</code> ...
1075
- //
1076
-
1077
- /*
1078
- text = text.replace(/
1079
- (^|[^\\]) // Character before opening ` can't be a backslash
1080
- (`+) // $2 = Opening run of `
1081
- ( // $3 = The code block
1082
- [^\r]*?
1083
- [^`] // attacklab: work around lack of lookbehind
1084
- )
1085
- \2 // Matching closer
1086
- (?!`)
1087
- /gm, function(){...});
1088
- */
1089
-
1090
- text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
1091
- function (wholeMatch, m1, m2, m3, m4) {
1092
- var c = m3;
1093
- c = c.replace(/^([ \t]*)/g, ""); // leading whitespace
1094
- c = c.replace(/[ \t]*$/g, ""); // trailing whitespace
1095
- c = _EncodeCode(c);
1096
- return m1 + "<code>" + c + "</code>";
1097
- });
1098
-
1099
- return text;
1100
- }
1101
-
1102
- var _EncodeCode = function (text) {
1103
- //
1104
- // Encode/escape certain characters inside Markdown code runs.
1105
- // The point is that in code, these characters are literals,
1106
- // and lose their special Markdown meanings.
1107
- //
1108
- // Encode all ampersands; HTML entities are not
1109
- // entities within a Markdown code span.
1110
- text = text.replace(/&/g, "&amp;");
1111
-
1112
- // Do the angle bracket song and dance:
1113
- text = text.replace(/</g, "&lt;");
1114
- text = text.replace(/>/g, "&gt;");
1115
-
1116
- // Now, escape characters that are magic in Markdown:
1117
- text = escapeCharacters(text, "\*_{}[]\\", false);
1118
-
1119
- // jj the line above breaks this:
1120
- //---
1121
-
1122
- //* Item
1123
-
1124
- // 1. Subitem
1125
-
1126
- // special char: *
1127
- //---
1128
-
1129
- return text;
1130
- }
1131
-
1132
- var _DoItalicsAndBold = function (text) {
1133
-
1134
- // <strong> must go first:
1135
- text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
1136
- "<strong>$2</strong>");
1137
-
1138
- text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
1139
- "<em>$2</em>");
1140
-
1141
- return text;
1142
- }
1143
-
1144
- var _DoBlockQuotes = function (text) {
1145
-
1146
- /*
1147
- text = text.replace(/
1148
- ( // Wrap whole match in $1
1149
- (
1150
- ^[ \t]*>[ \t]? // '>' at the start of a line
1151
- .+\n // rest of the first line
1152
- (.+\n)* // subsequent consecutive lines
1153
- \n* // blanks
1154
- )+
1155
- )
1156
- /gm, function(){...});
1157
- */
1158
-
1159
- text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
1160
- function (wholeMatch, m1) {
1161
- var bq = m1;
1162
-
1163
- // attacklab: hack around Konqueror 3.5.4 bug:
1164
- // "----------bug".replace(/^-/g,"") == "bug"
1165
-
1166
- bq = bq.replace(/^[ \t]*>[ \t]?/gm, "~0"); // trim one level of quoting
1167
-
1168
- // attacklab: clean up hack
1169
- bq = bq.replace(/~0/g, "");
1170
-
1171
- bq = bq.replace(/^[ \t]+$/gm, ""); // trim whitespace-only lines
1172
- bq = _RunBlockGamut(bq); // recurse
1173
-
1174
- bq = bq.replace(/(^|\n)/g, "$1 ");
1175
- // These leading spaces screw with <pre> content, so we need to fix that:
1176
- bq = bq.replace(
1177
- /(\s*<pre>[^\r]+?<\/pre>)/gm,
1178
- function (wholeMatch, m1) {
1179
- var pre = m1;
1180
- // attacklab: hack around Konqueror 3.5.4 bug:
1181
- pre = pre.replace(/^ /mg, "~0");
1182
- pre = pre.replace(/~0/g, "");
1183
- return pre;
1184
- });
1185
-
1186
- return hashBlock("<blockquote>\n" + bq + "\n</blockquote>");
1187
- });
1188
- return text;
1189
- }
1190
-
1191
- var _FormParagraphs = function (text) {
1192
- //
1193
- // Params:
1194
- // $text - string to process with html <p> tags
1195
- //
1196
-
1197
- // Strip leading and trailing lines:
1198
- text = text.replace(/^\n+/g, "");
1199
- text = text.replace(/\n+$/g, "");
1200
-
1201
- var grafs = text.split(/\n{2,}/g);
1202
- var grafsOut = [];
1203
-
1204
- //
1205
- // Wrap <p> tags.
1206
- //
1207
- var end = grafs.length;
1208
- for (var i = 0; i < end; i++) {
1209
- var str = grafs[i];
1210
-
1211
- // if this is an HTML marker, copy it
1212
- if (str.search(/~K(\d+)K/g) >= 0) {
1213
- grafsOut.push(str);
1214
- }
1215
- else if (str.search(/\S/) >= 0) {
1216
- str = _RunSpanGamut(str);
1217
- str = str.replace(/^([ \t]*)/g, "<p>");
1218
- str += "</p>"
1219
- grafsOut.push(str);
1220
- }
1221
-
1222
- }
1223
-
1224
- //
1225
- // Unhashify HTML blocks
1226
- //
1227
- end = grafsOut.length;
1228
- for (var i = 0; i < end; i++) {
1229
- // if this is a marker for an html block...
1230
- while (grafsOut[i].search(/~K(\d+)K/) >= 0) {
1231
- var blockText = g_html_blocks[RegExp.$1];
1232
- blockText = blockText.replace(/\$/g, "$$$$"); // Escape any dollar signs
1233
- grafsOut[i] = grafsOut[i].replace(/~K\d+K/, blockText);
1234
- }
1235
- }
1236
-
1237
- return grafsOut.join("\n\n");
1238
- }
1239
-
1240
- var _EncodeAmpsAndAngles = function (text) {
1241
- // Smart processing for ampersands and angle brackets that need to be encoded.
1242
-
1243
- // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
1244
- // http://bumppo.net/projects/amputator/
1245
- text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&amp;");
1246
-
1247
- // Encode naked <'s
1248
- text = text.replace(/<(?![a-z\/?\$!])/gi, "&lt;");
1249
-
1250
- return text;
1251
- }
1252
-
1253
- var _EncodeBackslashEscapes = function (text) {
1254
- //
1255
- // Parameter: String.
1256
- // Returns: The string, with after processing the following backslash
1257
- // escape sequences.
1258
- //
1259
-
1260
- // attacklab: The polite way to do this is with the new
1261
- // escapeCharacters() function:
1262
- //
1263
- // text = escapeCharacters(text,"\\",true);
1264
- // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
1265
- //
1266
- // ...but we're sidestepping its use of the (slow) RegExp constructor
1267
- // as an optimization for Firefox. This function gets called a LOT.
1268
-
1269
- text = text.replace(/\\(\\)/g, escapeCharacters_callback);
1270
- text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g, escapeCharacters_callback);
1271
- return text;
1272
- }
1273
-
1274
- var _DoAutoLinks = function (text) {
1275
-
1276
- text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi, "<a href=\"$1\">$1</a>");
1277
-
1278
- // Email addresses: <address@domain.foo>
1279
-
1280
- /*
1281
- text = text.replace(/
1282
- <
1283
- (?:mailto:)?
1284
- (
1285
- [-.\w]+
1286
- \@
1287
- [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
1288
- )
1289
- >
1290
- /gi, _DoAutoLinks_callback());
1291
- */
1292
- text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
1293
- function (wholeMatch, m1) {
1294
- return _EncodeEmailAddress(_UnescapeSpecialChars(m1));
1295
- }
1296
- );
1297
-
1298
- return text;
1299
- }
1300
-
1301
- var _EncodeEmailAddress = function (addr) {
1302
- //
1303
- // Input: an email address, e.g. "foo@example.com"
1304
- //
1305
- // Output: the email address as a mailto link, with each character
1306
- // of the address encoded as either a decimal or hex entity, in
1307
- // the hopes of foiling most address harvesting spam bots. E.g.:
1308
- //
1309
- // <a href="&#x6D;&#97;&#105;&#108;&#x74;&#111;:&#102;&#111;&#111;&#64;&#101;
1310
- // x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;">&#102;&#111;&#111;
1311
- // &#64;&#101;x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;</a>
1312
- //
1313
- // Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
1314
- // mailing list: <http://tinyurl.com/yu7ue>
1315
- //
1316
-
1317
- var encode = [
1318
- function (ch) {
1319
- return "&#" + ch.charCodeAt(0) + ";";
1320
- },
1321
- function (ch) {
1322
- return "&#x" + ch.charCodeAt(0).toString(16) + ";";
1323
- },
1324
- function (ch) {
1325
- return ch;
1326
- }
1327
- ];
1328
-
1329
- addr = "mailto:" + addr;
1330
-
1331
- addr = addr.replace(/./g, function (ch) {
1332
- if (ch == "@") {
1333
- // this *must* be encoded. I insist.
1334
- ch = encode[Math.floor(Math.random() * 2)](ch);
1335
- } else if (ch != ":") {
1336
- // leave ':' alone (to spot mailto: later)
1337
- var r = Math.random();
1338
- // roughly 10% raw, 45% hex, 45% dec
1339
- ch = (
1340
- r > .9 ? encode[2](ch) :
1341
- r > .45 ? encode[1](ch) :
1342
- encode[0](ch)
1343
- );
1344
- }
1345
- return ch;
1346
- });
1347
-
1348
- addr = "<a href=\"" + addr + "\">" + addr + "</a>";
1349
- addr = addr.replace(/">.+:/g, "\">"); // strip the mailto: from the visible part
1350
-
1351
- return addr;
1352
- }
1353
-
1354
- var _UnescapeSpecialChars = function (text) {
1355
- //
1356
- // Swap back in all the special characters we've hidden.
1357
- //
1358
- text = text.replace(/~E(\d+)E/g,
1359
- function (wholeMatch, m1) {
1360
- var charCodeToReplace = parseInt(m1);
1361
- return String.fromCharCode(charCodeToReplace);
1362
- }
1363
- );
1364
- return text;
1365
- }
1366
-
1367
- var _Outdent = function (text) {
1368
- //
1369
- // Remove one level of line-leading tabs or spaces
1370
- //
1371
-
1372
- // attacklab: hack around Konqueror 3.5.4 bug:
1373
- // "----------bug".replace(/^-/g,"") == "bug"
1374
-
1375
- text = text.replace(/^(\t|[ ]{1,4})/gm, "~0"); // attacklab: g_tab_width
1376
-
1377
- // attacklab: clean up hack
1378
- text = text.replace(/~0/g, "")
1379
-
1380
- return text;
1381
- }
1382
-
1383
- var _Detab = function (text) {
1384
- // attacklab: Detab's completely rewritten for speed.
1385
- // In perl we could fix it by anchoring the regexp with \G.
1386
- // In javascript we're less fortunate.
1387
-
1388
- // expand first n-1 tabs
1389
- text = text.replace(/\t(?=\t)/g, " "); // attacklab: g_tab_width
1390
-
1391
- // replace the nth with two sentinels
1392
- text = text.replace(/\t/g, "~A~B");
1393
-
1394
- // use the sentinel to anchor our regex so it doesn't explode
1395
- text = text.replace(/~B(.+?)~A/g,
1396
- function (wholeMatch, m1, m2) {
1397
- var leadingText = m1;
1398
- var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width
1399
-
1400
- // there *must* be a better way to do this:
1401
- for (var i = 0; i < numSpaces; i++) leadingText += " ";
1402
-
1403
- return leadingText;
1404
- }
1405
- );
1406
-
1407
- // clean up sentinels
1408
- text = text.replace(/~A/g, " "); // attacklab: g_tab_width
1409
- text = text.replace(/~B/g, "");
1410
-
1411
- return text;
1412
- }
1413
-
1414
-
1415
- //
1416
- // attacklab: Utility functions
1417
- //
1418
-
1419
-
1420
- var escapeCharacters = function (text, charsToEscape, afterBackslash) {
1421
- // First we have to escape the escape characters so that
1422
- // we can build a character class out of them
1423
- var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g, "\\$1") + "])";
1424
-
1425
- if (afterBackslash) {
1426
- regexString = "\\\\" + regexString;
1427
- }
1428
-
1429
- var regex = new RegExp(regexString, "g");
1430
- text = text.replace(regex, escapeCharacters_callback);
1431
-
1432
- return text;
1433
- }
1434
-
1435
-
1436
- var escapeCharacters_callback = function (wholeMatch, m1) {
1437
- var charCodeToEscape = m1.charCodeAt(0);
1438
- return "~E" + charCodeToEscape + "E";
1439
- }
1440
-
1441
- } // end of Showdown.converter
1442
-
1443
-
1444
- // export
1445
- if (typeof module !== 'undefined') module.exports = Showdown;
1446
-
1447
- // stolen from AMD branch of underscore
1448
- // AMD define happens at the end for compatibility with AMD loaders
1449
- // that don't enforce next-turn semantics on modules.
1450
- if (typeof define === 'function' && define.amd) {
1451
- define('showdown', function () {
1452
- return Showdown;
1453
- });
1454
- }
1455
- ;/**
1456
- * Created by Tivie on 04-11-2014.
1457
- */
1458
-
1459
-
1460
- //Check if AngularJs and Showdown is defined and only load ng-Showdown if both are present
1461
- if (typeof angular !== 'undefined' && typeof Showdown !== 'undefined') {
1462
-
1463
- (function (module, Showdown) {
1464
-
1465
- module
1466
- .provider('$Showdown', provider)
1467
- .directive('sdModelToHtml', ['$Showdown', markdownToHtmlDirective])
1468
- .filter('sdStripHtml', stripHtmlFilter);
1469
-
1470
- /**
1471
- * Angular Provider
1472
- * Enables configuration of showdown via angular.config and Dependency Injection into controllers, views
1473
- * directives, etc... This assures the directives and filters provided by the library itself stay consistent
1474
- * with the user configurations.
1475
- * If the user wants to use a different configuration in a determined context, he can use the "classic" Showdown
1476
- * object instead.
1477
- *
1478
- */
1479
- function provider() {
1480
-
1481
- // Configuration parameters for Showdown
1482
- var config = {
1483
- extensions: [],
1484
- stripHtml: true
1485
- };
1486
-
1487
- /**
1488
- * Sets a configuration option
1489
- *
1490
- * @param {string} key Config parameter key
1491
- * @param {string} value Config parameter value
1492
- */
1493
- this.setOption = function (key, value) {
1494
- config.key = value;
1495
-
1496
- return this;
1497
- };
1498
-
1499
- /**
1500
- * Gets the value of the configuration parameter specified by key
1501
- *
1502
- * @param {string} key The config parameter key
1503
- * @returns {string|null} Returns the value of the config parameter. (or null if the config parameter is not set)
1504
- */
1505
- this.getOption = function (key) {
1506
- if (config.hasOwnProperty(key)) {
1507
- return config.key;
1508
- } else {
1509
- return null;
1510
- }
1511
- };
1512
-
1513
- /**
1514
- * Loads a Showdown Extension
1515
- *
1516
- * @param {string} extensionName The name of the extension to load
1517
- */
1518
- this.loadExtension = function (extensionName) {
1519
- config.extensions.push(extensionName);
1520
-
1521
- return this;
1522
- };
1523
-
1524
- function SDObject() {
1525
- var converter = new Showdown.converter(config);
1526
-
1527
- /**
1528
- * Converts a markdown text into HTML
1529
- *
1530
- * @param {string} markdown The markdown string to be converted to HTML
1531
- * @returns {string} The converted HTML
1532
- */
1533
- this.makeHtml = function (markdown) {
1534
- return converter.makeHtml(markdown);
1535
- };
1536
-
1537
- /**
1538
- * Strips a text of it's HTML tags
1539
- *
1540
- * @param {string} text
1541
- * @returns {string}
1542
- */
1543
- this.stripHtml = function (text) {
1544
- return String(text).replace(/<[^>]+>/gm, '');
1545
- };
1546
- }
1547
-
1548
- // The object returned by service provider
1549
- this.$get = function () {
1550
- return new SDObject();
1551
- };
1552
- }
1553
-
1554
- /**
1555
- * AngularJS Directive to Md to HTML transformation
1556
- *
1557
- * Usage example:
1558
- * <div sd-md-to-html-model="markdownText" ></div>
1559
- *
1560
- * @param $Showdown
1561
- * @returns {*}
1562
- */
1563
- function markdownToHtmlDirective($Showdown) {
1564
-
1565
- var link = function (scope, element) {
1566
- scope.$watch('model', function (newValue) {
1567
- var val;
1568
- if (typeof newValue === 'string') {
1569
- val = $Showdown.makeHtml(newValue);
1570
- } else {
1571
- val = typeof newValue;
1572
- }
1573
- element.html(val);
1574
- });
1575
- };
1576
-
1577
- return {
1578
- restrict: 'A',
1579
- link: link,
1580
- scope: {
1581
- model: '=sdModelToHtml'
1582
- }
1583
- }
1584
- }
1585
-
1586
- /**
1587
- * AngularJS Filter to Strip HTML tags from text
1588
- *
1589
- * @returns {Function}
1590
- */
1591
- function stripHtmlFilter() {
1592
- return function (text) {
1593
- return String(text).replace(/<[^>]+>/gm, '');
1594
- };
1595
- }
1596
-
1597
- })(angular.module('Showdown', []), Showdown);
1598
-
1599
- } else {
1600
-
1601
- /** TODO Since this library is opt out, maybe we should not throw an error so we can concatenate this
1602
- script with the main lib */
1603
- // throw new Error("ng-showdown was not loaded because one of it's dependencies (AngularJS or Showdown) wasn't met");
1604
- }
1605
-
1606
- //# sourceMappingURL=showdown.js.map