github.com/delthas/discord-formatting (go): Package formatting is a small Go library for parsing Discord markdown-like messages to an AST. The goal is to copy the Discord apps behavior as precisely as possible. This is not a general purpose Markdown parser.  The main entrypoint to the library is the Parser type, along with its NewParser function. A Parser is used to Parser.Parse a Discord message string into an AST represented by a Node.  A Node is a node of the message tree and has a list of Node children. There are several types implementing the Node interface, such as TextNode. The recommended way to consume the AST is to Walk it, with a Walker function that runs a type switch on the Node type, to display appropriate begin/end formatting, or set internal state. It is recommended that unknown Node types be ignored by the consumer.  For example, when writing a Discord to IRC bridge, the function passed to Walk would output an IRC bold formatting character to the output on entering and leaving a BoldNode.  The library currently does not come with official formatters for the message AST.  The Debug function can be used to print a node tree in a human-readable format.
Keywords: ast|discord|formatting|markdown|parser