Skip to content

Commit

Permalink
Merge branch 'release/0.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
yurrriq committed Aug 18, 2016
2 parents 71242e9 + e3d5f65 commit b924c26
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 93 deletions.
2 changes: 1 addition & 1 deletion doc
17 changes: 0 additions & 17 deletions include/conversions.lfe

This file was deleted.

25 changes: 8 additions & 17 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
%% -*- erlang -*-
{erl_opts, []}.

{eunit_compile_opts, [{src_dirs, ["src", "test"]}]}.

{lfe_first_files, ["src/levaindoc-util.lfe"]}.

{deps, []}.

{plugins, [
{'lfe-compile', {git, "git://github.com/lfe-rebar3/compile.git",
{tag, "0.4.0"}}}
]}.

{overrides, [
{override, 'lfe-compile', [
{deps, [
{lfe, {git, "git://github.com/rvirding/lfe.git", {branch, "develop"}}}
]}
]}
{'lfe-compile',
{git, "git://github.com/lfe-rebar3/compile.git",
{tag, "0.5.0"}}}
]}.

{provider_hooks, [{pre, [{compile, {lfe, compile}}]}]}.

{project_plugins, [
{lodox, {git, "git://github.com/lfe-rebar3/lodox.git", {tag, "0.13.0"}}}
{lodox, {git, "git://github.com/lfe-rebar3/lodox.git", {tag, "0.15.1"}}}
]}.

{lodox, [
{apps, [
{levaindoc, [
%% {'output-path', "docs"}, % TODO: hex+hexdocs
{'source-uri',
"https://github.com/quasiquoting/levaindoc/blob"
"/{version}/{filepath}#L{line}"}
"/{version}/{filepath}#L{line}"},
%% This is too ridiculous, otherwise...
{'excluded-modules', [levaindoc]}
]}
]}
]}.
98 changes: 52 additions & 46 deletions src/levaindoc-util.lfe
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
(defmodule levaindoc-util
(doc "Utility functions for [levaindoc](levaindoc.html).")
"Utility functions for [levaindoc](https://github.com/quasiquoting/levaindoc).
For each `input`/`output` pair, there exist conversion functions
`levaindoc:{{input}}->{{output}}/{1,2}` and
`levaindoc:{{input}}-file->{{output}}/{1,2}`, where the first argument is a
`string` or `file` name, respectively, and the second is a (currently ignored)
list of `options`."
;; Conversions
(export (input-formats 0) (output-formats 0))
;; Random filename
(export (random-name 0))
(import (from erlang (monotonic_time 0) (time_offset 0) (unique_integer 0))))
(export (random-name 0)))


;;;===================================================================
Expand All @@ -14,56 +18,56 @@
(defun input-formats ()
"The list of supported input formats.
```bash
$ pandoc --version | head -1
```
```
pandoc 1.15.0.6
```
```bash
$ pandoc --version | head -1
```
```
pandoc 1.17.2
```
```bash
$ pandoc --help | head -6 | tail +2
```
```
Input formats: commonmark, docbook, docx, epub, haddock, html, json*, latex,
markdown, markdown_github, markdown_mmd, markdown_phpextra,
markdown_strict, mediawiki, native, opml, org, rst, t2t,
textile, twiki
[ *only Pandoc's JSON version of native AST]
```"
```bash
$ pandoc --help | head -6 | tail +2
```
```
Input formats: commonmark, docbook, docx, epub, haddock, html, json*, latex,
markdown, markdown_github, markdown_mmd, markdown_phpextra,
markdown_strict, mediawiki, native, odt, opml, org, rst, t2t,
textile, twiki
[ *only Pandoc's JSON version of native AST]
```"
'["commonmark" "docbook" "docx" "epub" "haddock" "html" "json" "latex"
"markdown" "markdown_github" "markdown_mmd" "markdown_phpextra"
"markdown_strict" "mediawiki" "native" "opml" "org" "rst" "t2t"
"textile" "twki"])
"markdown_strict" "mediawiki" "native" "odt" "opml" "org" "rst" "t2t"
"textile" "twiki"])

(defun output-formats ()
"The list of supported output formats.
```bash
$ pandoc --version | head -1
```
```
pandoc 1.15.0.6
```
```bash
$ pandoc --version | head -1
```
```
pandoc 1.17.2
```
```bash
$ pandoc --help | tail +7 | head -7
```
```
Output formats: asciidoc, beamer, commonmark, context, docbook, docx, dokuwiki,
dzslides, epub, epub3, fb2, haddock, html, html5, icml, json*,
latex, man, markdown, markdown_github, markdown_mmd,
markdown_phpextra, markdown_strict, mediawiki, native, odt,
opendocument, opml, org, pdf**, plain, revealjs, rst, rtf, s5,
slideous, slidy, texinfo, textile
[**for pdf output, use latex or beamer and -o FILENAME.pdf]
```"
'["asciidoc" "beamer" "commonmark" "context" "docbook" "docx" "dokuwiki"
"dzslides" "epub" "epub3" "fb2" "haddock" "html" "html5" "icml" "json"
"latex" "man" "markdown" "markdown_github" "markdown_mmd"
"markdown_phpextra" "markdown_strict" "mediawiki" "native" "odt"
"opendocument" "opml" "org" "pdf" "plain" "revealjs" "rst" "rtf" "s5"
"slideous" "slidy" "texinfo" "textile"])
```bash
$ pandoc --help | tail +7 | head -7
```
```
Output formats: asciidoc, beamer, commonmark, context, docbook, docbook5, docx,
dokuwiki, dzslides, epub, epub3, fb2, haddock, html, html5,
icml, json*, latex, man, markdown, markdown_github,
markdown_mmd, markdown_phpextra, markdown_strict, mediawiki,
native, odt, opendocument, opml, org, pdf**, plain, revealjs,
rst, rtf, s5, slideous, slidy, tei, texinfo, textile, zimwiki
[**for pdf output, use latex or beamer and -o FILENAME.pdf]
```"
'["asciidoc" "beamer" "commonmark" "context" "docbook" "docbook5" "docx"
"dokuwiki" "dzslides" "epub" "epub3" "fb2" "haddock" "html" "html5"
"icml" "json" "latex" "man" "markdown" "markdown_github"
"markdown_mmd" "markdown_phpextra" "markdown_strict" "mediawiki"
"native" "odt" "opendocument" "opml" "org" "pdf" "plain" "revealjs"
"rst" "rtf" "s5" "slideous" "slidy" "tei" "texinfo" "textile"])


;;;===================================================================
Expand All @@ -81,7 +85,9 @@ Output formats: asciidoc, beamer, commonmark, context, docbook, docx, dokuwiki,

(defun random-string ()
"Generate a random, 11-character, alphanumeric string."
(random:seed (monotonic_time) (time_offset) (unique_integer))
(random:seed (erlang:monotonic_time)
(erlang:time_offset)
(erlang:unique_integer))
(string:to_lower (integer_to_list (random:uniform #0x100000000000000) 36)))

(defun timestamp ()
Expand Down
7 changes: 5 additions & 2 deletions src/levaindoc.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

{application, levaindoc, [
{description, "Lightweight LFE wrapper for pandoc."},
{vsn, "0.5.1"},
{vsn, "0.6.1"},
{registered, []},
{applications, [kernel, stdlib]},
{env, []},
{modules, [levaindoc, 'levaindoc-util']},

{maintainers, ["Eric Bailey"]},
{licenses, ["MIT"]},
{links, [{"GitHub", "https://github.com/quasiquoting/levaindoc"}]}
{links, [
{"GitHub", "https://github.com/quasiquoting/levaindoc"},
{"Documentation", "http://quasiquoting.org/levaindoc"}
]}
]}.
49 changes: 39 additions & 10 deletions src/levaindoc.lfe
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
(defmodule levaindoc
(doc "A partial LFE port of [Pandex](https://github.com/FilterKaapi/pandex).")
"A partial LFE port of [Pandex](https://github.com/FilterKaapi/pandex)."
;; API
(export (convert-string 1) (convert-string 3) (convert-string 4)
(convert-file 1) (convert-file 3) (convert-file 4))
;; Conversions
(export all))

(include-lib "levaindoc/include/conversions.lfe")

(convert-file 1) (convert-file 3) (convert-file 4)))

;;;===================================================================
;;; Conversions
;;;===================================================================

;; Define all the conversion functions, unary and binary,
;; with names of the form, {{input-format}}->{{output-format}}.
;; See include/conversions.lfe for details.
(eval-when-compile
(defun defn (name args doc body)
"Similar to Clojure's `defn`. Define and export a function."
`(progn (defun ,name ,args ,doc ,body)
(extend-module () ((export (,name ,(length args)))))))
(defun defconv (input output)
"Define conversion functions from `input` to `output`."
`(progn
,@(let ((|-CONV-| (list_to_atom (++ input "->" output))))
`(,(defn |-CONV-| '(string _options)
(++ "Given a `string` in " input " format, "
"convert it to " output ".\n "
"N.B. `_options` are currently ignored.")
`(convert-string string ,input ,output))
,(defn |-CONV-| '(string)
(++ "Given a `string` in " input " format, "
"convert it to " output ".")
`(,|-CONV-| string []))))
,@(let ((|-FILE-CONV-| (list_to_atom (++ input "-file->" output))))
`(,(defn |-FILE-CONV-| '(file _options)
(++ "Read the file `file` and convert its "
input "-formatted contents to " output ".\n "
"N.B. `_options` are currently ignored.")
`(convert-file file ,input ,output))
,(defn |-FILE-CONV-| '(file)
(++ "Read the file `file` and convert its "
input "-formatted contents to " output ".")
`(,|-FILE-CONV-| file [])))))))

(defmacro defconversions ()
"Call [[defconv/2]] on every supported `input`/`output` pair."
`(progn ,@(lc ((<- input (levaindoc-util:input-formats))
(<- output (levaindoc-util:output-formats)))
(defconv input output))))

;; Define all the conversion functions, unary and binary, for strings and files,
;; with the names, {{input-}}->{{output}} and {{input}}-file->{{output}}.
(defconversions)


Expand Down

0 comments on commit b924c26

Please sign in to comment.