Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/markdownit/containers.js')
-rw-r--r--src/markdownit/containers.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/markdownit/containers.js b/src/markdownit/containers.js
new file mode 100644
index 000000000..1196f9b8e
--- /dev/null
+++ b/src/markdownit/containers.js
@@ -0,0 +1,25 @@
+import container from 'markdown-it-container'
+
+export const typesAvailable = ['info', 'warn', 'error', 'success']
+
+const buildRender = type => (tokens, idx, options, env, slf) => {
+ // add a class to the opening tag
+ const tag = tokens[idx]
+
+ if (tag.nesting === 1) {
+ tag.attrSet('data-container', type)
+ tag.attrJoin('class', `custom-container custom-container-${type}`)
+ }
+
+ return slf.renderToken(tokens, idx, options, env, slf)
+}
+
+export default (md) => {
+ typesAvailable.forEach(type => {
+ md.use(container, type, {
+ render: buildRender(type),
+ })
+ })
+
+ return md
+}