Coder Social home page Coder Social logo

notion-export's Introduction

nexp

โš ๏ธ:: I'm currently wrapping up the first release of this library and it's not ready for use.

A CLI and Go Library for exporting Notion pages to formats such as Markdown or HTML.

nexp leverages joemi/notionapi to query the official Notion API. It then parses each Notion block and renders a text representation based on your desired format. You can download nexp as a statically compiled binary to quicky export pages or include in scripts. Additionally, nexp can be used as a library in your Go code where, along with joemi/notionapi, you can query and setup advanced rules exporting pages.

You may consider nexp to:

Documentation

Install and Basic Usage

Visit the documentation for details beyond this section.

As a CLI

  1. Download and add nexp to your $PATH.

    a. Download from GitHub releases. and move it to your path.

    b. Use go install github.com/joshrosso/nexp.

  2. Add your Notion integration token to nexp.

    nexp login
    token: <paste token here and hit enter>

    You can create an integration token at (https://www.notion.so/my-integrations). Ensure whatever page you'd like to access you've shared with this integration (can be done in the Notion GUI by clicking share on a page.)

  3. Export a page to Markdown.

    nexp export 71ad7bd4cbae457f809dd313aa595b4a

    Alternatively, you can use the page URL as the argument above, for example, the full URL of the above is https://www.notion.so/joshrosso/Days-of-Future-Passed-71ad7bd4cbae457f809dd313aa595b4a

  4. The resulting Markdown will be printed to standard out and can be piped accordingly.

    Images that are hosted in Notion are saved to ./images/<image-name>.

As a Library

To use nexp as a library, you will import the nexp/export package.

  1. Add nexp/export to your Go project.

    go get github.com/joshrosso/nexp/export
  2. Import nexp.

    package main
    
    import (
    	"fmt"
    	"github.com/joshrosso/nexp/export"
    )
    
    const (
    	pageID = "71ad7bd4cbae457f809dd313aa595b4a"
    )
    
    func main() {
    	fmt.Println("hello world")
    
    	e, err := export.NewExporter()
    	if err != nil {
    		panic(err)
    	}
    	r, err := export.NewRenderer("markdown")
    	if err != nil {
    		panic(err)
    	}
    
    	output, err := e.Render(pageID, r)
    	if err != nil {
    		panic(err)
    	}
    
    	fmt.Printf("%s\n", output)
    }
  3. Run the above, and view the Markdown output.

    go run main.go

    Images that are hosted in Notion are saved to ./images/<image-name>.

Development & Contributing

  • Run make to get help text on development tasks.
  • Issues and Pull Requests welcome.
    • Consider opening an issue for non-trivial changes before implementing and opening a PR.
  • Line width for code contributions must be <= 99 columns.

notion-export's People

Contributors

joshrosso avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.