summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-asciidoc/src/toAsciidoc.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-asciidoc/src/toAsciidoc.js')
-rw-r--r--packages/gitbook-asciidoc/src/toAsciidoc.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/gitbook-asciidoc/src/toAsciidoc.js b/packages/gitbook-asciidoc/src/toAsciidoc.js
new file mode 100644
index 0000000..77759d8
--- /dev/null
+++ b/packages/gitbook-asciidoc/src/toAsciidoc.js
@@ -0,0 +1,46 @@
+
+// Return N time a string
+function ns(s, n) {
+ return Array(n + 1).join(s);
+}
+
+module.exports = {
+ onTitleStart(level) {
+ return ns('=', level) + ' ';
+ },
+ onTitleEnd(level) {
+ return this.onBL();
+ },
+
+ onParagraphStart() {
+ return this.onSection();
+ },
+ onParagraphEnd() {
+ return this.onSection();
+ },
+
+ onLinkStart(href) {
+ return 'link:' + href + '[';
+ },
+ onLinkEnd() {
+ return ']';
+ },
+
+ onListStart(level) {
+ return '';
+ },
+ onListEnd() {
+ return '';
+ },
+
+ onListItemStart(level) {
+ return ns('.', level + 1) + ' ';
+ },
+ onListItemEnd() {
+ return '';
+ },
+
+ onHR() {
+ return '\'\'\'';
+ }
+};