@diplodoc/transform 4.0.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 (355) hide show
  1. package/CHANGELOG.diplodoc.md +38 -0
  2. package/CHANGELOG.md +404 -0
  3. package/LICENSE +21 -0
  4. package/README.md +41 -0
  5. package/README.ru.md +36 -0
  6. package/dist/css/yfm.css +736 -0
  7. package/dist/css/yfm.css.map +7 -0
  8. package/dist/css/yfm.min.css +2 -0
  9. package/dist/css/yfm.min.css.map +7 -0
  10. package/dist/js/code.d.ts +1 -0
  11. package/dist/js/cut.d.ts +1 -0
  12. package/dist/js/index.d.ts +5 -0
  13. package/dist/js/polyfill.d.ts +1 -0
  14. package/dist/js/tabs.d.ts +1 -0
  15. package/dist/js/term/index.d.ts +1 -0
  16. package/dist/js/term/utils.d.ts +10 -0
  17. package/dist/js/utils.d.ts +2 -0
  18. package/dist/js/yfm.js +432 -0
  19. package/dist/js/yfm.js.map +7 -0
  20. package/dist/js/yfm.min.js +2 -0
  21. package/dist/js/yfm.min.js.map +7 -0
  22. package/lib/getObject.d.ts +2 -0
  23. package/lib/getObject.js +11 -0
  24. package/lib/getObject.js.map +1 -0
  25. package/lib/headings.d.ts +4 -0
  26. package/lib/headings.js +73 -0
  27. package/lib/headings.js.map +1 -0
  28. package/lib/highlight.d.ts +3 -0
  29. package/lib/highlight.js +29 -0
  30. package/lib/highlight.js.map +1 -0
  31. package/lib/index.d.ts +7 -0
  32. package/lib/index.js +35 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/liquid/conditions.d.ts +4 -0
  35. package/lib/liquid/conditions.js +181 -0
  36. package/lib/liquid/conditions.js.map +1 -0
  37. package/lib/liquid/cycles.d.ts +4 -0
  38. package/lib/liquid/cycles.js +160 -0
  39. package/lib/liquid/cycles.js.map +1 -0
  40. package/lib/liquid/errors.d.ts +3 -0
  41. package/lib/liquid/errors.js +13 -0
  42. package/lib/liquid/errors.js.map +1 -0
  43. package/lib/liquid/evaluation.d.ts +3 -0
  44. package/lib/liquid/evaluation.js +138 -0
  45. package/lib/liquid/evaluation.js.map +1 -0
  46. package/lib/liquid/filters.d.ts +9 -0
  47. package/lib/liquid/filters.js +22 -0
  48. package/lib/liquid/filters.js.map +1 -0
  49. package/lib/liquid/index.d.ts +9 -0
  50. package/lib/liquid/index.js +87 -0
  51. package/lib/liquid/index.js.map +1 -0
  52. package/lib/liquid/lexical.d.ts +14 -0
  53. package/lib/liquid/lexical.js +79 -0
  54. package/lib/liquid/lexical.js.map +1 -0
  55. package/lib/liquid/services/argv.d.ts +15 -0
  56. package/lib/liquid/services/argv.js +17 -0
  57. package/lib/liquid/services/argv.js.map +1 -0
  58. package/lib/liquid/sourceMap.d.ts +24 -0
  59. package/lib/liquid/sourceMap.js +56 -0
  60. package/lib/liquid/sourceMap.js.map +1 -0
  61. package/lib/liquid/substitutions.d.ts +2 -0
  62. package/lib/liquid/substitutions.js +36 -0
  63. package/lib/liquid/substitutions.js.map +1 -0
  64. package/lib/liquid/utils.d.ts +8 -0
  65. package/lib/liquid/utils.js +24 -0
  66. package/lib/liquid/utils.js.map +1 -0
  67. package/lib/log.d.ts +18 -0
  68. package/lib/log.js +54 -0
  69. package/lib/log.js.map +1 -0
  70. package/lib/md.d.ts +14 -0
  71. package/lib/md.js +96 -0
  72. package/lib/md.js.map +1 -0
  73. package/lib/plugins/anchors/collect.d.ts +5 -0
  74. package/lib/plugins/anchors/collect.js +81 -0
  75. package/lib/plugins/anchors/collect.js.map +1 -0
  76. package/lib/plugins/anchors/constants.d.ts +2 -0
  77. package/lib/plugins/anchors/constants.js +6 -0
  78. package/lib/plugins/anchors/constants.js.map +1 -0
  79. package/lib/plugins/anchors/index.d.ts +7 -0
  80. package/lib/plugins/anchors/index.js +134 -0
  81. package/lib/plugins/anchors/index.js.map +1 -0
  82. package/lib/plugins/changelog/collect.d.ts +8 -0
  83. package/lib/plugins/changelog/collect.js +50 -0
  84. package/lib/plugins/changelog/collect.js.map +1 -0
  85. package/lib/plugins/changelog/index.d.ts +6 -0
  86. package/lib/plugins/changelog/index.js +131 -0
  87. package/lib/plugins/changelog/index.js.map +1 -0
  88. package/lib/plugins/changelog/types.d.ts +10 -0
  89. package/lib/plugins/changelog/types.js +3 -0
  90. package/lib/plugins/changelog/types.js.map +1 -0
  91. package/lib/plugins/checkbox/checkbox.d.ts +7 -0
  92. package/lib/plugins/checkbox/checkbox.js +91 -0
  93. package/lib/plugins/checkbox/checkbox.js.map +1 -0
  94. package/lib/plugins/checkbox/index.d.ts +8 -0
  95. package/lib/plugins/checkbox/index.js +12 -0
  96. package/lib/plugins/checkbox/index.js.map +1 -0
  97. package/lib/plugins/code.d.ts +3 -0
  98. package/lib/plugins/code.js +61 -0
  99. package/lib/plugins/code.js.map +1 -0
  100. package/lib/plugins/cut.d.ts +3 -0
  101. package/lib/plugins/cut.js +70 -0
  102. package/lib/plugins/cut.js.map +1 -0
  103. package/lib/plugins/deflist.d.ts +3 -0
  104. package/lib/plugins/deflist.js +8 -0
  105. package/lib/plugins/deflist.js.map +1 -0
  106. package/lib/plugins/file/const.d.ts +27 -0
  107. package/lib/plugins/file/const.js +47 -0
  108. package/lib/plugins/file/const.js.map +1 -0
  109. package/lib/plugins/file/file.d.ts +8 -0
  110. package/lib/plugins/file/file.js +63 -0
  111. package/lib/plugins/file/file.js.map +1 -0
  112. package/lib/plugins/file/index.d.ts +4 -0
  113. package/lib/plugins/file/index.js +9 -0
  114. package/lib/plugins/file/index.js.map +1 -0
  115. package/lib/plugins/images/collect.d.ts +8 -0
  116. package/lib/plugins/images/collect.js +43 -0
  117. package/lib/plugins/images/collect.js.map +1 -0
  118. package/lib/plugins/images/index.d.ts +10 -0
  119. package/lib/plugins/images/index.js +81 -0
  120. package/lib/plugins/images/index.js.map +1 -0
  121. package/lib/plugins/imsize/const.d.ts +7 -0
  122. package/lib/plugins/imsize/const.js +12 -0
  123. package/lib/plugins/imsize/const.js.map +1 -0
  124. package/lib/plugins/imsize/helpers.d.ts +6 -0
  125. package/lib/plugins/imsize/helpers.js +64 -0
  126. package/lib/plugins/imsize/helpers.js.map +1 -0
  127. package/lib/plugins/imsize/index.d.ts +8 -0
  128. package/lib/plugins/imsize/index.js +12 -0
  129. package/lib/plugins/imsize/index.js.map +1 -0
  130. package/lib/plugins/imsize/plugin.d.ts +3 -0
  131. package/lib/plugins/imsize/plugin.js +188 -0
  132. package/lib/plugins/imsize/plugin.js.map +1 -0
  133. package/lib/plugins/includes/collect.d.ts +8 -0
  134. package/lib/plugins/includes/collect.js +49 -0
  135. package/lib/plugins/includes/collect.js.map +1 -0
  136. package/lib/plugins/includes/index.d.ts +8 -0
  137. package/lib/plugins/includes/index.js +98 -0
  138. package/lib/plugins/includes/index.js.map +1 -0
  139. package/lib/plugins/links/collect.d.ts +7 -0
  140. package/lib/plugins/links/collect.js +74 -0
  141. package/lib/plugins/links/collect.js.map +1 -0
  142. package/lib/plugins/links/constants.d.ts +1 -0
  143. package/lib/plugins/links/constants.js +5 -0
  144. package/lib/plugins/links/constants.js.map +1 -0
  145. package/lib/plugins/links/index.d.ts +24 -0
  146. package/lib/plugins/links/index.js +178 -0
  147. package/lib/plugins/links/index.js.map +1 -0
  148. package/lib/plugins/meta.d.ts +3 -0
  149. package/lib/plugins/meta.js +8 -0
  150. package/lib/plugins/meta.js.map +1 -0
  151. package/lib/plugins/monospace.d.ts +3 -0
  152. package/lib/plugins/monospace.js +109 -0
  153. package/lib/plugins/monospace.js.map +1 -0
  154. package/lib/plugins/notes.d.ts +3 -0
  155. package/lib/plugins/notes.js +103 -0
  156. package/lib/plugins/notes.js.map +1 -0
  157. package/lib/plugins/sup.d.ts +3 -0
  158. package/lib/plugins/sup.js +8 -0
  159. package/lib/plugins/sup.js.map +1 -0
  160. package/lib/plugins/table/index.d.ts +3 -0
  161. package/lib/plugins/table/index.js +215 -0
  162. package/lib/plugins/table/index.js.map +1 -0
  163. package/lib/plugins/tabs.d.ts +4 -0
  164. package/lib/plugins/tabs.js +4 -0
  165. package/lib/plugins/tabs.js.map +1 -0
  166. package/lib/plugins/term/constants.d.ts +1 -0
  167. package/lib/plugins/term/constants.js +5 -0
  168. package/lib/plugins/term/constants.js.map +1 -0
  169. package/lib/plugins/term/index.d.ts +3 -0
  170. package/lib/plugins/term/index.js +108 -0
  171. package/lib/plugins/term/index.js.map +1 -0
  172. package/lib/plugins/term/termDefinitions.d.ts +4 -0
  173. package/lib/plugins/term/termDefinitions.js +125 -0
  174. package/lib/plugins/term/termDefinitions.js.map +1 -0
  175. package/lib/plugins/typings.d.ts +12 -0
  176. package/lib/plugins/typings.js +3 -0
  177. package/lib/plugins/typings.js.map +1 -0
  178. package/lib/plugins/utils.d.ts +6 -0
  179. package/lib/plugins/utils.js +30 -0
  180. package/lib/plugins/utils.js.map +1 -0
  181. package/lib/plugins/video/const.d.ts +10 -0
  182. package/lib/plugins/video/const.js +22 -0
  183. package/lib/plugins/video/const.js.map +1 -0
  184. package/lib/plugins/video/index.d.ts +8 -0
  185. package/lib/plugins/video/index.js +104 -0
  186. package/lib/plugins/video/index.js.map +1 -0
  187. package/lib/plugins/video/parsers.d.ts +6 -0
  188. package/lib/plugins/video/parsers.js +64 -0
  189. package/lib/plugins/video/parsers.js.map +1 -0
  190. package/lib/plugins/video/types.d.ts +34 -0
  191. package/lib/plugins/video/types.js +3 -0
  192. package/lib/plugins/video/types.js.map +1 -0
  193. package/lib/plugins/video/utils.d.ts +2 -0
  194. package/lib/plugins/video/utils.js +25 -0
  195. package/lib/plugins/video/utils.js.map +1 -0
  196. package/lib/plugins.d.ts +3 -0
  197. package/lib/plugins.js +36 -0
  198. package/lib/plugins.js.map +1 -0
  199. package/lib/sanitize.d.ts +12 -0
  200. package/lib/sanitize.js +572 -0
  201. package/lib/sanitize.js.map +1 -0
  202. package/lib/title.d.ts +7 -0
  203. package/lib/title.js +18 -0
  204. package/lib/title.js.map +1 -0
  205. package/lib/typings.d.ts +57 -0
  206. package/lib/typings.js +3 -0
  207. package/lib/typings.js.map +1 -0
  208. package/lib/utils.d.ts +13 -0
  209. package/lib/utils.js +79 -0
  210. package/lib/utils.js.map +1 -0
  211. package/lib/utilsFS.d.ts +27 -0
  212. package/lib/utilsFS.js +89 -0
  213. package/lib/utilsFS.js.map +1 -0
  214. package/lib/yfmlint/index.d.ts +26 -0
  215. package/lib/yfmlint/index.js +72 -0
  216. package/lib/yfmlint/index.js.map +1 -0
  217. package/lib/yfmlint/markdownlint-custom-rule/index.d.ts +9 -0
  218. package/lib/yfmlint/markdownlint-custom-rule/index.js +22 -0
  219. package/lib/yfmlint/markdownlint-custom-rule/index.js.map +1 -0
  220. package/lib/yfmlint/markdownlint-custom-rule/yfm001.d.ts +2 -0
  221. package/lib/yfmlint/markdownlint-custom-rule/yfm001.js +28 -0
  222. package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -0
  223. package/lib/yfmlint/markdownlint-custom-rule/yfm002.d.ts +2 -0
  224. package/lib/yfmlint/markdownlint-custom-rule/yfm002.js +33 -0
  225. package/lib/yfmlint/markdownlint-custom-rule/yfm002.js.map +1 -0
  226. package/lib/yfmlint/markdownlint-custom-rule/yfm003.d.ts +2 -0
  227. package/lib/yfmlint/markdownlint-custom-rule/yfm003.js +33 -0
  228. package/lib/yfmlint/markdownlint-custom-rule/yfm003.js.map +1 -0
  229. package/lib/yfmlint/markdownlint-custom-rule/yfm004.d.ts +2 -0
  230. package/lib/yfmlint/markdownlint-custom-rule/yfm004.js +28 -0
  231. package/lib/yfmlint/markdownlint-custom-rule/yfm004.js.map +1 -0
  232. package/lib/yfmlint/markdownlint-custom-rule/yfm005.d.ts +2 -0
  233. package/lib/yfmlint/markdownlint-custom-rule/yfm005.js +28 -0
  234. package/lib/yfmlint/markdownlint-custom-rule/yfm005.js.map +1 -0
  235. package/lib/yfmlint/markdownlint-custom-rule/yfm006.d.ts +2 -0
  236. package/lib/yfmlint/markdownlint-custom-rule/yfm006.js +28 -0
  237. package/lib/yfmlint/markdownlint-custom-rule/yfm006.js.map +1 -0
  238. package/lib/yfmlint/markdownlint-custom-rule/yfm007.d.ts +2 -0
  239. package/lib/yfmlint/markdownlint-custom-rule/yfm007.js +29 -0
  240. package/lib/yfmlint/markdownlint-custom-rule/yfm007.js.map +1 -0
  241. package/lib/yfmlint/markdownlint-custom-rule/yfm008.d.ts +2 -0
  242. package/lib/yfmlint/markdownlint-custom-rule/yfm008.js +28 -0
  243. package/lib/yfmlint/markdownlint-custom-rule/yfm008.js.map +1 -0
  244. package/lib/yfmlint/markdownlint-custom-rule/yfm009.d.ts +2 -0
  245. package/lib/yfmlint/markdownlint-custom-rule/yfm009.js +47 -0
  246. package/lib/yfmlint/markdownlint-custom-rule/yfm009.js.map +1 -0
  247. package/lib/yfmlint/typings.d.ts +12 -0
  248. package/lib/yfmlint/typings.js +3 -0
  249. package/lib/yfmlint/typings.js.map +1 -0
  250. package/lib/yfmlint/utils.d.ts +9 -0
  251. package/lib/yfmlint/utils.js +22 -0
  252. package/lib/yfmlint/utils.js.map +1 -0
  253. package/lib/yfmlint/yfmlint.d.ts +3 -0
  254. package/lib/yfmlint/yfmlint.js +69 -0
  255. package/lib/yfmlint/yfmlint.js.map +1 -0
  256. package/package.json +106 -0
  257. package/src/.eslintrc +10 -0
  258. package/src/js/code.ts +65 -0
  259. package/src/js/cut.ts +57 -0
  260. package/src/js/index.ts +6 -0
  261. package/src/js/polyfill.js +27 -0
  262. package/src/js/term/index.ts +79 -0
  263. package/src/js/term/utils.ts +151 -0
  264. package/src/js/utils.ts +9 -0
  265. package/src/scss/_anchor.scss +33 -0
  266. package/src/scss/_code.scss +23 -0
  267. package/src/scss/_common.scss +407 -0
  268. package/src/scss/_cut.scss +42 -0
  269. package/src/scss/_file.scss +35 -0
  270. package/src/scss/_highlight.scss +96 -0
  271. package/src/scss/_note.scss +73 -0
  272. package/src/scss/_print.scss +20 -0
  273. package/src/scss/_term.scss +79 -0
  274. package/src/scss/_variables.scss +16 -0
  275. package/src/scss/yfm.scss +11 -0
  276. package/src/transform/getObject.ts +10 -0
  277. package/src/transform/headings.ts +88 -0
  278. package/src/transform/highlight.ts +33 -0
  279. package/src/transform/index.ts +50 -0
  280. package/src/transform/liquid/conditions.ts +259 -0
  281. package/src/transform/liquid/cycles.ts +244 -0
  282. package/src/transform/liquid/errors.ts +10 -0
  283. package/src/transform/liquid/evaluation.ts +145 -0
  284. package/src/transform/liquid/filters.ts +19 -0
  285. package/src/transform/liquid/index.ts +141 -0
  286. package/src/transform/liquid/lexical.ts +86 -0
  287. package/src/transform/liquid/services/argv.ts +23 -0
  288. package/src/transform/liquid/sourceMap.ts +72 -0
  289. package/src/transform/liquid/substitutions.ts +40 -0
  290. package/src/transform/liquid/utils.ts +30 -0
  291. package/src/transform/log.ts +60 -0
  292. package/src/transform/md.ts +123 -0
  293. package/src/transform/plugins/anchors/collect.ts +101 -0
  294. package/src/transform/plugins/anchors/constants.ts +2 -0
  295. package/src/transform/plugins/anchors/index.ts +166 -0
  296. package/src/transform/plugins/changelog/collect.ts +66 -0
  297. package/src/transform/plugins/changelog/index.ts +164 -0
  298. package/src/transform/plugins/changelog/types.ts +10 -0
  299. package/src/transform/plugins/checkbox/checkbox.ts +107 -0
  300. package/src/transform/plugins/checkbox/index.ts +15 -0
  301. package/src/transform/plugins/code.ts +79 -0
  302. package/src/transform/plugins/cut.ts +98 -0
  303. package/src/transform/plugins/deflist.ts +5 -0
  304. package/src/transform/plugins/file/README.md +34 -0
  305. package/src/transform/plugins/file/const.ts +46 -0
  306. package/src/transform/plugins/file/file.ts +82 -0
  307. package/src/transform/plugins/file/index.ts +10 -0
  308. package/src/transform/plugins/images/collect.ts +60 -0
  309. package/src/transform/plugins/images/index.ts +119 -0
  310. package/src/transform/plugins/imsize/const.ts +7 -0
  311. package/src/transform/plugins/imsize/helpers.ts +75 -0
  312. package/src/transform/plugins/imsize/index.ts +14 -0
  313. package/src/transform/plugins/imsize/plugin.ts +214 -0
  314. package/src/transform/plugins/includes/collect.ts +73 -0
  315. package/src/transform/plugins/includes/index.ts +127 -0
  316. package/src/transform/plugins/links/collect.ts +92 -0
  317. package/src/transform/plugins/links/constants.ts +1 -0
  318. package/src/transform/plugins/links/index.ts +218 -0
  319. package/src/transform/plugins/meta.ts +5 -0
  320. package/src/transform/plugins/monospace.ts +141 -0
  321. package/src/transform/plugins/notes.ts +134 -0
  322. package/src/transform/plugins/sup.ts +5 -0
  323. package/src/transform/plugins/table/index.ts +290 -0
  324. package/src/transform/plugins/tabs.ts +3 -0
  325. package/src/transform/plugins/term/constants.ts +1 -0
  326. package/src/transform/plugins/term/index.ts +139 -0
  327. package/src/transform/plugins/term/termDefinitions.ts +177 -0
  328. package/src/transform/plugins/typings.ts +14 -0
  329. package/src/transform/plugins/utils.ts +38 -0
  330. package/src/transform/plugins/video/const.ts +20 -0
  331. package/src/transform/plugins/video/index.ts +134 -0
  332. package/src/transform/plugins/video/parsers.ts +65 -0
  333. package/src/transform/plugins/video/types.ts +27 -0
  334. package/src/transform/plugins/video/utils.ts +24 -0
  335. package/src/transform/plugins.ts +35 -0
  336. package/src/transform/sanitize.ts +596 -0
  337. package/src/transform/title.ts +22 -0
  338. package/src/transform/typings.ts +64 -0
  339. package/src/transform/utils.ts +91 -0
  340. package/src/transform/utilsFS.ts +128 -0
  341. package/src/transform/yfmlint/README.md +48 -0
  342. package/src/transform/yfmlint/index.ts +124 -0
  343. package/src/transform/yfmlint/markdownlint-custom-rule/index.ts +9 -0
  344. package/src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts +36 -0
  345. package/src/transform/yfmlint/markdownlint-custom-rule/yfm002.ts +33 -0
  346. package/src/transform/yfmlint/markdownlint-custom-rule/yfm003.ts +33 -0
  347. package/src/transform/yfmlint/markdownlint-custom-rule/yfm004.ts +27 -0
  348. package/src/transform/yfmlint/markdownlint-custom-rule/yfm005.ts +27 -0
  349. package/src/transform/yfmlint/markdownlint-custom-rule/yfm006.ts +26 -0
  350. package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +28 -0
  351. package/src/transform/yfmlint/markdownlint-custom-rule/yfm008.ts +26 -0
  352. package/src/transform/yfmlint/markdownlint-custom-rule/yfm009.ts +54 -0
  353. package/src/transform/yfmlint/typings.ts +13 -0
  354. package/src/transform/yfmlint/utils.ts +31 -0
  355. package/src/transform/yfmlint/yfmlint.ts +73 -0
@@ -0,0 +1,151 @@
1
+ export const Selector = {
2
+ TITLE: '.yfm .yfm-term_title',
3
+ CONTENT: '.yfm .yfm-term_dfn',
4
+ };
5
+ export const openClass = 'open';
6
+ export const openDefinitionClass = Selector.CONTENT.replace(/\./g, '') + ' ' + openClass;
7
+ let isListenerNeeded = true;
8
+
9
+ export function createDefinitionElement(termElement: HTMLElement) {
10
+ const termKey = termElement.getAttribute('term-key');
11
+ const definitionTemplate = document.getElementById(
12
+ `${termKey}_template`,
13
+ ) as HTMLTemplateElement;
14
+ const definitionElement = definitionTemplate?.content.cloneNode(true).firstChild as HTMLElement;
15
+
16
+ definitionTemplate?.parentElement?.appendChild(definitionElement);
17
+ definitionTemplate.remove();
18
+
19
+ return definitionElement;
20
+ }
21
+
22
+ export function setDefinitionId(definitionElement: HTMLElement, termElement: HTMLElement): void {
23
+ const termId = termElement.getAttribute('id') || Math.random().toString(36).substr(2, 8);
24
+ definitionElement?.setAttribute('term-id', termId);
25
+ }
26
+
27
+ export function setDefinitionPosition(
28
+ definitionElement: HTMLElement,
29
+ termElement: HTMLElement,
30
+ ): void {
31
+ const {
32
+ x: termX,
33
+ y: termY,
34
+ right: termRight,
35
+ left: termLeft,
36
+ width: termWidth,
37
+ height: termHeight,
38
+ } = termElement.getBoundingClientRect();
39
+
40
+ const termParent = termParentElement(termElement);
41
+
42
+ if (!termParent) {
43
+ return;
44
+ }
45
+
46
+ const {right: termParentRight, left: termParentLeft} = termParent.getBoundingClientRect();
47
+
48
+ if ((termParentRight < termLeft || termParentLeft > termRight) && !isListenerNeeded) {
49
+ closeDefinition(definitionElement);
50
+ return;
51
+ }
52
+
53
+ if (isListenerNeeded && termParent) {
54
+ termParent.addEventListener('scroll', termOnResize);
55
+ isListenerNeeded = false;
56
+ }
57
+
58
+ const relativeX = Number(definitionElement.getAttribute('relativeX'));
59
+ const relativeY = Number(definitionElement.getAttribute('relativeY'));
60
+
61
+ if (relativeX === termX && relativeY === termY) {
62
+ return;
63
+ }
64
+
65
+ definitionElement.setAttribute('relativeX', String(termX));
66
+ definitionElement.setAttribute('relativeY', String(termY));
67
+
68
+ const offsetTop = termHeight + 5;
69
+ const definitionParent = definitionElement.parentElement;
70
+
71
+ if (!definitionParent) {
72
+ return;
73
+ }
74
+
75
+ const {width: definitionWidth} = definitionElement.getBoundingClientRect();
76
+ const {left: definitionParentLeft} = definitionParent.getBoundingClientRect();
77
+
78
+ // If definition not fit document change base alignment
79
+ const definitionRightCoordinate = definitionWidth + Number(getCoords(termElement).left);
80
+ const fitDefinitionDocument =
81
+ document.body.clientWidth > definitionRightCoordinate ? 0 : definitionWidth - termWidth;
82
+
83
+ const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;
84
+
85
+ definitionElement.style.top =
86
+ Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';
87
+ definitionElement.style.left =
88
+ Number(
89
+ getCoords(termElement).left -
90
+ definitionParentLeft +
91
+ definitionParent.offsetLeft -
92
+ fitDefinitionDocument,
93
+ ) + 'px';
94
+ }
95
+
96
+ function termOnResize() {
97
+ const openDefinition = document.getElementsByClassName(openDefinitionClass)[0] as HTMLElement;
98
+
99
+ if (!openDefinition) {
100
+ return;
101
+ }
102
+ const termId = openDefinition.getAttribute('term-id') || '';
103
+ const termElement = document.getElementById(termId);
104
+
105
+ if (!termElement) {
106
+ return;
107
+ }
108
+
109
+ setDefinitionPosition(openDefinition, termElement);
110
+ }
111
+
112
+ function termParentElement(term: HTMLElement | null) {
113
+ if (!term) {
114
+ return null;
115
+ }
116
+
117
+ const closestScrollableParent = term.closest('table') || term.closest('code');
118
+
119
+ return closestScrollableParent || term.parentElement;
120
+ }
121
+
122
+ export function closeDefinition(definition: HTMLElement) {
123
+ definition.classList.remove(openClass);
124
+ const termId = definition.getAttribute('term-id') || '';
125
+ const termParent = termParentElement(document.getElementById(termId));
126
+
127
+ if (!termParent) {
128
+ return;
129
+ }
130
+
131
+ termParent.removeEventListener('scroll', termOnResize);
132
+ isListenerNeeded = true;
133
+ }
134
+
135
+ function getCoords(elem: HTMLElement) {
136
+ const box = elem.getBoundingClientRect();
137
+
138
+ const body = document.body;
139
+ const docEl = document.documentElement;
140
+
141
+ const scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
142
+ const scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
143
+
144
+ const clientTop = docEl.clientTop || body.clientTop || 0;
145
+ const clientLeft = docEl.clientLeft || body.clientLeft || 0;
146
+
147
+ const top = box.top + scrollTop - clientTop;
148
+ const left = box.left + scrollLeft - clientLeft;
149
+
150
+ return {top: Math.round(top), left: Math.round(left)};
151
+ }
@@ -0,0 +1,9 @@
1
+ export const getEventTarget = (event: Event) => {
2
+ const path = event.composedPath();
3
+ return Array.isArray(path) && path.length > 0 ? path[0] : event.target;
4
+ };
5
+
6
+ export const isCustom = (event: Event) => {
7
+ const target = getEventTarget(event);
8
+ return !target || !(target as HTMLElement).matches;
9
+ };
@@ -0,0 +1,33 @@
1
+ .yfm {
2
+ h1, h2, h3, h4, h5, h6 {
3
+ .yfm-anchor {
4
+ display: inline-block;
5
+ width: 24px;
6
+ padding-right: 4px;
7
+ margin-left: -24px;
8
+ float: left;
9
+
10
+ text-align: center;
11
+ font-size: 18px;
12
+ }
13
+
14
+ .yfm-anchor::before {
15
+ content: '#';
16
+ visibility: hidden;
17
+ }
18
+
19
+ &:hover .yfm-anchor::before {
20
+ visibility: visible;
21
+ }
22
+ }
23
+
24
+ table {
25
+ h1, h2, h3, h4, h5, h6 {
26
+ .yfm-anchor {
27
+ width: 1em;
28
+ margin-left: -1em;
29
+ padding-right: 0;
30
+ }
31
+ }
32
+ };
33
+ }
@@ -0,0 +1,23 @@
1
+ .yfm {
2
+ &-clipboard {
3
+ position: relative;
4
+
5
+ &:hover &-button {
6
+ display: block;
7
+ }
8
+
9
+ & > pre {
10
+ border-radius: 10px;
11
+ overflow: hidden;
12
+ }
13
+ }
14
+
15
+ &-clipboard-button {
16
+ display: none;
17
+ position: absolute;
18
+ cursor: pointer;
19
+ top: 16px;
20
+ right: 16px;
21
+ z-index: 1;
22
+ }
23
+ }
@@ -0,0 +1,407 @@
1
+ @import 'variables';
2
+
3
+ .yfm {
4
+ font-family: var(--yfm-font-family-sans);
5
+ font-size: 15px;
6
+ line-height: 20px;
7
+ word-wrap: break-word;
8
+ color: $textColor;
9
+
10
+ * {
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ & > *:not(h2):not(h3):not(h4):not(h5):not(h6):first-child {
15
+ margin-top: 0 !important;
16
+ }
17
+
18
+ & > *:last-child {
19
+ margin-bottom: 0 !important;
20
+ }
21
+
22
+ h1, h2, h3, h4, h5, h6 {
23
+ margin-bottom: 15px;
24
+ font-weight: 500;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 32px;
29
+ line-height: 40px;
30
+ }
31
+
32
+ h2 {
33
+ font-size: 24px;
34
+ line-height: 28px;
35
+ }
36
+
37
+ h3 {
38
+ font-size: 20px;
39
+ line-height: 24px;
40
+ }
41
+
42
+ h4 {
43
+ font-size: 17px;
44
+ line-height: 24px;
45
+ }
46
+
47
+ h5 {
48
+ font-size: 15px;
49
+ line-height: 20px;
50
+ }
51
+
52
+ h6 {
53
+ font-size: 13px;
54
+ line-height: 18px;
55
+ }
56
+
57
+ a {
58
+ background-color: transparent;
59
+ color: $linkColor;
60
+ text-decoration: none;
61
+
62
+ &:hover, &:active {
63
+ color: $linkHoverColor;
64
+ }
65
+
66
+ &:not([href]) {
67
+ color: inherit;
68
+ }
69
+
70
+ }
71
+
72
+ strong {
73
+ font-weight: 700;
74
+ }
75
+
76
+ img, svg {
77
+ box-sizing: content-box;
78
+ max-width: 100%;
79
+ border: none;
80
+ vertical-align: middle;
81
+
82
+ &[align=right] {
83
+ padding-left: 20px;
84
+ }
85
+
86
+ &[align=left] {
87
+ padding-right: 20px;
88
+ }
89
+ }
90
+
91
+ img {
92
+ background-color: $baseColor;
93
+ }
94
+
95
+ svg {
96
+ height: auto;
97
+ }
98
+
99
+ .katex svg {
100
+ height: initial;
101
+ }
102
+
103
+ img + small {
104
+ display: block;
105
+ }
106
+
107
+ p,
108
+ blockquote,
109
+ ul,
110
+ ol,
111
+ dl,
112
+ table,
113
+ pre {
114
+ margin: 0 0 15px 0;
115
+ }
116
+
117
+ ul, ol, dl {
118
+ & pre {
119
+ margin-top: 15px;
120
+ }
121
+ }
122
+
123
+ code,
124
+ kbd,
125
+ pre {
126
+ font-family: var(--yfm-font-family-monospace);
127
+ font-size: 1em;
128
+ font-feature-settings: normal;
129
+ }
130
+
131
+ input {
132
+ margin: 0;
133
+ overflow: visible;
134
+
135
+ font-family: inherit;
136
+ font-size: inherit;
137
+ line-height: inherit;
138
+
139
+ &[type='checkbox'] {
140
+ position: relative;
141
+ top: 1px;
142
+
143
+ box-sizing: border-box;
144
+ padding: 0;
145
+ }
146
+ }
147
+
148
+ table {
149
+ color: #333;
150
+
151
+ display: inline-block;
152
+ max-width: 100%;
153
+ width: auto;
154
+ overflow: auto;
155
+ position: relative;
156
+ z-index: 1;
157
+
158
+ box-sizing: border-box;
159
+ border: 1px solid $borderColor;
160
+ border-radius: 8px;
161
+ border-collapse: collapse;
162
+ border-spacing: 0;
163
+ background: $baseColor;
164
+
165
+ thead, tr:nth-child(2n) {
166
+ background-color: $tableRowBackgroundColor;
167
+ }
168
+
169
+ tr:first-child {
170
+ td, th {
171
+ border-top: none;
172
+ }
173
+ }
174
+
175
+ tr:last-child {
176
+ td, th {
177
+ border-bottom: none;
178
+ }
179
+ }
180
+
181
+
182
+ th, td {
183
+ padding: 10px 20px;
184
+ overflow: hidden;
185
+ text-overflow: ellipsis;
186
+ border: 1px solid $borderColor;
187
+
188
+ p {
189
+ padding: 0;
190
+ margin: 0;
191
+ }
192
+ }
193
+
194
+ td {
195
+ vertical-align: baseline;
196
+ white-space: normal;
197
+ }
198
+
199
+ th {
200
+ font-weight: 500;
201
+ text-align: left;
202
+ }
203
+
204
+ tr td:first-child, tr th:first-child {
205
+ border-left: none;
206
+ }
207
+ tr td:last-child, tr th:last-child {
208
+ border-right: none;
209
+ }
210
+ }
211
+
212
+ hr {
213
+ box-sizing: content-box;
214
+ height: 0.25em;
215
+ padding: 0;
216
+ margin: 1.5em 0;
217
+ overflow: hidden;
218
+
219
+ background-color: $borderColor;
220
+ border: none;
221
+
222
+ &::before {
223
+ content: '';
224
+ display: table;
225
+ }
226
+
227
+ &::after {
228
+ content: '';
229
+ display: table;
230
+ clear: both;
231
+ }
232
+ }
233
+
234
+ blockquote {
235
+ position: relative;
236
+ padding-left: 12px;
237
+ border-left: 3px solid $accentColor;
238
+
239
+ & > *:first-child {
240
+ margin-top: 0;
241
+ }
242
+
243
+ & > *:last-child {
244
+ margin-bottom: 0;
245
+ }
246
+ }
247
+
248
+ dl {
249
+ padding: 0;
250
+
251
+ & > *:first-child {
252
+ margin-top: 0;
253
+ }
254
+
255
+ & > *:last-child {
256
+ margin-bottom: 0;
257
+ }
258
+
259
+ dt {
260
+ margin-bottom: 5px;
261
+ font-size: 1em;
262
+ font-weight: 500;
263
+ font-style: italic;
264
+ }
265
+
266
+ dd {
267
+ margin-bottom: 15px;
268
+ padding: 0 15px;
269
+ }
270
+ }
271
+
272
+ dd {
273
+ margin-left: 0;
274
+
275
+ & > ol:first-child,
276
+ & > ul:first-child,
277
+ & > dd:first-child {
278
+ padding-left: 0;
279
+ }
280
+ }
281
+
282
+ ul, ol {
283
+ padding-left: 2.2em;
284
+ }
285
+
286
+ ul ul,
287
+ ul ol,
288
+ ol ol,
289
+ ol ul {
290
+ margin-top: 0;
291
+ margin-bottom: 0;
292
+ }
293
+
294
+ &:not(.yfm_no-list-reset) {
295
+ ol {
296
+ list-style-type: none;
297
+ counter-reset: list;
298
+
299
+ & > li {
300
+ position: relative;
301
+ counter-increment: list;
302
+
303
+ &::before {
304
+ position: absolute;
305
+ right: 100%;
306
+ margin-right: 4px;
307
+ content: counters(list, '.') '. ';
308
+ }
309
+ }
310
+ }
311
+ }
312
+
313
+ li {
314
+ word-wrap: break-word;
315
+ }
316
+
317
+ li + li {
318
+ margin-top: 0.33em;
319
+ }
320
+
321
+ li p,
322
+ li blockquote {
323
+ margin-top: 15px;
324
+ }
325
+
326
+ code {
327
+ padding: 0.1em 0.4em 0.15em;
328
+ background-color: $inlineCodeBackgroundColor;
329
+ border-radius: 4px;
330
+ font-size: 0.875em;
331
+ white-space: normal;
332
+ color: $inlineCodeColor;
333
+ }
334
+
335
+ pre {
336
+ word-wrap: normal;
337
+ }
338
+
339
+ table code {
340
+ white-space: nowrap;
341
+ }
342
+
343
+ pre * code {
344
+ display: inline;
345
+ padding: 0;
346
+ margin: 0;
347
+ overflow: visible;
348
+ word-wrap: normal;
349
+ background-color: transparent;
350
+ border: 0;
351
+ color: $textColor;
352
+ }
353
+
354
+ pre > code {
355
+ display: block;
356
+ padding: 16px;
357
+ overflow: auto;
358
+
359
+ background-color: $codeBackgroundColor;
360
+ color: $textColor;
361
+
362
+ white-space: pre;
363
+ }
364
+
365
+ sup, sub {
366
+ line-height: 0;
367
+ }
368
+
369
+ /*
370
+ Hides element visually, but leaves it visible for search crawlers and screen readers
371
+
372
+ https://www.a11yproject.com/posts/2013-01-11-how-to-hide-content/
373
+ https://hugogiraudel.com/2016/10/13/css-hide-and-seek/
374
+ */
375
+ .visually-hidden {
376
+ position: absolute;
377
+
378
+ overflow: hidden;
379
+ clip: rect(0 0 0 0);
380
+
381
+ width: 1px;
382
+ height: 1px;
383
+ margin: -1px;
384
+
385
+ padding: 0;
386
+
387
+ white-space: nowrap;
388
+
389
+ border: 0;
390
+
391
+ clip-path: inset(100%);
392
+ }
393
+
394
+ // highlight.js colors
395
+ --yfm-color-hljs-background: #{$codeBackgroundColor};
396
+ --yfm-color-hljs-subst: #444;
397
+ --yfm-color-hljs-comment: #888888;
398
+ --yfm-color-hljs-deletion: #880000;
399
+ --yfm-color-hljs-section: #880000;
400
+ --yfm-color-hljs-pseudo: #BC6060;
401
+ --yfm-color-hljs-literal: #78A960;
402
+ --yfm-color-hljs-addition: #397300;
403
+ --yfm-color-hljs-meta: #1f7199;
404
+ --yfm-color-hljs-meta-string: #4d99bf;
405
+ --yfm-font-family-monospace: "Menlo", "Monaco", "Consolas", "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", "Courier", monospace;
406
+ --yfm-font-family-sans: 'Segoe UI', Arial, Helvetica, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
407
+ }
@@ -0,0 +1,42 @@
1
+ .yfm-cut {
2
+ $class: &;
3
+
4
+ &-title {
5
+ cursor: pointer;
6
+ position: relative;
7
+ user-select: none;
8
+ padding: 5px 0 5px 30px;
9
+
10
+ &:before {
11
+ content: '';
12
+ z-index: 1;
13
+ left: 0;
14
+ top: 50%;
15
+ background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+CiAgICA8cGF0aCBzdHJva2U9ImN1cnJlbnRDb2xvciIgZmlsbD0ibm9uZSIgZD0iTTMgNmw1IDUgNS01Ii8+Cjwvc3ZnPgo=");
16
+ transform: translateY(-50%) rotate(-90deg);
17
+ transition: transform 0.3s ease;
18
+ height: 20px;
19
+ width: 20px;
20
+ position: absolute;
21
+ }
22
+ }
23
+
24
+ &-content {
25
+ height: 0;
26
+ overflow: hidden;
27
+ transition: height 0.3s ease-in-out;
28
+ }
29
+
30
+ &.open {
31
+ > #{$class}-content {
32
+ padding: 5px 0 15px 30px;
33
+ height: auto;
34
+ }
35
+
36
+ > #{$class}-title:before {
37
+ transform: translateY(-50%);
38
+ }
39
+ }
40
+ }
41
+
42
+
@@ -0,0 +1,35 @@
1
+ @import 'variables';
2
+
3
+ $defaultIcon: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzODQgNTEyIj48cGF0aCBmaWxsPSJjdXJyZW50Q29sb3IiIGQ9Ik0zNjkuOSA5Ny45TDI4NiAxNEMyNzcgNSAyNjQuOC0uMSAyNTIuMS0uMUg0OEMyMS41IDAgMCAyMS41IDAgNDh2NDE2YzAgMjYuNSAyMS41IDQ4IDQ4IDQ4aDI4OGMyNi41IDAgNDgtMjEuNSA0OC00OFYxMzEuOWMwLTEyLjctNS4xLTI1LTE0LjEtMzR6bS0yMi42IDIyLjdjMi4xIDIuMSAzLjUgNC42IDQuMiA3LjRIMjU2VjMyLjVjMi44LjcgNS4zIDIuMSA3LjQgNC4ybDgzLjkgODMuOXpNMzM2IDQ4MEg0OGMtOC44IDAtMTYtNy4yLTE2LTE2VjQ4YzAtOC44IDcuMi0xNiAxNi0xNmgxNzZ2MTA0YzAgMTMuMyAxMC43IDI0IDI0IDI0aDEwNHYzMDRjMCA4LjgtNy4yIDE2LTE2IDE2em0tNDgtMjQ0djhjMCA2LjYtNS40IDEyLTEyIDEySDEwOGMtNi42IDAtMTItNS40LTEyLTEydi04YzAtNi42IDUuNC0xMiAxMi0xMmgxNjhjNi42IDAgMTIgNS40IDEyIDEyem0wIDY0djhjMCA2LjYtNS40IDEyLTEyIDEySDEwOGMtNi42IDAtMTItNS40LTEyLTEydi04YzAtNi42IDUuNC0xMiAxMi0xMmgxNjhjNi42IDAgMTIgNS40IDEyIDEyem0wIDY0djhjMCA2LjYtNS40IDEyLTEyIDEySDEwOGMtNi42IDAtMTItNS40LTEyLTEydi04YzAtNi42IDUuNC0xMiAxMi0xMmgxNjhjNi42IDAgMTIgNS40IDEyIDEyeiIvPjwvc3ZnPg==");
4
+
5
+ /**
6
+ Public CSS variables:
7
+ --yfm-file-icon sets file icon image
8
+ --yfm-file-icon-color sets file icon color
9
+ */
10
+
11
+ .yfm-file {
12
+ &__icon {
13
+ ---yfm-file-icon-img: var(--yfm-file-icon, #{$defaultIcon});
14
+
15
+ display: inline-block;
16
+ user-select: none;
17
+
18
+ width: 16px;
19
+ margin: 0 2px;
20
+
21
+ color: var(--yfm-file-icon-color, #{$textColor});
22
+ background-color: currentColor;
23
+ background-repeat: no-repeat;
24
+ background-position: 50%;
25
+ background-size: 100%;
26
+
27
+ mask-image: var(---yfm-file-icon-img);
28
+ mask-position: center;
29
+ mask-repeat: no-repeat;
30
+
31
+ &::before {
32
+ content: '\a0';
33
+ }
34
+ }
35
+ }