================
@@ -0,0 +1,266 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Standalone Markdown parsing library for the LLVM ecosystem.
+///
+/// The parser takes plain text and returns a list of nodes describing the
+/// Markdown it found. Each kind of construct has its own node type, and every
+/// node shares a common MDNode base, so you can use
+/// llvm::isa<>/cast<>/dyn_cast<> to check what a node is.
+///
+/// Inline nodes (appear inside ParagraphNode, HeadingNode, etc.):
+///   TextNode: plain text run
+///   SoftBreakNode: soft line break
+///   HardBreakNode: hard line break (trailing spaces or backslash)
+///   InlineCodeNode: inline code span (`code`)
+///   EmphasisNode: emphasis (*text* or _text_)
+///   StrongNode: strong emphasis (**text** or __text__)
+///
+/// Block nodes:
+///   ParagraphNode: sequence of inline nodes
+///   HeadingNode: ATX heading (# through ######), level 1-6
+///   FencedCodeNode: fenced code block (``` or ~~~)
+///   TableNode: pipe table (a header row and body rows of cells)
+///   UnorderedListNode: bullet list (-, *, +)
+///   OrderedListNode: numbered list with explicit start number
+///   ListItemNode: single item inside a list
+///   BlockQuoteNode: block quote (>)
+///   ThematicBreakNode: horizontal rule (---, ***, ___)
+///
+/// All nodes are arena-allocated. The caller owns the arena and must keep it
+/// alive for the lifetime of any returned nodes. Malformed input is parsed as
+/// plain text rather than rejected; unrecognized text falls back to TextNode.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SUPPORT_MARKDOWN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_SUPPORT_MARKDOWN_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
+
+namespace clang::doc::markdown {
+
+/// Discriminator for all Markdown AST nodes. Inline kinds are grouped before
+/// block kinds.
+enum class NodeKind {
+  // Inline nodes
+  NK_Text,
+  NK_SoftBreak,
+  NK_HardBreak,
+  NK_InlineCode,
+  NK_Emphasis,
+  NK_Strong,
+  NK_LastInline = NK_Strong, // sentinel: all inline kinds are <= this
+
+  // Block nodes
+  NK_Paragraph,
+  NK_Heading,
+  NK_FencedCode,
+  NK_Table,
+  NK_UnorderedList,
+  NK_OrderedList,
+  NK_ListItem,
+  NK_BlockQuote,
+  NK_ThematicBreak,
+  NK_FirstBlock = NK_Paragraph, // sentinel: all block kinds are >= this
+};
+
+/// Base type for all Markdown AST nodes. Nodes are arena-allocated and have no
+/// virtual destructor; use llvm::isa<>/cast<>/dyn_cast<> for type-safe
+/// downcasting.
----------------
ilovepi wrote:

```suggestion
/// Base type for all Markdown AST nodes. Nodes are intended to be 
arena-allocated and must be trivially destructible.
```
You should have static asserts about this, the same way we do in clang-doc.

https://github.com/llvm/llvm-project/pull/202991
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to