Getty Ritter 8a34d6bd1e Fixed import issues in last merge | 8 years ago | |
---|---|---|
ptolemy | 8 years ago | |
ptolemy-bridge | 8 years ago | |
ptolemy-core | 8 years ago | |
ptolemy-reader-markdown | 8 years ago | |
ptolemy-reader-slackdown | 8 years ago | |
ptolemy-writer-html | 8 years ago | |
.gitignore | 8 years ago | |
README.md | 8 years ago | |
cabal.project | 8 years ago |
WARNING: STILL SUPER EARLY IN DEVELOPMENT, AND MAY NEVER GO ANYWHERE AT ALL.
The motivation behind Ptolemy is to address some minor gripes about Pandoc as a library. Let's be clear: Pandoc is awesome. It's amazing both as a utility and as a library, and a ridiculous amount of work has gone into making it as cool as it is.
One of the major strengths of Pandoc is that it's frankly huge. It's got all kinds of amazing features and implements a ridiculous amount of stuff. The downside to that is that when you want to use Pandoc as a library, you often only want a tiny subset of its functionality. Maybe you want to parse Markdown and RST, and produce HTML. Maybe you want to pull in HTML but also spit out LaTeX. With Pandoc, you can't go in a little bit: you have to get it all.
This library is an experiment in building a heavily Pandoc-inspired system with a more modular structure. With Ptolemy, you can select just the readers and writers you want and compose them together without having to draw in the the hundred-odd modules that compose Pandoc proper. It also should simplify plugging in new modules to a Pandoc-like ecosystem: I could, for example, create a new markup format and easily translate it to the Ptolemy internal format and then use existing Ptolemy writers with it.
That said, it might turn out that this is no net win at all. We'll see!
This doesn't actually work yet, but it will look something like
this. This program will depend on ptolemy-reader-markdown
,
ptolemy-writer-html
and text
:
import qualified Data.Text as Text
import qualified Text.Ptolemy.Markdown.Writer as MS
import qualified Text.Ptolemy.HTML.Writer as HTML
main :: IO
main = do
cs <- Text.getContents
case MD.readSlackdown MD.defaultOpts cs of
Left err -> putStrLn err
Right pt -> Text.putStrLn (HTML.writeHtmlStrict pt)
The name Ptolemy is a Greek name that was given to a number of famous Greek and Egyptian historical figures, but I chose it for this project for two reasons: