Documentation ¶
Overview ¶
Package blocks provides some of the Mycomarkup's blocks.
Index ¶
- Constants
- func MatchesImg(line string) bool
- func ParagraphToHtml(hyphaName, input string) string
- type Block
- type CodeBlock
- type Formatted
- type Heading
- type HorizontalLine
- type IDCounter
- type Img
- type ImgEntry
- type LaunchPad
- type List
- type ListItem
- type ListMarker
- type Paragraph
- type Quote
- type RocketLink
- type Table
- type TableCell
- type TableRow
- type Transclusion
- type TransclusionSelector
Constants ¶
const TransclusionError = "err"
TransclusionError is a value that means that the transclusion is wrong.
Variables ¶
This section is empty.
Functions ¶
func MatchesImg ¶
func ParagraphToHtml ¶
Types ¶
type Block ¶
type Block interface { // IsBlock is the method that a block should implement. In the future, this method might be removed, but for now, we need it just to put something in the interface. IsBlock() // ID returns an id for the block. It should be unique when possible. The block should increment a value in the counter depending on its type. ID(counter *IDCounter) string }
Block is a unit of Mycomarkup. It is somewhat analogous to HTML's tags.
type CodeBlock ¶ added in v0.2.0
type CodeBlock struct {
// contains filtered or unexported fields
}
CodeBlock represents a block of preformatted text.
func MakeCodeBlock ¶ added in v0.2.0
MakeCodeBlock returns a code block with the given language and contents.
func (*CodeBlock) AddLine ¶ added in v0.2.0
AddLine adds a line to the code block's contents. The line should be without line breaks.
type Formatted ¶ added in v0.2.0
type Formatted struct { HyphaName string Html string *bytes.Buffer // contains filtered or unexported fields }
func MakeFormatted ¶ added in v0.3.0
type Heading ¶ added in v0.1.2
type Heading struct { Level uint // contains filtered or unexported fields }
func MakeHeading ¶ added in v0.1.2
type HorizontalLine ¶
type HorizontalLine struct {
// contains filtered or unexported fields
}
HorizontalLine represents the horizontal line block.
In Mycomarkup it is written like that:
----
func MakeHorizontalLine ¶
func MakeHorizontalLine(src string) HorizontalLine
func (HorizontalLine) ID ¶
func (h HorizontalLine) ID(counter *IDCounter) string
func (HorizontalLine) IsBlock ¶ added in v0.4.1
func (h HorizontalLine) IsBlock()
type IDCounter ¶ added in v0.4.5
type IDCounter struct { // In some cases using the results of counting is not needed because the IDs are not needed themselves. This variable is true when this is the case. ShouldUseResults bool // contains filtered or unexported fields }
func (IDCounter) UnusableCopy ¶ added in v0.4.5
type Img ¶
type Img struct { Entries []ImgEntry // contains filtered or unexported fields }
func (*Img) HasOneImage ¶ added in v0.1.1
HasOneImage returns true if img has exactly one image and that images has no description.
func (*Img) MarkExistenceOfSrcLinks ¶ added in v0.1.1
func (img *Img) MarkExistenceOfSrcLinks()
func (*Img) ProcessLine ¶ added in v0.2.0
func (*Img) ProcessRune ¶ added in v0.2.0
type ImgEntry ¶ added in v0.1.1
ImgEntry is an entry of an image gallery. It can only be nested into Img.
func (*ImgEntry) Description ¶ added in v0.2.0
func (*ImgEntry) SizeHAsAttr ¶ added in v0.1.1
func (*ImgEntry) SizeWAsAttr ¶ added in v0.1.1
type LaunchPad ¶ added in v0.1.2
type LaunchPad struct {
Rockets []RocketLink
}
LaunchPad is a container for RocketLinks.
func MakeLaunchPad ¶ added in v0.1.2
func MakeLaunchPad() LaunchPad
func (*LaunchPad) AddRocket ¶ added in v0.1.2
func (lp *LaunchPad) AddRocket(rl RocketLink)
type List ¶
type List struct { // Items are the entries of the List. There should be at least one. Items []ListItem // Marker is the type of the list. All entries have the same type. See SameAs for information about same types. Marker ListMarker }
List is the block representing a set of related elements. It must be the same as all ListItem.Marker.
type ListItem ¶ added in v0.3.0
type ListItem struct { Marker ListMarker // Level is equal to amount of asterisks. // * -> Level = 1 // **. -> Level = 2 Level uint // Contents are Mycomarkup blocks. TODO: proper type. Contents []Block }
ListItem is an entry in a List.
type ListMarker ¶ added in v0.3.0
type ListMarker int
ListMarker is the type of a ListItem or a List.
const ( // MarkerUnordered is for bullets like * (no point). MarkerUnordered ListMarker = iota // MarkerOrdered is for bullets like *. (with point). MarkerOrdered // MarkerTodoDone is for bullets like *v (with tick). MarkerTodoDone // MarkerTodo is for bullets like *x (with cross). MarkerTodo )
func (ListMarker) SameAs ¶ added in v0.3.0
func (m1 ListMarker) SameAs(m2 ListMarker) bool
SameAs is true if both list markers are of the same type. MarkerTodoDone and MarkerTodo are considered same to each other. All other markers are different from each other.
type Quote ¶ added in v0.2.0
type Quote struct {
// contains filtered or unexported fields
}
Quote is the block representing a quote.
type RocketLink ¶ added in v0.1.2
RocketLink is a rocket link which is meant to be nested inside LaunchPad.
func MakeRocketLink ¶ added in v0.1.2
func MakeRocketLink(line, hyphaName string) RocketLink
func (RocketLink) ID ¶ added in v0.4.5
func (r RocketLink) ID(_ *IDCounter) string
func (RocketLink) IsBlock ¶ added in v0.4.1
func (r RocketLink) IsBlock()
type Table ¶
type Table struct { // data HyphaName string Caption string Rows []*TableRow // state InMultiline bool // tmp CurrCellMarker rune CurrColspan uint CurrCellBuilder strings.Builder }
Table is a table, which consists of several Rows and has a Caption.
type TableCell ¶ added in v0.1.2
TableCell is a cell in TableRow.
func (*TableCell) ColspanAttribute ¶ added in v0.2.0
ColspanAttribute returns either an empty string (if the cell doesn't have colspan) or a string in this format:
colspan="<number here>"
type TableRow ¶ added in v0.1.2
TableRow is a row in a table. Thus, it can only be nested inside a table.
func (*TableRow) LooksLikeThead ¶ added in v0.1.2
LooksLikeThead is true if the table row looks like it might as well be a thead row.
Most likely, rows with more than two header cells are theads. I allow one extra datum cell for tables like this: | ! a ! b ! c | d | e ! f | g | h
type Transclusion ¶ added in v0.2.0
type Transclusion struct { // Target is the name of the hypha to be transcluded. Target string Selector TransclusionSelector }
Transclusion is the block representing an extract from a different document.
func MakeTransclusion ¶ added in v0.2.0
func MakeTransclusion(line, hyphaName string) Transclusion
func (Transclusion) ID ¶ added in v0.2.0
func (t Transclusion) ID(counter *IDCounter) string
func (Transclusion) IsBlock ¶ added in v0.4.1
func (t Transclusion) IsBlock()
type TransclusionSelector ¶ added in v0.4.5
type TransclusionSelector struct {
// contains filtered or unexported fields
}
func DefaultSelector ¶ added in v0.4.5
func DefaultSelector() TransclusionSelector
func ParseSelector ¶ added in v0.4.5
func ParseSelector(selector string) TransclusionSelector
ParseSelector parses the selector according to the following rules.
If the selector is empty, we think of it as of selector start..description and try again.
If there is no .. in the selector, the selector selects just one block with the matching id.
If there is a .. in selector, there are two bounds: left and right. Both bounds are ids of some blocks.
Special bounds:
attachment: hypha's attachment. start: hypha's text's first block. description: hypha's text's first paragraph. end: hypha's last block.
If the left bound is empty, it is set to start. If the right bound is empty, it is set to end.