// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
package org_tangled
// schema: org.tangled.markup.markdown
import (
"bytes"
"encoding/json"
"fmt"
"io"
"github.com/bluesky-social/indigo/lex/util"
cbg "github.com/whyrusleeping/cbor-gen"
)
const (
MarkupMarkdownNSID = "org.tangled.markup.markdown"
)
func init() {
util.RegisterType("org.tangled.markup.markdown#main", &MarkupMarkdown{})
} // MarkupMarkdown is a "main" in the org.tangled.markup.markdown schema.
// Tangled Flavored Markdown format text
//
// RECORDTYPE: MarkupMarkdown
type MarkupMarkdown struct {
LexiconTypeID string `json:"$type,const=org.tangled.markup.markdown" cborgen:"$type,const=org.tangled.markup.markdown"`
// blobs: list of blobs referenced in markdown
Blobs []*MarkupMarkdown_Blobs_Elem `json:"blobs,omitempty" cborgen:"blobs,omitempty"`
// text: Final post-processed markdown content that will be rendered
Text string `json:"text" cborgen:"text"`
}
type MarkupMarkdown_Blobs_Elem struct {
MarkupEmbedImage *MarkupEmbedImage
MarkupEmbedVideo *MarkupEmbedVideo
}
func (t *MarkupMarkdown_Blobs_Elem) MarshalJSON() ([]byte, error) {
if t.MarkupEmbedImage != nil {
t.MarkupEmbedImage.LexiconTypeID = "org.tangled.markup.embed.image"
return json.Marshal(t.MarkupEmbedImage)
}
if t.MarkupEmbedVideo != nil {
t.MarkupEmbedVideo.LexiconTypeID = "org.tangled.markup.embed.video"
return json.Marshal(t.MarkupEmbedVideo)
}
return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *MarkupMarkdown_Blobs_Elem) UnmarshalJSON(b []byte) error {
typ, err := util.TypeExtract(b)
if err != nil {
return err
}
switch typ {
case "org.tangled.markup.embed.image":
t.MarkupEmbedImage = new(MarkupEmbedImage)
return json.Unmarshal(b, t.MarkupEmbedImage)
case "org.tangled.markup.embed.video":
t.MarkupEmbedVideo = new(MarkupEmbedVideo)
return json.Unmarshal(b, t.MarkupEmbedVideo)
default:
return nil
}
}
func (t *MarkupMarkdown_Blobs_Elem) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if t.MarkupEmbedImage != nil {
return t.MarkupEmbedImage.MarshalCBOR(w)
}
if t.MarkupEmbedVideo != nil {
return t.MarkupEmbedVideo.MarshalCBOR(w)
}
return fmt.Errorf("cannot cbor marshal empty enum")
}
func (t *MarkupMarkdown_Blobs_Elem) UnmarshalCBOR(r io.Reader) error {
typ, b, err := util.CborTypeExtractReader(r)
if err != nil {
return err
}
switch typ {
case "org.tangled.markup.embed.image":
t.MarkupEmbedImage = new(MarkupEmbedImage)
return t.MarkupEmbedImage.UnmarshalCBOR(bytes.NewReader(b))
case "org.tangled.markup.embed.video":
t.MarkupEmbedVideo = new(MarkupEmbedVideo)
return t.MarkupEmbedVideo.UnmarshalCBOR(bytes.NewReader(b))
default:
return nil
}
}
// MarkupMarkdown_Inline is a "inline" in the org.tangled.markup.markdown schema.
//
// Tangled Flavored Markdown format text (inline)
//
// RECORDTYPE: MarkupMarkdown_Inline
type MarkupMarkdown_Inline struct {
LexiconTypeID string `json:"$type,const=org.tangled.markup.markdown#inline" cborgen:"$type,const=org.tangled.markup.markdown#inline"`
// text: Final post-processed markdown content that will be rendered
Text string `json:"text" cborgen:"text"`
}