Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sbinet.org/x/odt

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sbinet.org/x/odt

  • v0.1.0
  • Go
  • Socket score

Version published
Created
Source

odt

Build status GoDoc godocs.io

odt is a set of Go-based tools to deal with the ODT file format.

Installation

$> go install sbinet.org/x/odt

Examples

func main() {
	doc, err := odt.Open("testdata/simple.odt")
	if err != nil {
		panic(err)
	}
	defer doc.Close()

	var depth int
	indent := func() string {
		return strings.Repeat("  ", depth)
	}

	err = odt.Walk(doc.Node(), func(n odt.Node, entering bool) (odt.WalkStatus, error) {
		switch {
		case entering:
			ii := indent()
			fmt.Printf("%s<%s> {\n", ii, n.Name())
			depth++
		default:
			switch n := n.(type) {
			case *odt.Text:
				if n.Value != "" {
					fmt.Printf("%stext: %q\n", indent(), n.Value)
				}
			}
			depth--
			ii := indent()
			fmt.Printf("%s}\n", ii)
		}
		return odt.WalkContinue, nil
	})
	if err != nil {
		panic(err)
	}
}

odt2md

odt2md tries its best at converting an ODT document to a CommonMark one:

$> go install sbinet.org/x/odt/cmd/odt2md@latest
$> odt2md -h
odt2md converts an ODT document into a CommonMark one.

Usage: odt2md [OPTIONS] [INPUT.odt]

Example:

 $> odt2md input.odt
 $> odt2md input.odt > out.md
 $> odt2md -o out.md input.odt
 $> odt2md < input.odt > out.md
 $> odt2md -o out.md < input.odt

Options:
  -o string
    	path to output CommonMark file

$> odt2md ./testdata/simple.odt

# Title

Hello World!

FAQs

Package last updated on 22 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc