Guest User

Untitled

a guest
Feb 19th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.01 KB | None | 0 0
  1. { scopeName = 'text.html.markdown';
  2. fileTypes = ( 'markdown', 'mdown', 'markdn', 'md' );
  3. foldingStartMarker = '(?x)
  4. (<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\b.*?>
  5. |<!--(?!.*-->)
  6. |\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/)))
  7. )';
  8. foldingStopMarker = '(?x)
  9. (</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)>
  10. |^\s*-->
  11. |(^|\s)\}
  12. )';
  13. patterns = (
  14. { name = 'meta.separator.markdown';
  15. match = '^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$\n?';
  16. },
  17. { name = 'meta.separator.markdown';
  18. match = '^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$\n?';
  19. },
  20. { name = 'meta.separator.markdown';
  21. match = '^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$\n?';
  22. },
  23. { name = 'markup.heading.markdown';
  24. match = '^#{1,6}\s*(.*?)\s*#*$';
  25. captures = { 1 = { name = 'entity.name.function'; }; };
  26. },
  27. { name = 'markup.list.unnumbered';
  28. begin = '^\s{0,3}[*+-](?=\s)';
  29. end = '^(?=\S)';
  30. patterns = ( { include = '#list-paragraph'; } );
  31. },
  32. { name = 'markup.list.numbered';
  33. begin = '^\s{0,3}[0-9]+\.(?=\s)';
  34. end = '^(?=\S)';
  35. patterns = ( { include = '#list-paragraph'; } );
  36. },
  37. { name = 'markup.quote.markdown';
  38. begin = '^\s*>';
  39. end = '^\s*$';
  40. patterns = ( { include = '#inline'; } );
  41. },
  42. { name = 'markup.raw.block.markdown';
  43. begin = ' {4,}|\t';
  44. end = '^\s*$';
  45. },
  46. { name = 'meta.disable-markdown';
  47. comment = "Markdown formatting is disabled inside block-level tags. We only do that when a tag is at the start of a line (which only contains that tag). It would be better to list exactly which tags this should happen for (but I'm lazy) -- Allan";
  48. begin = '^(?=<(\w+)[^>]*(?<!/)>$)';
  49. end = '(?<=^</\1>$\n)';
  50. patterns = ( { include = 'text.html.basic'; } );
  51. },
  52. { name = 'meta.link.reference.def.markdown';
  53. match = '(?x:
  54. \s* # Leading whitespace
  55. \[(.+?)\]: # Reference name
  56. [ \t]* # Optional whitespace
  57. <?(\S+?)>? # The url
  58. [ \t]* # Optional whitespace
  59. (?:
  60. (\(.+?\)) # Match title in quotes…
  61. | (".+?") # or in parens.
  62. | (''.+?'')
  63. )? # Title is optional
  64. \s* # Optional whitespace
  65. $
  66. )';
  67. captures =
  68. { 1 = { name = 'constant.other.reference.link.markdown'; };
  69. 2 = { name = 'markup.underline.link.markdown'; };
  70. 3 = { name = 'string.other.link.description.title.markdown'; };
  71. 4 = { name = 'string.other.link.description.title.markdown'; };
  72. 5 = { name = 'string.other.link.description.title.markdown'; };
  73. };
  74. },
  75. { name = 'meta.paragraph.markdown';
  76. begin = '^(?=\S)(?!^[=-]{3,}(?=$))';
  77. end = '(^(?:\s*$|(?=\s*>))|(?<=^===|^====|=====)[ \t]*\n|(?<=^---|^----|-----)[ \t]*\n)';
  78. patterns = (
  79. { include = '#inline'; },
  80. { include = 'text.html.basic'; },
  81. { name = 'markup.heading.1.markdown';
  82. match = '^={3,}(?=[ \t]*$)';
  83. },
  84. { name = 'markup.heading.2.markdown';
  85. match = '^-{3,}(?=[ \t]*$)';
  86. },
  87. );
  88. },
  89. );
  90. repository = {
  91. inline = {
  92. patterns = (
  93. { include = '#escape'; },
  94. { include = '#ampersand'; },
  95. { include = '#raw'; },
  96. { include = '#bold'; },
  97. { include = '#italic'; },
  98. { include = '#line-break'; },
  99. { include = '#image-inline'; },
  100. { include = '#link-inline'; },
  101. { include = '#link-inet'; },
  102. { include = '#link-email'; },
  103. { include = '#image-ref'; },
  104. { include = '#link-ref-literal'; },
  105. { include = '#link-ref'; },
  106. );
  107. };
  108. escape = {
  109. name = 'constant.character.escape.markdown';
  110. match = '\\[-`*_#+.!(){}\[\]\\]';
  111. };
  112. ampersand = {
  113. name = 'meta.other.valid-ampersand.markdown';
  114. comment = "Markdown will convert this for us. We match it so that the HTML grammar won't mark it up as invalid.";
  115. match = '&(?!([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);)';
  116. };
  117. raw = {
  118. patterns = (
  119. { name = 'markup.raw.inline.markdown';
  120. match = '``.*?``';
  121. },
  122. { name = 'markup.raw.inline.markdown';
  123. match = '`([^\\`]|\\.)*?`';
  124. },
  125. );
  126. };
  127. bold = {
  128. name = 'markup.bold.markdown';
  129. begin = '(?x)
  130. (\*\*|__)(?=\S) # Open
  131. (?=
  132. (
  133. [^\<`\[\\] # Ignore html tags and
  134. # raw states.
  135. | <[^>]*+> # HTML tags
  136. | <(?=[^>\n]*+$) # Open bracket otherwise
  137. | ``([^`]|`(?!`))*+`` # Raw v1
  138. | `([^\\`]|\\.)*+` # Raw v2
  139. | \\[\\`*_{}\[\]()#.!] # Escapes
  140. | \\(?=[^\\`*_{}\[\]()#.!]) # Slash no an escape
  141. | \[
  142. (?<link>
  143. (?<square> # Named group
  144. [^\[\]\\] # Match most chars
  145. | \\. # Escaped chars
  146. | \[ \g<square>*+ \] # Nested brackets
  147. )*+
  148. \]
  149. (
  150. ( # Reference Link
  151. [ ]? # Optional space
  152. \[[^\]]*+\] # Ref name
  153. )
  154. | ( # Inline Link
  155. \( # Opening paren
  156. [ \t]*+ # Optional whtiespace
  157. <?(.*?)>? # URL
  158. [ \t]*+ # Optional whtiespace
  159. ( # Optional Title
  160. (?<title>[''"])
  161. (.*?)
  162. \k<title>
  163. )?
  164. \)
  165. )
  166. )
  167. )
  168. | \[(?!\g<link>)
  169. )*?
  170. (?<!
  171. [^\\]\\ # Crazy check for
  172. | [^\\]\\\\\\ # escapes before the
  173. | [^\\]\\\\\\\\\\ # end condition.
  174. )
  175. (?<=\S)\1 # Close
  176. )
  177. ';
  178. end = '(?<=\S)\1';
  179. patterns = (
  180. { begin = '(?=<[^>]*?>)';
  181. end = '(?<=>)';
  182. patterns = (
  183. { include = 'text.html.basic'; },
  184. );
  185. },
  186. { name = 'markup.italic.markdown';
  187. comment = 'Match simple italics for speed';
  188. match = '(\*|_)(?=\S)[-a-zA-Z0-9. ]+?(?<=\S)\1';
  189. },
  190. { include = '#escape'; },
  191. { include = '#ampersand'; },
  192. { include = '#raw'; },
  193. { include = '#italic'; },
  194. { include = '#image-inline'; },
  195. { include = '#link-inline'; },
  196. { include = '#link-inet'; },
  197. { include = '#link-email'; },
  198. { include = '#image-ref'; },
  199. { include = '#link-ref-literal'; },
  200. { include = '#link-ref'; },
  201. );
  202. };
  203. italic = {
  204. name = 'markup.italic.markdown';
  205. begin = '(\*|_)(?=\S)(?=(.+?[*_]*)(?<![^\\]\\|[^\\]\\\\\\|[^\\]\\\\\\\\\\)(?<=\S)\1)';
  206. end = '(?<=\S)\1';
  207. patterns = (
  208. { begin = '(?=<[^>]*?>)';
  209. end = '(?<=>)';
  210. patterns = (
  211. { include = 'text.html.basic'; },
  212. );
  213. },
  214. { name = 'markup.bold.markdown';
  215. comment = 'Match simple bolds for speed';
  216. match = '(\*\*|__)(?=\S)[-a-zA-Z0-9. ]+?(?<=\S)\1';
  217. },
  218. { include = '#escape'; },
  219. { include = '#ampersand'; },
  220. { include = '#raw'; },
  221. { include = '#bold'; },
  222. { include = '#image-inline'; },
  223. { include = '#link-inline'; },
  224. { include = '#link-inet'; },
  225. { include = '#link-email'; },
  226. { include = '#image-ref'; },
  227. { include = '#link-ref-literal'; },
  228. { include = '#link-ref'; },
  229. );
  230. };
  231. line-break = {
  232. name = 'meta.dummy.line-break';
  233. match = ' {2,}$';
  234. };
  235. image-inline = {
  236. name = 'meta.image.inline.markdown';
  237. match = '(?x:
  238. \! # Images start with !
  239. \[([^\]]*?)\] # Match the link text.
  240. ([ ]?) # Space not allowed
  241. \( # Opening paren for url
  242. <?(\S+?)>? # The url
  243. [ \t]* # Optional whitespace
  244. (?:
  245. (\(.+?\)) # Match title in parens…
  246. | (".+?") # or in quotes.
  247. )? # Title is optional
  248. \s* # Optional whitespace
  249. \)
  250. )';
  251. captures =
  252. { 1 = { name = 'string.other.link.description.markdown'; };
  253. 2 = { name = 'invalid.illegal.whitespace.markdown'; };
  254. 3 = { name = 'markup.underline.link.image.markdown'; };
  255. 4 = { name = 'string.other.link.description.title.markdown'; };
  256. 5 = { name = 'string.other.link.description.title.markdown'; };
  257. };
  258. };
  259. link-inline = {
  260. name = 'meta.link.inline.markdown';
  261. match = '(?x:
  262. \[([^\]]*?)\] # Match the link text.
  263. ([ ]?) # Space not allowed
  264. \( # Opening paren for url
  265. <?(\S*?)>? # The url
  266. [ \t]* # Optional whitespace
  267. (?:
  268. (\(.+?\)) # Match title in parens…
  269. | (".+?") # or in quotes.
  270. )? # Title is optional
  271. \s* # Optional whitespace
  272. \)
  273. )';
  274. captures =
  275. { 1 = { name = 'string.other.link.title.markdown'; };
  276. 2 = { name = 'invalid.illegal.whitespace.markdown'; };
  277. 3 = { name = 'markup.underline.link.markdown'; };
  278. 4 = { name = 'string.other.link.description.title.markdown'; };
  279. 5 = { name = 'string.other.link.description.title.markdown'; };
  280. };
  281. };
  282. link-inet = {
  283. name = 'meta.link.inet.markdown';
  284. match = '<((?:https?|ftp)://.*?)>';
  285. captures = { 1 = { name = 'markup.underline.link.markdown'; }; };
  286. };
  287. link-email = {
  288. name = 'meta.link.email.lt-gt.markdown';
  289. match = '<((?:mailto:)?[-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>';
  290. captures = { 1 = { name = 'markup.underline.link.markdown'; }; };
  291. };
  292. image-ref = {
  293. name = 'meta.image.reference.markdown';
  294. match = '\!\[(.*?)\] *\[(.*?)\]';
  295. captures =
  296. { 1 = { name = 'string.other.link.description.markdown'; };
  297. 2 = { name = 'constant.other.reference.link.markdown'; };
  298. };
  299. };
  300. link-ref-literal = {
  301. name = 'meta.link.reference.literal.markdown';
  302. match = '\[(([^\[\]]|\[.*+\])*+)\] *\[\]';
  303. captures =
  304. { 1 = { name = 'string.other.link.title.markdown'; };
  305. };
  306. };
  307. link-ref = {
  308. name = 'meta.link.reference.markdown';
  309. match = '\[(([^\[\]]|\[.*+\])*+)\] *\[[^\]]*+\]';
  310. captures =
  311. { 1 = { name = 'string.other.link.title.markdown'; };
  312. 3 = { name = 'constant.other.reference.link.markdown'; };
  313. };
  314. };
  315. list-paragraph = { patterns = (
  316. { name = 'meta.paragraph.list.markdown';
  317. begin = '\G\s+(?=\S)';
  318. end = '^\s*$';
  319. patterns = ( { include = '#inline'; } );
  320. }
  321. );
  322. };
  323. };
  324. }
Add Comment
Please, Sign In to add comment