.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / remark-stringify / lib / visitors / table.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/remark-stringify/lib/visitors/table.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/remark-stringify/lib/visitors/table.js
new file mode 100644 (file)
index 0000000..fc0c18c
--- /dev/null
@@ -0,0 +1,66 @@
+'use strict';
+
+var markdownTable = require('markdown-table');
+
+module.exports = table;
+
+/* Stringify table.
+ *
+ * Creates a fenced table by default, but not in
+ * `looseTable: true` mode:
+ *
+ *     Foo | Bar
+ *     :-: | ---
+ *     Baz | Qux
+ *
+ * NOTE: Be careful with `looseTable: true` mode, as a
+ * loose table inside an indented code block on GitHub
+ * renders as an actual table!
+ *
+ * Creates a spaced table by default, but not in
+ * `spacedTable: false`:
+ *
+ *     |Foo|Bar|
+ *     |:-:|---|
+ *     |Baz|Qux|
+ */
+function table(node) {
+  var self = this;
+  var options = self.options;
+  var loose = options.looseTable;
+  var spaced = options.spacedTable;
+  var pad = options.paddedTable;
+  var stringLength = options.stringLength;
+  var rows = node.children;
+  var index = rows.length;
+  var exit = self.enterTable();
+  var result = [];
+  var start;
+  var end;
+
+  while (index--) {
+    result[index] = self.all(rows[index]);
+  }
+
+  exit();
+
+  if (loose) {
+    start = '';
+    end = '';
+  } else if (spaced) {
+    start = '| ';
+    end = ' |';
+  } else {
+    start = '|';
+    end = '|';
+  }
+
+  return markdownTable(result, {
+    align: node.align,
+    pad: pad,
+    start: start,
+    end: end,
+    stringLength: stringLength,
+    delimiter: spaced ? ' | ' : '|'
+  });
+}