toMarkdown.js 989 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Return N time a string
  2. function ns(s, n) {
  3. return Array(n + 1).join(s);
  4. }
  5. /*
  6. This module provides markup rules for gitbook-html
  7. These rules are being used to generate SUMMARY/GLOSSARY/LANGS
  8. */
  9. module.exports = {
  10. onTitleStart: function (level) {
  11. return ns("#", level) + " ";
  12. },
  13. onTitleEnd: function (level) {
  14. return this.onBL();
  15. },
  16. onParagraphStart: function () {
  17. return this.onSection();
  18. },
  19. onParagraphEnd: function () {
  20. return this.onSection();
  21. },
  22. onLinkStart: function () {
  23. return "[";
  24. },
  25. onLinkEnd: function (href) {
  26. return "](" + href + ")";
  27. },
  28. onListStart: function (level) {
  29. return "";
  30. },
  31. onListEnd: function () {
  32. return "";
  33. },
  34. onListItemStart: function (level) {
  35. return ns(" ", level * 4) + "* ";
  36. },
  37. onListItemEnd: function () {
  38. return "";
  39. },
  40. onHR: function () {
  41. return "-----";
  42. },
  43. };