@quirekit/cm-legacy-modes 0.0.0-stage → 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (420) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -2
  3. package/README.zh-CN.md +28 -0
  4. package/THIRD_PARTY_NOTICES.md +143 -0
  5. package/UPSTREAM.json +16 -0
  6. package/dist/mode/README.md +52 -0
  7. package/dist/mode/apl.d.ts +2 -0
  8. package/dist/mode/apl.js +140 -0
  9. package/dist/mode/asciiarmor.d.ts +2 -0
  10. package/dist/mode/asciiarmor.js +54 -0
  11. package/dist/mode/asn1.d.ts +12 -0
  12. package/dist/mode/asn1.js +190 -0
  13. package/dist/mode/asterisk.d.ts +2 -0
  14. package/dist/mode/asterisk.js +186 -0
  15. package/dist/mode/brainfuck.d.ts +2 -0
  16. package/dist/mode/brainfuck.js +68 -0
  17. package/dist/mode/clike.d.ts +35 -0
  18. package/dist/mode/clike.js +1019 -0
  19. package/dist/mode/clojure.d.ts +2 -0
  20. package/dist/mode/clojure.js +272 -0
  21. package/dist/mode/cmake.d.ts +2 -0
  22. package/dist/mode/cmake.js +80 -0
  23. package/dist/mode/cobol.d.ts +2 -0
  24. package/dist/mode/cobol.js +234 -0
  25. package/dist/mode/coffeescript.d.ts +2 -0
  26. package/dist/mode/coffeescript.js +327 -0
  27. package/dist/mode/commonlisp.d.ts +2 -0
  28. package/dist/mode/commonlisp.js +107 -0
  29. package/dist/mode/crystal.d.ts +2 -0
  30. package/dist/mode/crystal.js +417 -0
  31. package/dist/mode/css.d.ts +5 -0
  32. package/dist/mode/css.js +846 -0
  33. package/dist/mode/cypher.d.ts +2 -0
  34. package/dist/mode/cypher.js +120 -0
  35. package/dist/mode/d.d.ts +2 -0
  36. package/dist/mode/d.js +203 -0
  37. package/dist/mode/diff.d.ts +2 -0
  38. package/dist/mode/diff.js +29 -0
  39. package/dist/mode/dockerfile.d.ts +2 -0
  40. package/dist/mode/dockerfile.js +198 -0
  41. package/dist/mode/dtd.d.ts +2 -0
  42. package/dist/mode/dtd.js +120 -0
  43. package/dist/mode/dylan.d.ts +2 -0
  44. package/dist/mode/dylan.js +336 -0
  45. package/dist/mode/ebnf.d.ts +2 -0
  46. package/dist/mode/ebnf.js +149 -0
  47. package/dist/mode/ecl.d.ts +2 -0
  48. package/dist/mode/ecl.js +188 -0
  49. package/dist/mode/eiffel.d.ts +2 -0
  50. package/dist/mode/eiffel.js +145 -0
  51. package/dist/mode/elm.d.ts +2 -0
  52. package/dist/mode/elm.js +228 -0
  53. package/dist/mode/erlang.d.ts +2 -0
  54. package/dist/mode/erlang.js +580 -0
  55. package/dist/mode/factor.d.ts +2 -0
  56. package/dist/mode/factor.js +63 -0
  57. package/dist/mode/fcl.d.ts +2 -0
  58. package/dist/mode/fcl.js +153 -0
  59. package/dist/mode/forth.d.ts +2 -0
  60. package/dist/mode/forth.js +162 -0
  61. package/dist/mode/fortran.d.ts +2 -0
  62. package/dist/mode/fortran.js +171 -0
  63. package/dist/mode/gas.d.ts +3 -0
  64. package/dist/mode/gas.js +342 -0
  65. package/dist/mode/gherkin.d.ts +2 -0
  66. package/dist/mode/gherkin.js +146 -0
  67. package/dist/mode/go.d.ts +2 -0
  68. package/dist/mode/go.js +163 -0
  69. package/dist/mode/groovy.d.ts +2 -0
  70. package/dist/mode/groovy.js +226 -0
  71. package/dist/mode/haskell.d.ts +2 -0
  72. package/dist/mode/haskell.js +238 -0
  73. package/dist/mode/haxe.d.ts +3 -0
  74. package/dist/mode/haxe.js +490 -0
  75. package/dist/mode/http.d.ts +2 -0
  76. package/dist/mode/http.js +87 -0
  77. package/dist/mode/idl.d.ts +2 -0
  78. package/dist/mode/idl.js +274 -0
  79. package/dist/mode/javascript.d.ts +5 -0
  80. package/dist/mode/javascript.js +922 -0
  81. package/dist/mode/jinja2.d.ts +2 -0
  82. package/dist/mode/jinja2.js +170 -0
  83. package/dist/mode/julia.d.ts +2 -0
  84. package/dist/mode/julia.js +367 -0
  85. package/dist/mode/livescript.d.ts +2 -0
  86. package/dist/mode/livescript.js +257 -0
  87. package/dist/mode/lua.d.ts +2 -0
  88. package/dist/mode/lua.js +135 -0
  89. package/dist/mode/mathematica.d.ts +2 -0
  90. package/dist/mode/mathematica.js +153 -0
  91. package/dist/mode/mbox.d.ts +2 -0
  92. package/dist/mode/mbox.js +114 -0
  93. package/dist/mode/mirc.d.ts +2 -0
  94. package/dist/mode/mirc.js +174 -0
  95. package/dist/mode/mllike.d.ts +4 -0
  96. package/dist/mode/mllike.js +346 -0
  97. package/dist/mode/modelica.d.ts +2 -0
  98. package/dist/mode/modelica.js +190 -0
  99. package/dist/mode/mscgen.d.ts +4 -0
  100. package/dist/mode/mscgen.js +147 -0
  101. package/dist/mode/mumps.d.ts +2 -0
  102. package/dist/mode/mumps.js +127 -0
  103. package/dist/mode/nginx.d.ts +2 -0
  104. package/dist/mode/nginx.js +161 -0
  105. package/dist/mode/nsis.d.ts +2 -0
  106. package/dist/mode/nsis.js +78 -0
  107. package/dist/mode/ntriples.d.ts +2 -0
  108. package/dist/mode/ntriples.js +139 -0
  109. package/dist/mode/octave.d.ts +2 -0
  110. package/dist/mode/octave.js +123 -0
  111. package/dist/mode/oz.d.ts +2 -0
  112. package/dist/mode/oz.js +233 -0
  113. package/dist/mode/pascal.d.ts +2 -0
  114. package/dist/mode/pascal.js +122 -0
  115. package/dist/mode/pegjs.d.ts +2 -0
  116. package/dist/mode/pegjs.js +85 -0
  117. package/dist/mode/perl.d.ts +2 -0
  118. package/dist/mode/perl.js +818 -0
  119. package/dist/mode/pig.d.ts +2 -0
  120. package/dist/mode/pig.js +147 -0
  121. package/dist/mode/powershell.d.ts +2 -0
  122. package/dist/mode/powershell.js +379 -0
  123. package/dist/mode/properties.d.ts +2 -0
  124. package/dist/mode/properties.js +60 -0
  125. package/dist/mode/protobuf.d.ts +2 -0
  126. package/dist/mode/protobuf.js +55 -0
  127. package/dist/mode/pug.d.ts +2 -0
  128. package/dist/mode/pug.js +502 -0
  129. package/dist/mode/puppet.d.ts +2 -0
  130. package/dist/mode/puppet.js +203 -0
  131. package/dist/mode/python.d.ts +3 -0
  132. package/dist/mode/python.js +388 -0
  133. package/dist/mode/q.d.ts +2 -0
  134. package/dist/mode/q.js +124 -0
  135. package/dist/mode/r.d.ts +2 -0
  136. package/dist/mode/r.js +172 -0
  137. package/dist/mode/rpm.d.ts +3 -0
  138. package/dist/mode/rpm.js +88 -0
  139. package/dist/mode/ruby.d.ts +2 -0
  140. package/dist/mode/ruby.js +287 -0
  141. package/dist/mode/rust.d.ts +2 -0
  142. package/dist/mode/rust.js +54 -0
  143. package/dist/mode/sas.d.ts +2 -0
  144. package/dist/mode/sas.js +266 -0
  145. package/dist/mode/sass.d.ts +2 -0
  146. package/dist/mode/sass.js +427 -0
  147. package/dist/mode/scheme.d.ts +2 -0
  148. package/dist/mode/scheme.js +261 -0
  149. package/dist/mode/shell.d.ts +2 -0
  150. package/dist/mode/shell.js +146 -0
  151. package/dist/mode/sieve.d.ts +2 -0
  152. package/dist/mode/sieve.js +176 -0
  153. package/dist/mode/simple-mode.d.ts +14 -0
  154. package/dist/mode/simple-mode.js +136 -0
  155. package/dist/mode/smalltalk.d.ts +2 -0
  156. package/dist/mode/smalltalk.js +151 -0
  157. package/dist/mode/solr.d.ts +2 -0
  158. package/dist/mode/solr.js +78 -0
  159. package/dist/mode/sparql.d.ts +2 -0
  160. package/dist/mode/sparql.js +169 -0
  161. package/dist/mode/spreadsheet.d.ts +2 -0
  162. package/dist/mode/spreadsheet.js +96 -0
  163. package/dist/mode/sql.d.ts +27 -0
  164. package/dist/mode/sql.js +481 -0
  165. package/dist/mode/stex.d.ts +3 -0
  166. package/dist/mode/stex.js +245 -0
  167. package/dist/mode/stylus.d.ts +2 -0
  168. package/dist/mode/stylus.js +747 -0
  169. package/dist/mode/swift.d.ts +2 -0
  170. package/dist/mode/swift.js +200 -0
  171. package/dist/mode/tcl.d.ts +2 -0
  172. package/dist/mode/tcl.js +123 -0
  173. package/dist/mode/textile.d.ts +2 -0
  174. package/dist/mode/textile.js +440 -0
  175. package/dist/mode/tiddlywiki.d.ts +2 -0
  176. package/dist/mode/tiddlywiki.js +277 -0
  177. package/dist/mode/tiki.d.ts +2 -0
  178. package/dist/mode/tiki.js +291 -0
  179. package/dist/mode/toml.d.ts +2 -0
  180. package/dist/mode/toml.js +74 -0
  181. package/dist/mode/troff.d.ts +2 -0
  182. package/dist/mode/troff.js +63 -0
  183. package/dist/mode/ttcn-cfg.d.ts +2 -0
  184. package/dist/mode/ttcn-cfg.js +199 -0
  185. package/dist/mode/ttcn.d.ts +2 -0
  186. package/dist/mode/ttcn.js +255 -0
  187. package/dist/mode/turtle.d.ts +2 -0
  188. package/dist/mode/turtle.js +145 -0
  189. package/dist/mode/vb.d.ts +2 -0
  190. package/dist/mode/vb.js +254 -0
  191. package/dist/mode/vbscript.d.ts +3 -0
  192. package/dist/mode/vbscript.js +320 -0
  193. package/dist/mode/velocity.d.ts +2 -0
  194. package/dist/mode/velocity.js +184 -0
  195. package/dist/mode/verilog.d.ts +3 -0
  196. package/dist/mode/verilog.js +601 -0
  197. package/dist/mode/vhdl.d.ts +2 -0
  198. package/dist/mode/vhdl.js +172 -0
  199. package/dist/mode/wast.d.ts +2 -0
  200. package/dist/mode/wast.js +119 -0
  201. package/dist/mode/webidl.d.ts +2 -0
  202. package/dist/mode/webidl.js +179 -0
  203. package/dist/mode/xml.d.ts +3 -0
  204. package/dist/mode/xml.js +397 -0
  205. package/dist/mode/xquery.d.ts +2 -0
  206. package/dist/mode/xquery.js +415 -0
  207. package/dist/mode/yacas.d.ts +2 -0
  208. package/dist/mode/yacas.js +181 -0
  209. package/dist/mode/yaml.d.ts +2 -0
  210. package/dist/mode/yaml.js +101 -0
  211. package/dist/mode/z80.d.ts +3 -0
  212. package/dist/mode/z80.js +101 -0
  213. package/mode/README.md +52 -0
  214. package/mode/apl.d.ts +2 -0
  215. package/mode/apl.js +140 -0
  216. package/mode/asciiarmor.d.ts +2 -0
  217. package/mode/asciiarmor.js +54 -0
  218. package/mode/asn1.d.ts +12 -0
  219. package/mode/asn1.js +190 -0
  220. package/mode/asterisk.d.ts +2 -0
  221. package/mode/asterisk.js +186 -0
  222. package/mode/brainfuck.d.ts +2 -0
  223. package/mode/brainfuck.js +68 -0
  224. package/mode/clike.d.ts +35 -0
  225. package/mode/clike.js +1019 -0
  226. package/mode/clojure.d.ts +2 -0
  227. package/mode/clojure.js +272 -0
  228. package/mode/cmake.d.ts +2 -0
  229. package/mode/cmake.js +80 -0
  230. package/mode/cobol.d.ts +2 -0
  231. package/mode/cobol.js +234 -0
  232. package/mode/coffeescript.d.ts +2 -0
  233. package/mode/coffeescript.js +327 -0
  234. package/mode/commonlisp.d.ts +2 -0
  235. package/mode/commonlisp.js +107 -0
  236. package/mode/crystal.d.ts +2 -0
  237. package/mode/crystal.js +417 -0
  238. package/mode/css.d.ts +5 -0
  239. package/mode/css.js +846 -0
  240. package/mode/cypher.d.ts +2 -0
  241. package/mode/cypher.js +120 -0
  242. package/mode/d.d.ts +2 -0
  243. package/mode/d.js +203 -0
  244. package/mode/diff.d.ts +2 -0
  245. package/mode/diff.js +29 -0
  246. package/mode/dockerfile.d.ts +2 -0
  247. package/mode/dockerfile.js +198 -0
  248. package/mode/dtd.d.ts +2 -0
  249. package/mode/dtd.js +120 -0
  250. package/mode/dylan.d.ts +2 -0
  251. package/mode/dylan.js +336 -0
  252. package/mode/ebnf.d.ts +2 -0
  253. package/mode/ebnf.js +149 -0
  254. package/mode/ecl.d.ts +2 -0
  255. package/mode/ecl.js +188 -0
  256. package/mode/eiffel.d.ts +2 -0
  257. package/mode/eiffel.js +145 -0
  258. package/mode/elm.d.ts +2 -0
  259. package/mode/elm.js +228 -0
  260. package/mode/erlang.d.ts +2 -0
  261. package/mode/erlang.js +580 -0
  262. package/mode/factor.d.ts +2 -0
  263. package/mode/factor.js +63 -0
  264. package/mode/fcl.d.ts +2 -0
  265. package/mode/fcl.js +153 -0
  266. package/mode/forth.d.ts +2 -0
  267. package/mode/forth.js +162 -0
  268. package/mode/fortran.d.ts +2 -0
  269. package/mode/fortran.js +171 -0
  270. package/mode/gas.d.ts +3 -0
  271. package/mode/gas.js +342 -0
  272. package/mode/gherkin.d.ts +2 -0
  273. package/mode/gherkin.js +146 -0
  274. package/mode/go.d.ts +2 -0
  275. package/mode/go.js +163 -0
  276. package/mode/groovy.d.ts +2 -0
  277. package/mode/groovy.js +226 -0
  278. package/mode/haskell.d.ts +2 -0
  279. package/mode/haskell.js +238 -0
  280. package/mode/haxe.d.ts +3 -0
  281. package/mode/haxe.js +490 -0
  282. package/mode/http.d.ts +2 -0
  283. package/mode/http.js +87 -0
  284. package/mode/idl.d.ts +2 -0
  285. package/mode/idl.js +274 -0
  286. package/mode/javascript.d.ts +5 -0
  287. package/mode/javascript.js +922 -0
  288. package/mode/jinja2.d.ts +2 -0
  289. package/mode/jinja2.js +170 -0
  290. package/mode/julia.d.ts +2 -0
  291. package/mode/julia.js +367 -0
  292. package/mode/livescript.d.ts +2 -0
  293. package/mode/livescript.js +257 -0
  294. package/mode/lua.d.ts +2 -0
  295. package/mode/lua.js +135 -0
  296. package/mode/mathematica.d.ts +2 -0
  297. package/mode/mathematica.js +153 -0
  298. package/mode/mbox.d.ts +2 -0
  299. package/mode/mbox.js +114 -0
  300. package/mode/mirc.d.ts +2 -0
  301. package/mode/mirc.js +174 -0
  302. package/mode/mllike.d.ts +4 -0
  303. package/mode/mllike.js +346 -0
  304. package/mode/modelica.d.ts +2 -0
  305. package/mode/modelica.js +190 -0
  306. package/mode/mscgen.d.ts +4 -0
  307. package/mode/mscgen.js +147 -0
  308. package/mode/mumps.d.ts +2 -0
  309. package/mode/mumps.js +127 -0
  310. package/mode/nginx.d.ts +2 -0
  311. package/mode/nginx.js +161 -0
  312. package/mode/nsis.d.ts +2 -0
  313. package/mode/nsis.js +78 -0
  314. package/mode/ntriples.d.ts +2 -0
  315. package/mode/ntriples.js +139 -0
  316. package/mode/octave.d.ts +2 -0
  317. package/mode/octave.js +123 -0
  318. package/mode/oz.d.ts +2 -0
  319. package/mode/oz.js +233 -0
  320. package/mode/pascal.d.ts +2 -0
  321. package/mode/pascal.js +122 -0
  322. package/mode/pegjs.d.ts +2 -0
  323. package/mode/pegjs.js +85 -0
  324. package/mode/perl.d.ts +2 -0
  325. package/mode/perl.js +818 -0
  326. package/mode/pig.d.ts +2 -0
  327. package/mode/pig.js +147 -0
  328. package/mode/powershell.d.ts +2 -0
  329. package/mode/powershell.js +379 -0
  330. package/mode/properties.d.ts +2 -0
  331. package/mode/properties.js +60 -0
  332. package/mode/protobuf.d.ts +2 -0
  333. package/mode/protobuf.js +55 -0
  334. package/mode/pug.d.ts +2 -0
  335. package/mode/pug.js +502 -0
  336. package/mode/puppet.d.ts +2 -0
  337. package/mode/puppet.js +203 -0
  338. package/mode/python.d.ts +3 -0
  339. package/mode/python.js +388 -0
  340. package/mode/q.d.ts +2 -0
  341. package/mode/q.js +124 -0
  342. package/mode/r.d.ts +2 -0
  343. package/mode/r.js +172 -0
  344. package/mode/rpm.d.ts +3 -0
  345. package/mode/rpm.js +88 -0
  346. package/mode/ruby.d.ts +2 -0
  347. package/mode/ruby.js +287 -0
  348. package/mode/rust.d.ts +2 -0
  349. package/mode/rust.js +54 -0
  350. package/mode/sas.d.ts +2 -0
  351. package/mode/sas.js +266 -0
  352. package/mode/sass.d.ts +2 -0
  353. package/mode/sass.js +427 -0
  354. package/mode/scheme.d.ts +2 -0
  355. package/mode/scheme.js +261 -0
  356. package/mode/shell.d.ts +2 -0
  357. package/mode/shell.js +146 -0
  358. package/mode/sieve.d.ts +2 -0
  359. package/mode/sieve.js +176 -0
  360. package/mode/simple-mode.d.ts +14 -0
  361. package/mode/simple-mode.js +136 -0
  362. package/mode/smalltalk.d.ts +2 -0
  363. package/mode/smalltalk.js +151 -0
  364. package/mode/solr.d.ts +2 -0
  365. package/mode/solr.js +78 -0
  366. package/mode/sparql.d.ts +2 -0
  367. package/mode/sparql.js +169 -0
  368. package/mode/spreadsheet.d.ts +2 -0
  369. package/mode/spreadsheet.js +96 -0
  370. package/mode/sql.d.ts +27 -0
  371. package/mode/sql.js +481 -0
  372. package/mode/stex.d.ts +3 -0
  373. package/mode/stex.js +245 -0
  374. package/mode/stylus.d.ts +2 -0
  375. package/mode/stylus.js +747 -0
  376. package/mode/swift.d.ts +2 -0
  377. package/mode/swift.js +200 -0
  378. package/mode/tcl.d.ts +2 -0
  379. package/mode/tcl.js +123 -0
  380. package/mode/textile.d.ts +2 -0
  381. package/mode/textile.js +440 -0
  382. package/mode/tiddlywiki.d.ts +2 -0
  383. package/mode/tiddlywiki.js +277 -0
  384. package/mode/tiki.d.ts +2 -0
  385. package/mode/tiki.js +291 -0
  386. package/mode/toml.d.ts +2 -0
  387. package/mode/toml.js +74 -0
  388. package/mode/troff.d.ts +2 -0
  389. package/mode/troff.js +63 -0
  390. package/mode/ttcn-cfg.d.ts +2 -0
  391. package/mode/ttcn-cfg.js +199 -0
  392. package/mode/ttcn.d.ts +2 -0
  393. package/mode/ttcn.js +255 -0
  394. package/mode/turtle.d.ts +2 -0
  395. package/mode/turtle.js +145 -0
  396. package/mode/vb.d.ts +2 -0
  397. package/mode/vb.js +254 -0
  398. package/mode/vbscript.d.ts +3 -0
  399. package/mode/vbscript.js +320 -0
  400. package/mode/velocity.d.ts +2 -0
  401. package/mode/velocity.js +184 -0
  402. package/mode/verilog.d.ts +3 -0
  403. package/mode/verilog.js +601 -0
  404. package/mode/vhdl.d.ts +2 -0
  405. package/mode/vhdl.js +172 -0
  406. package/mode/wast.d.ts +2 -0
  407. package/mode/wast.js +119 -0
  408. package/mode/webidl.d.ts +2 -0
  409. package/mode/webidl.js +179 -0
  410. package/mode/xml.d.ts +3 -0
  411. package/mode/xml.js +397 -0
  412. package/mode/xquery.d.ts +2 -0
  413. package/mode/xquery.js +415 -0
  414. package/mode/yacas.d.ts +2 -0
  415. package/mode/yacas.js +181 -0
  416. package/mode/yaml.d.ts +2 -0
  417. package/mode/yaml.js +101 -0
  418. package/mode/z80.d.ts +3 -0
  419. package/mode/z80.js +101 -0
  420. package/package.json +37 -3
@@ -0,0 +1,277 @@
1
+ // Tokenizer
2
+ var textwords = {};
3
+
4
+ var keywords = {
5
+ "allTags": true, "closeAll": true, "list": true,
6
+ "newJournal": true, "newTiddler": true,
7
+ "permaview": true, "saveChanges": true,
8
+ "search": true, "slider": true, "tabs": true,
9
+ "tag": true, "tagging": true, "tags": true,
10
+ "tiddler": true, "timeline": true,
11
+ "today": true, "version": true, "option": true,
12
+ "with": true, "filter": true
13
+ };
14
+
15
+ var isSpaceName = /[\w_\-]/i,
16
+ reHR = /^\-\-\-\-+$/, // <hr>
17
+ reWikiCommentStart = /^\/\*\*\*$/, // /***
18
+ reWikiCommentStop = /^\*\*\*\/$/, // ***/
19
+ reBlockQuote = /^<<<$/,
20
+
21
+ reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start
22
+ reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop
23
+ reXmlCodeStart = /^<!--\{\{\{-->$/, // xml block start
24
+ reXmlCodeStop = /^<!--\}\}\}-->$/, // xml stop
25
+
26
+ reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
27
+ reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
28
+
29
+ reUntilCodeStop = /.*?\}\}\}/;
30
+
31
+ function chain(stream, state, f) {
32
+ state.tokenize = f;
33
+ return f(stream, state);
34
+ }
35
+
36
+ function tokenBase(stream, state) {
37
+ var sol = stream.sol(), ch = stream.peek();
38
+
39
+ state.block = false; // indicates the start of a code block.
40
+
41
+ // check start of blocks
42
+ if (sol && /[<\/\*{}\-]/.test(ch)) {
43
+ if (stream.match(reCodeBlockStart)) {
44
+ state.block = true;
45
+ return chain(stream, state, twTokenCode);
46
+ }
47
+ if (stream.match(reBlockQuote))
48
+ return 'quote';
49
+ if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop))
50
+ return 'comment';
51
+ if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop))
52
+ return 'comment';
53
+ if (stream.match(reHR))
54
+ return 'contentSeparator';
55
+ }
56
+
57
+ stream.next();
58
+ if (sol && /[\/\*!#;:>|]/.test(ch)) {
59
+ if (ch == "!") { // tw header
60
+ stream.skipToEnd();
61
+ return "header";
62
+ }
63
+ if (ch == "*") { // tw list
64
+ stream.eatWhile('*');
65
+ return "comment";
66
+ }
67
+ if (ch == "#") { // tw numbered list
68
+ stream.eatWhile('#');
69
+ return "comment";
70
+ }
71
+ if (ch == ";") { // definition list, term
72
+ stream.eatWhile(';');
73
+ return "comment";
74
+ }
75
+ if (ch == ":") { // definition list, description
76
+ stream.eatWhile(':');
77
+ return "comment";
78
+ }
79
+ if (ch == ">") { // single line quote
80
+ stream.eatWhile(">");
81
+ return "quote";
82
+ }
83
+ if (ch == '|')
84
+ return 'header';
85
+ }
86
+
87
+ if (ch == '{' && stream.match('{{'))
88
+ return chain(stream, state, twTokenCode);
89
+
90
+ // rudimentary html:// file:// link matching. TW knows much more ...
91
+ if (/[hf]/i.test(ch) &&
92
+ /[ti]/i.test(stream.peek()) &&
93
+ stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i))
94
+ return "link";
95
+
96
+ // just a little string indicator, don't want to have the whole string covered
97
+ if (ch == '"')
98
+ return 'string';
99
+
100
+ if (ch == '~') // _no_ CamelCase indicator should be bold
101
+ return 'brace';
102
+
103
+ if (/[\[\]]/.test(ch) && stream.match(ch)) // check for [[..]]
104
+ return 'brace';
105
+
106
+ if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
107
+ stream.eatWhile(isSpaceName);
108
+ return "link";
109
+ }
110
+
111
+ if (/\d/.test(ch)) { // numbers
112
+ stream.eatWhile(/\d/);
113
+ return "number";
114
+ }
115
+
116
+ if (ch == "/") { // tw invisible comment
117
+ if (stream.eat("%")) {
118
+ return chain(stream, state, twTokenComment);
119
+ } else if (stream.eat("/")) { //
120
+ return chain(stream, state, twTokenEm);
121
+ }
122
+ }
123
+
124
+ if (ch == "_" && stream.eat("_")) // tw underline
125
+ return chain(stream, state, twTokenUnderline);
126
+
127
+ // strikethrough and mdash handling
128
+ if (ch == "-" && stream.eat("-")) {
129
+ // if strikethrough looks ugly, change CSS.
130
+ if (stream.peek() != ' ')
131
+ return chain(stream, state, twTokenStrike);
132
+ // mdash
133
+ if (stream.peek() == ' ')
134
+ return 'brace';
135
+ }
136
+
137
+ if (ch == "'" && stream.eat("'")) // tw bold
138
+ return chain(stream, state, twTokenStrong);
139
+
140
+ if (ch == "<" && stream.eat("<")) // tw macro
141
+ return chain(stream, state, twTokenMacro);
142
+
143
+ // core macro handling
144
+ stream.eatWhile(/[\w\$_]/);
145
+ return textwords.propertyIsEnumerable(stream.current()) ? "keyword" : null
146
+ }
147
+
148
+ // tw invisible comment
149
+ function twTokenComment(stream, state) {
150
+ var maybeEnd = false, ch;
151
+ while (ch = stream.next()) {
152
+ if (ch == "/" && maybeEnd) {
153
+ state.tokenize = tokenBase;
154
+ break;
155
+ }
156
+ maybeEnd = (ch == "%");
157
+ }
158
+ return "comment";
159
+ }
160
+
161
+ // tw strong / bold
162
+ function twTokenStrong(stream, state) {
163
+ var maybeEnd = false,
164
+ ch;
165
+ while (ch = stream.next()) {
166
+ if (ch == "'" && maybeEnd) {
167
+ state.tokenize = tokenBase;
168
+ break;
169
+ }
170
+ maybeEnd = (ch == "'");
171
+ }
172
+ return "strong";
173
+ }
174
+
175
+ // tw code
176
+ function twTokenCode(stream, state) {
177
+ var sb = state.block;
178
+
179
+ if (sb && stream.current()) {
180
+ return "comment";
181
+ }
182
+
183
+ if (!sb && stream.match(reUntilCodeStop)) {
184
+ state.tokenize = tokenBase;
185
+ return "comment";
186
+ }
187
+
188
+ if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
189
+ state.tokenize = tokenBase;
190
+ return "comment";
191
+ }
192
+
193
+ stream.next();
194
+ return "comment";
195
+ }
196
+
197
+ // tw em / italic
198
+ function twTokenEm(stream, state) {
199
+ var maybeEnd = false,
200
+ ch;
201
+ while (ch = stream.next()) {
202
+ if (ch == "/" && maybeEnd) {
203
+ state.tokenize = tokenBase;
204
+ break;
205
+ }
206
+ maybeEnd = (ch == "/");
207
+ }
208
+ return "emphasis";
209
+ }
210
+
211
+ // tw underlined text
212
+ function twTokenUnderline(stream, state) {
213
+ var maybeEnd = false,
214
+ ch;
215
+ while (ch = stream.next()) {
216
+ if (ch == "_" && maybeEnd) {
217
+ state.tokenize = tokenBase;
218
+ break;
219
+ }
220
+ maybeEnd = (ch == "_");
221
+ }
222
+ return "link";
223
+ }
224
+
225
+ // tw strike through text looks ugly
226
+ // change CSS if needed
227
+ function twTokenStrike(stream, state) {
228
+ var maybeEnd = false, ch;
229
+
230
+ while (ch = stream.next()) {
231
+ if (ch == "-" && maybeEnd) {
232
+ state.tokenize = tokenBase;
233
+ break;
234
+ }
235
+ maybeEnd = (ch == "-");
236
+ }
237
+ return "deleted";
238
+ }
239
+
240
+ // macro
241
+ function twTokenMacro(stream, state) {
242
+ if (stream.current() == '<<') {
243
+ return 'meta';
244
+ }
245
+
246
+ var ch = stream.next();
247
+ if (!ch) {
248
+ state.tokenize = tokenBase;
249
+ return null;
250
+ }
251
+ if (ch == ">") {
252
+ if (stream.peek() == '>') {
253
+ stream.next();
254
+ state.tokenize = tokenBase;
255
+ return "meta";
256
+ }
257
+ }
258
+
259
+ stream.eatWhile(/[\w\$_]/);
260
+ return keywords.propertyIsEnumerable(stream.current()) ? "keyword" : null
261
+ }
262
+
263
+ // Interface
264
+ export const tiddlyWiki = {
265
+ name: "tiddlywiki",
266
+
267
+ startState: function () {
268
+ return {tokenize: tokenBase};
269
+ },
270
+
271
+ token: function (stream, state) {
272
+ if (stream.eatSpace()) return null;
273
+ var style = state.tokenize(stream, state);
274
+ return style;
275
+ }
276
+ };
277
+
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const tiki: StreamParser<unknown>
@@ -0,0 +1,291 @@
1
+ function inBlock(style, terminator, returnTokenizer) {
2
+ return function(stream, state) {
3
+ while (!stream.eol()) {
4
+ if (stream.match(terminator)) {
5
+ state.tokenize = inText;
6
+ break;
7
+ }
8
+ stream.next();
9
+ }
10
+
11
+ if (returnTokenizer) state.tokenize = returnTokenizer;
12
+
13
+ return style;
14
+ };
15
+ }
16
+
17
+ function inLine(style) {
18
+ return function(stream, state) {
19
+ while(!stream.eol()) {
20
+ stream.next();
21
+ }
22
+ state.tokenize = inText;
23
+ return style;
24
+ };
25
+ }
26
+
27
+ function inText(stream, state) {
28
+ function chain(parser) {
29
+ state.tokenize = parser;
30
+ return parser(stream, state);
31
+ }
32
+
33
+ var sol = stream.sol();
34
+ var ch = stream.next();
35
+
36
+ //non start of line
37
+ switch (ch) { //switch is generally much faster than if, so it is used here
38
+ case "{": //plugin
39
+ stream.eat("/");
40
+ stream.eatSpace();
41
+ stream.eatWhile(/[^\s\u00a0=\"\'\/?(}]/);
42
+ state.tokenize = inPlugin;
43
+ return "tag";
44
+ case "_": //bold
45
+ if (stream.eat("_"))
46
+ return chain(inBlock("strong", "__", inText));
47
+ break;
48
+ case "'": //italics
49
+ if (stream.eat("'"))
50
+ return chain(inBlock("em", "''", inText));
51
+ break;
52
+ case "(":// Wiki Link
53
+ if (stream.eat("("))
54
+ return chain(inBlock("link", "))", inText));
55
+ break;
56
+ case "[":// Weblink
57
+ return chain(inBlock("url", "]", inText));
58
+ break;
59
+ case "|": //table
60
+ if (stream.eat("|"))
61
+ return chain(inBlock("comment", "||"));
62
+ break;
63
+ case "-":
64
+ if (stream.eat("=")) {//titleBar
65
+ return chain(inBlock("header string", "=-", inText));
66
+ } else if (stream.eat("-")) {//deleted
67
+ return chain(inBlock("error tw-deleted", "--", inText));
68
+ }
69
+ break;
70
+ case "=": //underline
71
+ if (stream.match("=="))
72
+ return chain(inBlock("tw-underline", "===", inText));
73
+ break;
74
+ case ":":
75
+ if (stream.eat(":"))
76
+ return chain(inBlock("comment", "::"));
77
+ break;
78
+ case "^": //box
79
+ return chain(inBlock("tw-box", "^"));
80
+ break;
81
+ case "~": //np
82
+ if (stream.match("np~"))
83
+ return chain(inBlock("meta", "~/np~"));
84
+ break;
85
+ }
86
+
87
+ //start of line types
88
+ if (sol) {
89
+ switch (ch) {
90
+ case "!": //header at start of line
91
+ if (stream.match('!!!!!')) {
92
+ return chain(inLine("header string"));
93
+ } else if (stream.match('!!!!')) {
94
+ return chain(inLine("header string"));
95
+ } else if (stream.match('!!!')) {
96
+ return chain(inLine("header string"));
97
+ } else if (stream.match('!!')) {
98
+ return chain(inLine("header string"));
99
+ } else {
100
+ return chain(inLine("header string"));
101
+ }
102
+ break;
103
+ case "*": //unordered list line item, or <li /> at start of line
104
+ case "#": //ordered list line item, or <li /> at start of line
105
+ case "+": //ordered list line item, or <li /> at start of line
106
+ return chain(inLine("tw-listitem bracket"));
107
+ break;
108
+ }
109
+ }
110
+
111
+ //stream.eatWhile(/[&{]/); was eating up plugins, turned off to act less like html and more like tiki
112
+ return null;
113
+ }
114
+
115
+ // Return variables for tokenizers
116
+ var pluginName, type;
117
+ function inPlugin(stream, state) {
118
+ var ch = stream.next();
119
+ var peek = stream.peek();
120
+
121
+ if (ch == "}") {
122
+ state.tokenize = inText;
123
+ //type = ch == ")" ? "endPlugin" : "selfclosePlugin"; inPlugin
124
+ return "tag";
125
+ } else if (ch == "(" || ch == ")") {
126
+ return "bracket";
127
+ } else if (ch == "=") {
128
+ type = "equals";
129
+
130
+ if (peek == ">") {
131
+ stream.next();
132
+ peek = stream.peek();
133
+ }
134
+
135
+ //here we detect values directly after equal character with no quotes
136
+ if (!/[\'\"]/.test(peek)) {
137
+ state.tokenize = inAttributeNoQuote();
138
+ }
139
+ //end detect values
140
+
141
+ return "operator";
142
+ } else if (/[\'\"]/.test(ch)) {
143
+ state.tokenize = inAttribute(ch);
144
+ return state.tokenize(stream, state);
145
+ } else {
146
+ stream.eatWhile(/[^\s\u00a0=\"\'\/?]/);
147
+ return "keyword";
148
+ }
149
+ }
150
+
151
+ function inAttribute(quote) {
152
+ return function(stream, state) {
153
+ while (!stream.eol()) {
154
+ if (stream.next() == quote) {
155
+ state.tokenize = inPlugin;
156
+ break;
157
+ }
158
+ }
159
+ return "string";
160
+ };
161
+ }
162
+
163
+ function inAttributeNoQuote() {
164
+ return function(stream, state) {
165
+ while (!stream.eol()) {
166
+ var ch = stream.next();
167
+ var peek = stream.peek();
168
+ if (ch == " " || ch == "," || /[ )}]/.test(peek)) {
169
+ state.tokenize = inPlugin;
170
+ break;
171
+ }
172
+ }
173
+ return "string";
174
+ };
175
+ }
176
+
177
+ var curState, setStyle;
178
+ function pass() {
179
+ for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
180
+ }
181
+
182
+ function cont() {
183
+ pass.apply(null, arguments);
184
+ return true;
185
+ }
186
+
187
+ function pushContext(pluginName, startOfLine) {
188
+ var noIndent = curState.context && curState.context.noIndent;
189
+ curState.context = {
190
+ prev: curState.context,
191
+ pluginName: pluginName,
192
+ indent: curState.indented,
193
+ startOfLine: startOfLine,
194
+ noIndent: noIndent
195
+ };
196
+ }
197
+
198
+ function popContext() {
199
+ if (curState.context) curState.context = curState.context.prev;
200
+ }
201
+
202
+ function element(type) {
203
+ if (type == "openPlugin") {curState.pluginName = pluginName; return cont(attributes, endplugin(curState.startOfLine));}
204
+ else if (type == "closePlugin") {
205
+ var err = false;
206
+ if (curState.context) {
207
+ err = curState.context.pluginName != pluginName;
208
+ popContext();
209
+ } else {
210
+ err = true;
211
+ }
212
+ if (err) setStyle = "error";
213
+ return cont(endcloseplugin(err));
214
+ }
215
+ else if (type == "string") {
216
+ if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
217
+ if (curState.tokenize == inText) popContext();
218
+ return cont();
219
+ }
220
+ else return cont();
221
+ }
222
+
223
+ function endplugin(startOfLine) {
224
+ return function(type) {
225
+ if (
226
+ type == "selfclosePlugin" ||
227
+ type == "endPlugin"
228
+ )
229
+ return cont();
230
+ if (type == "endPlugin") {pushContext(curState.pluginName, startOfLine); return cont();}
231
+ return cont();
232
+ };
233
+ }
234
+
235
+ function endcloseplugin(err) {
236
+ return function(type) {
237
+ if (err) setStyle = "error";
238
+ if (type == "endPlugin") return cont();
239
+ return pass();
240
+ };
241
+ }
242
+
243
+ function attributes(type) {
244
+ if (type == "keyword") {setStyle = "attribute"; return cont(attributes);}
245
+ if (type == "equals") return cont(attvalue, attributes);
246
+ return pass();
247
+ }
248
+ function attvalue(type) {
249
+ if (type == "keyword") {setStyle = "string"; return cont();}
250
+ if (type == "string") return cont(attvaluemaybe);
251
+ return pass();
252
+ }
253
+ function attvaluemaybe(type) {
254
+ if (type == "string") return cont(attvaluemaybe);
255
+ else return pass();
256
+ }
257
+ export const tiki = {
258
+ name: "tiki",
259
+ startState: function() {
260
+ return {tokenize: inText, cc: [], indented: 0, startOfLine: true, pluginName: null, context: null};
261
+ },
262
+ token: function(stream, state) {
263
+ if (stream.sol()) {
264
+ state.startOfLine = true;
265
+ state.indented = stream.indentation();
266
+ }
267
+ if (stream.eatSpace()) return null;
268
+
269
+ setStyle = type = pluginName = null;
270
+ var style = state.tokenize(stream, state);
271
+ if ((style || type) && style != "comment") {
272
+ curState = state;
273
+ while (true) {
274
+ var comb = state.cc.pop() || element;
275
+ if (comb(type || style)) break;
276
+ }
277
+ }
278
+ state.startOfLine = false;
279
+ return setStyle || style;
280
+ },
281
+ indent: function(state, textAfter, cx) {
282
+ var context = state.context;
283
+ if (context && context.noIndent) return 0;
284
+ if (context && /^{\//.test(textAfter))
285
+ context = context.prev;
286
+ while (context && !context.startOfLine)
287
+ context = context.prev;
288
+ if (context) return context.indent + cx.unit;
289
+ else return 0;
290
+ }
291
+ };
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const toml: StreamParser<unknown>
@@ -0,0 +1,74 @@
1
+ export const toml = {
2
+ name: "toml",
3
+ startState: function () {
4
+ return {
5
+ inString: false,
6
+ stringType: "",
7
+ lhs: true,
8
+ inArray: 0
9
+ };
10
+ },
11
+ token: function (stream, state) {
12
+ //check for state changes
13
+ let quote
14
+ if (!state.inString && (quote = stream.match(/^('''|"""|'|")/))) {
15
+ state.stringType = quote[0]
16
+ state.inString = true; // Update state
17
+ }
18
+ if (stream.sol() && !state.inString && state.inArray === 0) {
19
+ state.lhs = true;
20
+ }
21
+ //return state
22
+ if (state.inString) {
23
+ while (state.inString) {
24
+ if (stream.match(state.stringType)) {
25
+ state.inString = false; // Clear flag
26
+ } else if (stream.peek() === '\\') {
27
+ stream.next();
28
+ stream.next();
29
+ } else if (stream.eol()) {
30
+ break
31
+ } else {
32
+ stream.match(/^.[^\\\"\']*/);
33
+ }
34
+ }
35
+ return state.lhs ? "property" : "string"; // Token style
36
+ } else if (state.inArray && stream.peek() === ']') {
37
+ stream.next();
38
+ state.inArray--;
39
+ return 'bracket';
40
+ } else if (state.lhs && stream.peek() === '[' && stream.skipTo(']')) {
41
+ stream.next();//skip closing ]
42
+ // array of objects has an extra open & close []
43
+ if (stream.peek() === ']') stream.next();
44
+ return "atom";
45
+ } else if (stream.peek() === "#") {
46
+ stream.skipToEnd();
47
+ return "comment";
48
+ } else if (stream.eatSpace()) {
49
+ return null;
50
+ } else if (state.lhs && stream.eatWhile(function (c) { return c != '=' && c != ' '; })) {
51
+ return "property";
52
+ } else if (state.lhs && stream.peek() === "=") {
53
+ stream.next();
54
+ state.lhs = false;
55
+ return null;
56
+ } else if (!state.lhs && stream.match(/^\d\d\d\d[\d\-\:\.T]*Z/)) {
57
+ return 'atom'; //date
58
+ } else if (!state.lhs && (stream.match('true') || stream.match('false'))) {
59
+ return 'atom';
60
+ } else if (!state.lhs && stream.peek() === '[') {
61
+ state.inArray++;
62
+ stream.next();
63
+ return 'bracket';
64
+ } else if (!state.lhs && stream.match(/^\-?\d+(?:\.\d+)?/)) {
65
+ return 'number';
66
+ } else if (!stream.eatSpace()) {
67
+ stream.next();
68
+ }
69
+ return null;
70
+ },
71
+ languageData: {
72
+ commentTokens: { line: '#' },
73
+ },
74
+ };
@@ -0,0 +1,2 @@
1
+ import {StreamParser} from "@quirekit/cm-language"
2
+ export declare const troff: StreamParser<unknown>