diff --git a/lib/liquid-tags/annotate.js b/lib/liquid-tags/annotate.js deleted file mode 100644 index 2242c4717e..0000000000 --- a/lib/liquid-tags/annotate.js +++ /dev/null @@ -1,170 +0,0 @@ -/* -Parses code blocks inside {% annotate %} ... {% endannotate %} -Results in single line comments split out, output format is: - -.annotate - .annotate-row (n) - .annotate-code - .annotate-note - -Contributing rules: -- You must wrap the entire code block in `{% annotate %}` and `{% endannotate %}`. -- You must include a language on the starting ` ``` ` tag. -- You can only include one code fence in the Liquid tags. -- Notes must start with one of: `#`, `//`, `` to maintain syntax highlighting; this will not impact what renders. -*/ - -import { chunk, last } from 'lodash-es' - -const codeFenceRegex = /^```\w*.*$/gm -const codeFenceLangRegex = /```(\w+)/ -const commentRegexNumber = /^\s*#\s*/ // also known has hash or sharp; but the unicode name is "number sign" -const commentRegexSlash = /^\s*\/\/\s*/ -const commentRegexXml = /^\s*` to maintain syntax highlighting; this will not impact what renders. + +`parse-info-string.js` plugin is required for this to work, and must come before `remark-rehype`. +`annotate` must come before the `highlight` plugin. +*/ + +import yaml from 'js-yaml' +import fs from 'fs' +import { chunk, last } from 'lodash-es' +import { visit } from 'unist-util-visit' +import { h } from 'hastscript' +import { fromMarkdown } from 'mdast-util-from-markdown' +import { toHast } from 'mdast-util-to-hast' + +const languages = yaml.load(fs.readFileSync('./data/variables/code-languages.yml', 'utf8')) + +const commentRegexes = { + number: /^\s*#\s*/, // also known has hash or sharp; but the unicode name is "number sign" + slash: /^\s*\/\/\s*/, + xml: /^\s*