Git Product home page Git Product logo

goorgeous's Introduction

chaseadamsio/goorgeous

https://travis-ci.org/chaseadamsio/goorgeous.svg?branch=master https://coveralls.io/repos/github/chaseadamsio/goorgeous/badge.svg?branch=master

goorgeous is a Go Org to HTML Parser.

gopher_small.gif

Pronounced: Go? Org? Yes!

“Org mode is for keeping notes, maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system.”

The purpose of this package is to come as close as possible as parsing an *.org document into HTML, the same way one might publish with org-publish-html from Emacs.

Installation

go get -u github.com/chaseadamsio/goorgeous

Usage

Org Headers

To retrieve the headers from a []byte, call OrgHeaders and it will return a map[string]interface{}:

input := "#+title: goorgeous\n* Some Headline\n"
out, _ := goorgeous.OrgHeaders(input) 
map[string]interface{}{ 
        "title": "goorgeous"
}

Org Content

After importing github.com/chaseadamsio/goorgeous, you can call Org with a []byte and it will return an html version of the content as a []byte

input := "#+TITLE: goorgeous\n* Some Headline\n"
out := goorgeous.OrgCommon([]byte(input)) 

out will be:

<h1>Some Headline</h1>/n

Why?

First off, I’ve become an unapologetic user of Emacs & ever since finding org-mode I use it for anything having to do with writing content, organizing my life and keeping documentation of my days/weeks/months.

Although I like Emacs & emacs-lisp, I publish all of my html sites with Hugo Static Site Generator and wanted to be able to write my content in org-mode in Emacs rather than markdown.

Hugo’s implementation of templating and speed are unmatched, so the only way I knew for sure I could continue to use Hugo and write in org-mode seamlessly was to write a golang parser for org content and submit a PR for Hugo to use it.

Acknowledgements

I leaned heavily on russross’ blackfriday markdown renderer as both an example of how to write a parser (with some updates to leverage the go we know today) and reusing the blackfriday HTML Renderer so I didn’t have to write my own!

goorgeous's People

Contributors

chaseadamsio avatar ageekymonk avatar carlcolglazier avatar zzamboni avatar edwardbetts avatar clockoon avatar sanandak avatar wd avatar

Watchers

Donald Hunter avatar  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.