Go to the documentation of this file.
38 "\"theme\": \"base\","
39 "\"curve\": \"monotoneX\","
40 "\"rankSpacing\": 10,"
41 "\"nodeSpacing\": 10,"
42 "\"themeCSS\": \"__###__\","
43 "\"fontFamily\": \"Roboto,Segoe UI,sans-serif\","
44 "\"themeVariables\": { "
45 "\"clusterBkg\": \"white\", "
46 "\"primaryBorderColor\": \"gray\", "
47 "\"lineColor\": \"gray\", "
48 "\"secondaryTextColor\": \"gray\", "
49 "\"tertiaryBorderColor\": \"gray\", "
50 "\"primaryTextColor\": \"#666\", "
51 "\"secondaryTextColor\": \"red\" "
54 "\"subGraphTitleMargin\": { \"top\": -15, \"bottom\": 20 }, "
55 "\"diagramPadding\": 20, "
56 "\"curve\": \"monotoneX\" "
62 "\"theme\": \"base\","
63 "\"layout\": \"elk\","
64 "\"curve\": \"monotoneX\","
65 "\"rankSpacing\": 65,"
66 "\"nodeSpacing\": 60,"
67 "\"themeCSS\": \"__###__\","
68 "\"fontFamily\": \"Roboto,Segoe UI,sans-serif\","
69 "\"themeVariables\": { "
70 "\"clusterBkg\": \"white\", "
71 "\"primaryBorderColor\": \"gray\", "
72 "\"lineColor\": \"gray\", "
73 "\"secondaryTextColor\": \"gray\", "
74 "\"tertiaryBorderColor\": \"gray\", "
75 "\"primaryTextColor\": \"#666\", "
76 "\"secondaryTextColor\": \"red\" "
79 "\"diagramPadding\": 12, "
80 "\"entityPadding\": 4, "
81 "\"minEntityWidth\": 150, "
82 "\"minEntityHeight\": 20, "
83 "\"curve\": \"monotoneX\" "
91 "--ff-colvideo: #6eaa7b; "
92 "--ff-colaudio: #477fb3; "
93 "--ff-colsubtitle: #ad76ab; "
94 "--ff-coltext: #666; "
96 " g.nodes g.node.default rect.basic.label-container, "
97 " g.nodes g.node.default path { "
100 " stroke-width: 1px !important; "
101 " stroke: #e9e9e9 !important; "
102 " fill: url(#ff-filtergradient) !important; "
103 " filter: drop-shadow(0px 0px 5.5px rgba(0, 0, 0, 0.05)); "
104 " fill: white !important; "
107 " .relationshipLine { "
111 " filter: drop-shadow(0px 0px 3px rgba(0, 0, 0, 0.2)); "
114 " g.node.default g.label.name foreignObject > div > span > p, "
115 " g.nodes g.node.default g.label:not(.attribute-name, .attribute-keys, .attribute-type, .attribute-comment) foreignObject > div > span > p { "
116 " font-size: 0.95rem; "
117 " font-weight: 500; "
118 " text-transform: uppercase; "
119 " min-width: 5.5rem; "
120 " margin-bottom: 0.5rem; "
124 " .edgePaths path { "
125 " marker-end: none; "
126 " marker-start: none; "
161 #define OFFSET(x) offsetof(MermaidContext, x)
164 {
"link_coloring",
"enable colored links (requires Mermaid >= 11.5)",
OFFSET(enable_link_colors),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1 },
244 #define MM_INDENT() writer_printf(tfc, "%*c", mmc->indent_level * 2, ' ')
257 if (tfc->
level == 0) {
268 directive =
av_strireplace(diag_directive,
"__###__", css_buf.str);
273 av_log(tfc,
AV_LOG_ERROR,
"Unable to locate the required token (__###__) in the html template.");
278 for (uint64_t
i = 0;
i < length;
i++)
287 writer_put_str(tfc,
" gradient_def@{ shape: text, label: \"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1\" height=\"1\"><defs><linearGradient id=\"ff-filtergradient\" x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\"><stop offset=\"0%\" style=\"stop-color:hsl(0, 0%, 98.6%); \"/><stop offset=\"50%\" style=\"stop-color:hsl(0, 0%, 100%); \"/><stop offset=\"100%\" style=\"stop-color:hsl(0, 0%, 96.5%); \"/></linearGradient><radialGradient id=\"ff-radgradient\" cx=\"50%\" cy=\"50%\" r=\"100%\" fx=\"45%\" fy=\"40%\"><stop offset=\"25%\" stop-color=\"hsl(0, 0%, 100%)\" /><stop offset=\"100%\" stop-color=\"hsl(0, 0%, 96%)\" /></radialGradient></defs></svg>\" }\n");
304 if (parent_sec_data.subgraph_start_incomplete) {
306 if (parent_buf->len > 0)
336 av_log(tfc,
AV_LOG_ERROR,
"Unable to write subgraph start. Missing id field. Section: %s", section->
name);
430 if (sec_data.current_is_textblock) {
433 if (sec_data.section_id) {
441 }
else if (sec_data.current_is_stadium) {
461 if (sec_data.section_id) {
474 if (sec_data.src_id && sec_data.dest_id
480 av_bprintf(&mmc->
link_buf,
"\n %s %s-%s-%s@==", sec_data.src_id, sec_data.section_type, sec_data.src_id, sec_data.dest_id);
501 switch (sec_data.link_type) {
524 if (tfc->
level == 0) {
530 av_log(tfc,
AV_LOG_ERROR,
"Unable to locate the required token (__###__) in the html template.");
533 token_pos += strlen(
"__###__");
538 if (tfc->
level == 1) {
550 const char *str,
int64_t num,
const int is_int)
610 const char *col_type;
615 if (sec_data.section_id && !strcmp(str, sec_data.section_id))
617 else if (sec_data.dest_id && !strcmp(str, sec_data.dest_id))
619 else if (sec_data.src_id && !strcmp(str, sec_data.src_id))
672 .priv_class = &mermaid_class,
677 .
name =
"mermaidhtml",
686 .priv_class = &mermaid_class,
#define AV_BPRINT_SIZE_UNLIMITED
#define AV_TEXTFORMAT_SECTION_PRINT_TAGS
...
AVBPrint link_buf
print buffer for writing diagram links
#define AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER
@ AV_TEXTFORMAT_LINKTYPE_SRCDEST
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
static av_cold int has_link_pair(const AVTextFormatContext *tfc, const char *src, const char *dest)
const char * src_id_key
name of the key to be used as the source id for diagram connections
@ AV_DIAGRAMTYPE_ENTITYRELATIONSHIP
const char * context_type
static void writer_printf(AVTextFormatContext *wctx, const char *fmt,...)
#define AV_TEXTFORMAT_SECTION_FLAG_IS_SUBGRAPH
...
@ AV_TEXTFORMAT_LINKTYPE_ONETOMANY
static void mermaid_print_int(AVTextFormatContext *tfc, const char *key, int64_t value)
DEFINE_FORMATTER_CLASS(mermaid)
static const char * init_directive
int level
current level, starting from 0
#define AV_ESCAPE_FLAG_STRICT
Escape only specified special characters.
@ AV_TEXTFORMAT_LINKTYPE_MANYTOONE
const AVTextFormatter avtextformatter_mermaid
static void mermaid_print_str(AVTextFormatContext *tfc, const char *key, const char *value)
static av_cold int mermaid_init_html(AVTextFormatContext *tfc)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void * priv
private data for use by the filter
int subgraph_start_incomplete
Describe the class of an AVClass context structure.
static void writer_w8(AVTextFormatContext *wctx, int b)
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags)
Escape the content in src and append it to dstbuf.
static const AVTextFormatSection * tf_get_parent_section(AVTextFormatContext *tfc, int level)
Safely access the parent section.
char * av_strireplace(const char *str, const char *from, const char *to)
Locale-independent strings replace.
@ AV_TEXTFORMAT_LINKTYPE_MANYTOMANY
AVDiagramConfig * diagram_config
#define SECTION_MAX_NB_LEVELS
int(* init)(AVBSFContext *ctx)
static void mermaid_print_section_footer(AVTextFormatContext *tfc)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static void mermaid_print_value(AVTextFormatContext *tfc, const char *key, const char *str, int64_t num, const int is_int)
#define AV_TEXTFORMAT_SECTION_FLAG_IS_SHAPE
...
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various formatters
static const char * theme_css_er
const AVTextFormatter avtextformatter_mermaidhtml
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
const char * linktype_key
name of the key to be used as the link type for diagram connections (AVTextFormatLinkType)
static void mermaid_print_section_header(AVTextFormatContext *tfc, const void *data)
AVDiagramType diagram_type
static void writer_put_str(AVTextFormatContext *wctx, const char *str)
static void uninit(AVBSFContext *ctx)
#define i(width, name, range_min, range_max)
unsigned nb_link_captions[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section,
static void set_str(const char **dst, const char *src)
static av_cold int mermaid_init(AVTextFormatContext *tfc)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
struct MermaidContext::section_data section_data[SECTION_MAX_NB_LEVELS]
@ AV_TEXTFORMAT_LINKTYPE_ONETOONE
const char * dest_id_key
name of the key to be used as the target id for diagram connections
void av_bprintf(AVBPrint *buf, const char *fmt,...)
#define AV_TEXTFORMAT_SECTION_FLAG_HAS_LINKS
...
const char * html_template
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
static av_cold int mermaid_uninit(AVTextFormatContext *tfc)
const char * section_type
char * av_strdup(const char *s)
Duplicate a string.
const char * id_key
name of the key to be used as the id
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
@ AV_ESCAPE_MODE_BACKSLASH
Use backslash escaping.
static const AVTextFormatSection * tf_get_section(AVTextFormatContext *tfc, int level)
Safely validate and access a section at a given level.
void av_diagram_init(AVTextFormatContext *tfc, AVDiagramConfig *diagram_config)
AVTextFormatLinkType link_type
static const AVOption mermaid_options[]
static const char * init_directive_er