markdown_service.proto 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. syntax = "proto3";
  2. package memos.api.v1;
  3. import "google/api/annotations.proto";
  4. option go_package = "gen/api/v1";
  5. service MarkdownService {
  6. // ParseMarkdown parses the given markdown content and returns a list of nodes.
  7. rpc ParseMarkdown(ParseMarkdownRequest) returns (ParseMarkdownResponse) {
  8. option (google.api.http) = {
  9. post: "/api/v1/markdown:parse"
  10. body: "*"
  11. };
  12. }
  13. // RestoreMarkdownNodes restores the given nodes to markdown content.
  14. rpc RestoreMarkdownNodes(RestoreMarkdownNodesRequest) returns (RestoreMarkdownNodesResponse) {
  15. option (google.api.http) = {
  16. post: "/api/v1/markdown/node:restore"
  17. body: "*"
  18. };
  19. }
  20. // StringifyMarkdownNodes stringify the given nodes to plain text content.
  21. rpc StringifyMarkdownNodes(StringifyMarkdownNodesRequest) returns (StringifyMarkdownNodesResponse) {
  22. option (google.api.http) = {
  23. post: "/api/v1/markdown/node:stringify"
  24. body: "*"
  25. };
  26. }
  27. // GetLinkMetadata returns metadata for a given link.
  28. rpc GetLinkMetadata(GetLinkMetadataRequest) returns (LinkMetadata) {
  29. option (google.api.http) = {get: "/api/v1/markdown/link:metadata"};
  30. }
  31. }
  32. message ParseMarkdownRequest {
  33. string markdown = 1;
  34. }
  35. message ParseMarkdownResponse {
  36. repeated Node nodes = 1;
  37. }
  38. message RestoreMarkdownNodesRequest {
  39. repeated Node nodes = 1;
  40. }
  41. message RestoreMarkdownNodesResponse {
  42. string markdown = 1;
  43. }
  44. message StringifyMarkdownNodesRequest {
  45. repeated Node nodes = 1;
  46. }
  47. message StringifyMarkdownNodesResponse {
  48. string plain_text = 1;
  49. }
  50. message GetLinkMetadataRequest {
  51. string link = 1;
  52. }
  53. message LinkMetadata {
  54. string title = 1;
  55. string description = 2;
  56. string image = 3;
  57. }
  58. enum NodeType {
  59. NODE_UNSPECIFIED = 0;
  60. // Block nodes.
  61. LINE_BREAK = 1;
  62. PARAGRAPH = 2;
  63. CODE_BLOCK = 3;
  64. HEADING = 4;
  65. HORIZONTAL_RULE = 5;
  66. BLOCKQUOTE = 6;
  67. LIST = 7;
  68. ORDERED_LIST_ITEM = 8;
  69. UNORDERED_LIST_ITEM = 9;
  70. TASK_LIST_ITEM = 10;
  71. MATH_BLOCK = 11;
  72. TABLE = 12;
  73. EMBEDDED_CONTENT = 13;
  74. // Inline nodes.
  75. TEXT = 51;
  76. BOLD = 52;
  77. ITALIC = 53;
  78. BOLD_ITALIC = 54;
  79. CODE = 55;
  80. IMAGE = 56;
  81. LINK = 57;
  82. AUTO_LINK = 58;
  83. TAG = 59;
  84. STRIKETHROUGH = 60;
  85. ESCAPING_CHARACTER = 61;
  86. MATH = 62;
  87. HIGHLIGHT = 63;
  88. SUBSCRIPT = 64;
  89. SUPERSCRIPT = 65;
  90. REFERENCED_CONTENT = 66;
  91. SPOILER = 67;
  92. HTML_ELEMENT = 68;
  93. }
  94. message Node {
  95. NodeType type = 1;
  96. oneof node {
  97. // Block nodes.
  98. LineBreakNode line_break_node = 11;
  99. ParagraphNode paragraph_node = 12;
  100. CodeBlockNode code_block_node = 13;
  101. HeadingNode heading_node = 14;
  102. HorizontalRuleNode horizontal_rule_node = 15;
  103. BlockquoteNode blockquote_node = 16;
  104. ListNode list_node = 17;
  105. OrderedListItemNode ordered_list_item_node = 18;
  106. UnorderedListItemNode unordered_list_item_node = 19;
  107. TaskListItemNode task_list_item_node = 20;
  108. MathBlockNode math_block_node = 21;
  109. TableNode table_node = 22;
  110. EmbeddedContentNode embedded_content_node = 23;
  111. // Inline nodes.
  112. TextNode text_node = 51;
  113. BoldNode bold_node = 52;
  114. ItalicNode italic_node = 53;
  115. BoldItalicNode bold_italic_node = 54;
  116. CodeNode code_node = 55;
  117. ImageNode image_node = 56;
  118. LinkNode link_node = 57;
  119. AutoLinkNode auto_link_node = 58;
  120. TagNode tag_node = 59;
  121. StrikethroughNode strikethrough_node = 60;
  122. EscapingCharacterNode escaping_character_node = 61;
  123. MathNode math_node = 62;
  124. HighlightNode highlight_node = 63;
  125. SubscriptNode subscript_node = 64;
  126. SuperscriptNode superscript_node = 65;
  127. ReferencedContentNode referenced_content_node = 66;
  128. SpoilerNode spoiler_node = 67;
  129. HTMLElementNode html_element_node = 68;
  130. }
  131. }
  132. message LineBreakNode {}
  133. message ParagraphNode {
  134. repeated Node children = 1;
  135. }
  136. message CodeBlockNode {
  137. string language = 1;
  138. string content = 2;
  139. }
  140. message HeadingNode {
  141. int32 level = 1;
  142. repeated Node children = 2;
  143. }
  144. message HorizontalRuleNode {
  145. string symbol = 1;
  146. }
  147. message BlockquoteNode {
  148. repeated Node children = 1;
  149. }
  150. message ListNode {
  151. enum Kind {
  152. KIND_UNSPECIFIED = 0;
  153. ORDERED = 1;
  154. UNORDERED = 2;
  155. DESCRIPTION = 3;
  156. }
  157. Kind kind = 1;
  158. int32 indent = 2;
  159. repeated Node children = 3;
  160. }
  161. message OrderedListItemNode {
  162. string number = 1;
  163. int32 indent = 2;
  164. repeated Node children = 3;
  165. }
  166. message UnorderedListItemNode {
  167. string symbol = 1;
  168. int32 indent = 2;
  169. repeated Node children = 3;
  170. }
  171. message TaskListItemNode {
  172. string symbol = 1;
  173. int32 indent = 2;
  174. bool complete = 3;
  175. repeated Node children = 4;
  176. }
  177. message MathBlockNode {
  178. string content = 1;
  179. }
  180. message TableNode {
  181. repeated Node header = 1;
  182. repeated string delimiter = 2;
  183. message Row {
  184. repeated Node cells = 1;
  185. }
  186. repeated Row rows = 3;
  187. }
  188. message EmbeddedContentNode {
  189. string resource_name = 1;
  190. string params = 2;
  191. }
  192. message TextNode {
  193. string content = 1;
  194. }
  195. message BoldNode {
  196. string symbol = 1;
  197. repeated Node children = 2;
  198. }
  199. message ItalicNode {
  200. string symbol = 1;
  201. string content = 2;
  202. }
  203. message BoldItalicNode {
  204. string symbol = 1;
  205. string content = 2;
  206. }
  207. message CodeNode {
  208. string content = 1;
  209. }
  210. message ImageNode {
  211. string alt_text = 1;
  212. string url = 2;
  213. }
  214. message LinkNode {
  215. string text = 1;
  216. string url = 2;
  217. }
  218. message AutoLinkNode {
  219. string url = 1;
  220. bool is_raw_text = 2;
  221. }
  222. message TagNode {
  223. string content = 1;
  224. }
  225. message StrikethroughNode {
  226. string content = 1;
  227. }
  228. message EscapingCharacterNode {
  229. string symbol = 1;
  230. }
  231. message MathNode {
  232. string content = 1;
  233. }
  234. message HighlightNode {
  235. string content = 1;
  236. }
  237. message SubscriptNode {
  238. string content = 1;
  239. }
  240. message SuperscriptNode {
  241. string content = 1;
  242. }
  243. message ReferencedContentNode {
  244. string resource_name = 1;
  245. string params = 2;
  246. }
  247. message SpoilerNode {
  248. string content = 1;
  249. }
  250. message HTMLElementNode {
  251. string tag_name = 1;
  252. map<string, string> attributes = 2;
  253. }