markdown

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package markdown converts standard markdown to platform-specific formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractMention

func ExtractMention(body string, mentions []TeamsMention, userID string) bool

ExtractMention reports whether userID is @-mentioned in the message body. It checks the parsed mentions[] array first (authoritative), then falls back to scanning the body for <at id="N"> tags whose corresponding mentions entry resolves to userID.

func MarkdownToTeamsHTML

func MarkdownToTeamsHTML(md string) string

MarkdownToTeamsHTML converts standard markdown to the HTML subset Teams renders in chatMessage bodies when contentType == "html".

Supported: headings, bold, italic, inline code, fenced code, links, ordered/unordered lists, blockquotes. Unsupported features (e.g. tables, images) degrade to escaped plain text rather than raw HTML so the output is always safe to drop into body.content.

func SplitMessage

func SplitMessage(text string, limit int) []string

SplitMessage splits a long message into chunks that fit within limit. It splits at paragraph boundaries first, then newlines, then hard-splits.

func SplitMessageTeams

func SplitMessageTeams(text string) []string

SplitMessageTeams splits text into chunks that each fit within the Teams body limit. Prefers paragraph boundaries, then newlines, then hard splits. Mirrors the existing SplitMessage helper but uses the Teams threshold.

func SplitSummaryAndReport

func SplitSummaryAndReport(text string) (summary, report string)

SplitSummaryAndReport splits a long response into a summary and full report. The summary is the first paragraph (up to the first double newline), capped at 600 characters, with a note that the full report is attached as a file. If no paragraph boundary is found, falls back to a 500-char truncation at a sentence boundary.

func TeamsHTMLToPlain

func TeamsHTMLToPlain(s string) string

TeamsHTMLToPlain extracts plain text from a Teams chatMessage HTML body.

Strategy: replace block-level tags with newlines, replace <at> tags with their visible text, strip all remaining tags, decode entities, collapse runs of whitespace. The result is suitable for sending to the LLM as the user's prompt.

func ToSlackMrkdwn

func ToSlackMrkdwn(text string) string

ToSlackMrkdwn converts standard markdown to Slack mrkdwn format.

func ToTelegramHTML

func ToTelegramHTML(text string) string

ToTelegramHTML converts standard markdown to Telegram-compatible HTML.

Types

type TeamsMention

type TeamsMention struct {
	ID        int    `json:"id"`
	Text      string `json:"mentionText"`
	Mentioned struct {
		User struct {
			ID          string `json:"id"`
			DisplayName string `json:"displayName"`
		} `json:"user"`
	} `json:"mentioned"`
}

TeamsMention is the inbound representation of a Microsoft Graph mention entry (mentions[i] in a chatMessage). Only the fields the adapter needs are modelled — extras decode silently.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL