mirror of
https://github.com/go-i2p/go-rst.git
synced 2025-06-09 09:32:52 -04:00
change module path
This commit is contained in:
5
go.mod
5
go.mod
@ -1,11 +1,12 @@
|
||||
module i2pgit.org/idk/go-rst
|
||||
module github.com/go-i2p/go-rst
|
||||
|
||||
go 1.23.1
|
||||
go 1.23.5
|
||||
|
||||
require (
|
||||
github.com/jung-kurt/gofpdf v1.16.2
|
||||
github.com/leonelquinteros/gotext v1.7.0
|
||||
github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4
|
||||
i2pgit.org/idk/go-rst v0.0.0-20241117051016-28becac1359a
|
||||
)
|
||||
|
||||
require golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
||||
|
2
go.sum
2
go.sum
@ -37,3 +37,5 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
i2pgit.org/idk/go-rst v0.0.0-20241117051016-28becac1359a h1:XznUABjwo3fQ/BrHij2USpC4w9liYyyF9lcxLoqA7SQ=
|
||||
i2pgit.org/idk/go-rst v0.0.0-20241117051016-28becac1359a/go.mod h1:NK1YfVStYV/nPxngGN9QMMyVXcwkQAw8bTXdGmaXbvg=
|
||||
|
6
main.go
6
main.go
@ -6,9 +6,9 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"i2pgit.org/idk/go-rst/pkg/parser"
|
||||
"i2pgit.org/idk/go-rst/pkg/renderer"
|
||||
"i2pgit.org/idk/go-rst/pkg/translator"
|
||||
"github.com/go-i2p/go-rst/pkg/parser"
|
||||
"github.com/go-i2p/go-rst/pkg/renderer"
|
||||
"github.com/go-i2p/go-rst/pkg/translator"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -282,3 +282,32 @@ func (n *CodeNode) String() string {
|
||||
func (n *TableNode) String() string {
|
||||
return fmt.Sprintf("Table: %d columns x %d rows", len(n.headers), len(n.rows))
|
||||
}
|
||||
|
||||
// BlockQuoteNode represents an indented block quote
|
||||
type BlockQuoteNode struct {
|
||||
*BaseNode
|
||||
attribution string
|
||||
}
|
||||
|
||||
// NewBlockQuoteNode creates a new BlockQuoteNode with the given content
|
||||
func NewBlockQuoteNode(content string, attribution string) *BlockQuoteNode {
|
||||
node := &BlockQuoteNode{
|
||||
BaseNode: NewBaseNode(NodeBlockQuote),
|
||||
attribution: attribution,
|
||||
}
|
||||
node.SetContent(content)
|
||||
return node
|
||||
}
|
||||
|
||||
// Attribution returns the quote attribution if any
|
||||
func (n *BlockQuoteNode) Attribution() string {
|
||||
return n.attribution
|
||||
}
|
||||
|
||||
// String representation for debugging
|
||||
func (n *BlockQuoteNode) String() string {
|
||||
if n.attribution != "" {
|
||||
return fmt.Sprintf("BlockQuote: %s -- %s", n.Content(), n.attribution)
|
||||
}
|
||||
return fmt.Sprintf("BlockQuote: %s", n.Content())
|
||||
}
|
||||
|
@ -7,17 +7,18 @@ type NodeType int
|
||||
|
||||
// Node type constants define the possible types of nodes in the RST document tree
|
||||
const (
|
||||
NodeHeading NodeType = iota // Represents a section heading
|
||||
NodeParagraph // Represents a text paragraph
|
||||
NodeList // Represents an ordered or unordered list
|
||||
NodeListItem // Represents an item within a list
|
||||
NodeLink // Represents a hyperlink
|
||||
NodeEmphasis // Represents emphasized (italic) text
|
||||
NodeStrong // Represents strong (bold) text
|
||||
NodeMeta // Represents metadata information
|
||||
NodeDirective // Represents an RST directive
|
||||
NodeCode // Represents a code block
|
||||
NodeTable // Represents a table structure
|
||||
NodeHeading NodeType = iota // Represents a section heading
|
||||
NodeParagraph // Represents a text paragraph
|
||||
NodeList // Represents an ordered or unordered list
|
||||
NodeListItem // Represents an item within a list
|
||||
NodeLink // Represents a hyperlink
|
||||
NodeEmphasis // Represents emphasized (italic) text
|
||||
NodeStrong // Represents strong (bold) text
|
||||
NodeMeta // Represents metadata information
|
||||
NodeDirective // Represents an RST directive
|
||||
NodeCode // Represents a code block
|
||||
NodeTable // Represents a table structure
|
||||
NodeBlockQuote // Represents a block quote
|
||||
)
|
||||
|
||||
// Node interface defines the common behavior for all RST document nodes
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"bufio"
|
||||
"strings"
|
||||
|
||||
"i2pgit.org/idk/go-rst/pkg/nodes"
|
||||
"i2pgit.org/idk/go-rst/pkg/translator"
|
||||
"github.com/go-i2p/go-rst/pkg/nodes"
|
||||
"github.com/go-i2p/go-rst/pkg/translator"
|
||||
)
|
||||
|
||||
// Parser is a struct that holds the state of the parser.
|
||||
|
@ -6,7 +6,7 @@ package parser
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"i2pgit.org/idk/go-rst/pkg/translator"
|
||||
"github.com/go-i2p/go-rst/pkg/translator"
|
||||
)
|
||||
|
||||
const simpleDoc = "example/doc.rst"
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/yosssi/gohtml"
|
||||
"i2pgit.org/idk/go-rst/pkg/nodes"
|
||||
"github.com/go-i2p/go-rst/pkg/nodes"
|
||||
)
|
||||
|
||||
// HTMLRederer is a renderer that renders nodes to HTML.
|
||||
@ -101,6 +101,16 @@ func (r *HTMLRenderer) renderNode(node nodes.Node) {
|
||||
|
||||
case *nodes.DirectiveNode:
|
||||
r.renderDirective(n)
|
||||
case *nodes.BlockQuoteNode:
|
||||
r.buffer.WriteString("<blockquote>")
|
||||
r.buffer.WriteString(html.EscapeString(n.Content()))
|
||||
if attr := n.Attribution(); attr != "" {
|
||||
r.buffer.WriteString("<footer>")
|
||||
r.buffer.WriteString(html.EscapeString(attr))
|
||||
r.buffer.WriteString("</footer>")
|
||||
}
|
||||
r.buffer.WriteString("</blockquote>\n")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"i2pgit.org/idk/go-rst/pkg/nodes"
|
||||
"github.com/go-i2p/go-rst/pkg/nodes"
|
||||
)
|
||||
|
||||
// MarkdownRenderer implements a Markdown renderer with the same interface as HTMLRenderer
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/jung-kurt/gofpdf"
|
||||
"i2pgit.org/idk/go-rst/pkg/nodes"
|
||||
"github.com/go-i2p/go-rst/pkg/nodes"
|
||||
)
|
||||
|
||||
// PDFRenderer implements rendering RST nodes to PDF format
|
||||
|
Reference in New Issue
Block a user