您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package org
  2. import "fmt"
  3. // Writer is the interface that is used to export a parsed document into a new format. See Document.Write().
  4. type Writer interface {
  5. Before(*Document) // Before is called before any nodes are passed to the writer.
  6. After(*Document) // After is called after all nodes have been passed to the writer.
  7. String() string // String is called at the very end to retrieve the final output.
  8. WriterWithExtensions() Writer
  9. WriteNodesAsString(...Node) string
  10. WriteKeyword(Keyword)
  11. WriteInclude(Include)
  12. WriteComment(Comment)
  13. WriteNodeWithMeta(NodeWithMeta)
  14. WriteNodeWithName(NodeWithName)
  15. WriteHeadline(Headline)
  16. WriteBlock(Block)
  17. WriteExample(Example)
  18. WriteDrawer(Drawer)
  19. WritePropertyDrawer(PropertyDrawer)
  20. WriteList(List)
  21. WriteListItem(ListItem)
  22. WriteDescriptiveListItem(DescriptiveListItem)
  23. WriteTable(Table)
  24. WriteHorizontalRule(HorizontalRule)
  25. WriteParagraph(Paragraph)
  26. WriteText(Text)
  27. WriteEmphasis(Emphasis)
  28. WriteLatexFragment(LatexFragment)
  29. WriteStatisticToken(StatisticToken)
  30. WriteExplicitLineBreak(ExplicitLineBreak)
  31. WriteLineBreak(LineBreak)
  32. WriteRegularLink(RegularLink)
  33. WriteTimestamp(Timestamp)
  34. WriteFootnoteLink(FootnoteLink)
  35. WriteFootnoteDefinition(FootnoteDefinition)
  36. }
  37. func WriteNodes(w Writer, nodes ...Node) {
  38. w = w.WriterWithExtensions()
  39. for _, n := range nodes {
  40. switch n := n.(type) {
  41. case Keyword:
  42. w.WriteKeyword(n)
  43. case Include:
  44. w.WriteInclude(n)
  45. case Comment:
  46. w.WriteComment(n)
  47. case NodeWithMeta:
  48. w.WriteNodeWithMeta(n)
  49. case NodeWithName:
  50. w.WriteNodeWithName(n)
  51. case Headline:
  52. w.WriteHeadline(n)
  53. case Block:
  54. w.WriteBlock(n)
  55. case Example:
  56. w.WriteExample(n)
  57. case Drawer:
  58. w.WriteDrawer(n)
  59. case PropertyDrawer:
  60. w.WritePropertyDrawer(n)
  61. case List:
  62. w.WriteList(n)
  63. case ListItem:
  64. w.WriteListItem(n)
  65. case DescriptiveListItem:
  66. w.WriteDescriptiveListItem(n)
  67. case Table:
  68. w.WriteTable(n)
  69. case HorizontalRule:
  70. w.WriteHorizontalRule(n)
  71. case Paragraph:
  72. w.WriteParagraph(n)
  73. case Text:
  74. w.WriteText(n)
  75. case Emphasis:
  76. w.WriteEmphasis(n)
  77. case LatexFragment:
  78. w.WriteLatexFragment(n)
  79. case StatisticToken:
  80. w.WriteStatisticToken(n)
  81. case ExplicitLineBreak:
  82. w.WriteExplicitLineBreak(n)
  83. case LineBreak:
  84. w.WriteLineBreak(n)
  85. case RegularLink:
  86. w.WriteRegularLink(n)
  87. case Timestamp:
  88. w.WriteTimestamp(n)
  89. case FootnoteLink:
  90. w.WriteFootnoteLink(n)
  91. case FootnoteDefinition:
  92. w.WriteFootnoteDefinition(n)
  93. default:
  94. if n != nil {
  95. panic(fmt.Sprintf("bad node %T %#v", n, n))
  96. }
  97. }
  98. }
  99. }