Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
3.2 kB · 112 lines
Go
at next-dev
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113// 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: MarkupMarkdowntype 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_Inlinetype 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"`}