quip2md

package module
v0.0.0-...-14159d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2018 License: MIT Imports: 13 Imported by: 0

README

quip2md GoDoc Build Status

Quip is a cloud documentation suite which provides a web API for interacting with it. While the UI has export options for different formats, it all happens client-side. The API only returns HTML which is heavily customized to work with their styling. Unfortunately this means no markdown converter knows how to act when processing.

There's an existing issue on the quip-api repo but it doesn't seem to be a priority. That's where quip2md comes in!

Supported Features

  • Headers 1-3
  • Bold
  • Italics
  • Underline [*]
  • Strikethrough [*]
  • Inline Code
  • Hyperlinks
  • Unordered Lists
  • Ordered Lists
  • Checked Lists w/ check marks maintained
  • Nested lists w/ a-z and roman numerals on unordered lists
  • Quote Blocks w/ maintained text styling
  • Code Blocks - including adjacent ones
Caveats [*]
  • Not every Markdown renderer supports underline the same way. We use _this_
  • Not every Markdown renderer supports strikethrough. We use ~~this~~
  • Highlighted text will be converted with no styling applied

Download

go get -u github.com/coxley/quip2md/...

Usage

quip2md can be used as both a library in your Go program or from the CLI. This is done to enable any project regardless of implementation language to take advantage

If you're using the go-quip library, usage might look like the following:

package main

import (
	"fmt"

	"github.com/coxley/quip2md"
	quip "github.com/mduvall/go-quip"
)

const quip_token = "YOUR_API_TOKEN"
const quip_ref_doc = "EXAMPLE_DOCUMENT_THREAD_ID"

func main() {
	q := quip.NewClient(quip_token)
	thread := q.GetThread(quip_ref_doc)
	md, _ := quip2md.QuipToMarkdown(thread.Html)
	fmt.Println(md)

}

From the CLI:

$ quip2md --help
NAME:
   quip2md - Convert Quip HTML to Markdown

USAGE:
   quip2md [file to convert]
   cat [file to convert] | quip2md
   custom_program | quip2md

Documentation

Index

Constants

View Source
const (
	UnorderedList string = "5"
	OrderedList   string = "6"
	CheckedList   string = "7"
)
View Source
const (
	Bold          string = "b"
	Italic        string = "i"
	Underline     string = "u"
	Strikethrough string = "del"
	CodeInline    string = "code"
	Anchor        string = "a"
	Highlight     string = "annotation"

	H1         string = "h1"
	H2         string = "h2"
	H3         string = "h3"
	CodeBlock  string = "pre"
	Paragraph  string = "p"
	BlockQuote string = "blockquote"
)
View Source
const ZERO_WIDTH_SPACE = "\u200b"

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDigest

func AssetDigest(name string) ([sha256.Size]byte, error)

AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func Digests

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func QuipToMarkdown

func QuipToMarkdown(q string) (string, error)

QuipToMarkdown converts HTML from Quip HTML as string to sane Markdown

Supported Features:

  • Headers 1-3
  • Bold
  • Italics
  • Underline [*]
  • Strikethrough [*]
  • Inline Code
  • Hyperlinks
  • Unordered Lists
  • Ordered Lists
  • Checked Lists w/ check marks maintained
  • Nested lists w/ a-z and roman numerals on unordered lists
  • Quote Blocks w/ maintained text styling
  • Code Blocks - including adjacent ones

Caveats [*]:

  • Not every Markdown renderer supports underline the same way. We use `_this_`
  • Not every Markdown renderer supports strikethrough. We use `~~this~~`
  • Highlighted text will be converted with no styling applied

Funny Quip HTML quirks:

  • Everything is within a tag. Each tag is on it's own line
  • Between paragraphs, there's a paragraph tag with 200b (unicod zero width space)
  • <li> ends with </span><br/></li>
  • Type of list is dictated by the class with starting value in attr
  • Nested lists are tracked with class=parent on <li>
  • Checked list checks are tracked by class=checked
  • Code blocks are dictated by class=prettyprint. All content on one line in HTML
  • For conversion purposes, almost all metadata can be ignored

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL