Skip to content

Commit

Permalink
Add partial port of Pandex
Browse files Browse the repository at this point in the history
Also bump to 0.12.2 and update documentation.

This commit should resolve #43 and also address #41.
Still needed is some better documentation about how to configure Lodox.

Pandex: https://github.com/FilterKaapi/pandex
  • Loading branch information
yurrriq committed Jan 25, 2016
1 parent 1d55d22 commit c9e48dd
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 168 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Finally, add Lodox to your `plugins` list:
[% ...
{lodox, ".*",
{git, "git://github.com/quasiquoting/lodox.git",
{tag, "0.12.1"}}}]}.
{tag, "0.12.2"}}}]}.
```

The recommended place for the Lodox plugin entry is the global [rebar3](https://github.com/rebar/rebar3) config, `~/.config/rebar3/rebar.config`,
Expand Down Expand Up @@ -60,7 +60,7 @@ rebar3 do compile, lfe lodox

If all goes well, the output will look something like:

Generated lodox v0.12.1 docs in /path/to/lodox/doc
Generated lodox v0.12.2 docs in /path/to/lodox/doc

And, as promised, [generated documentation](http://quasiquoting.org/lodox/) will be in the `doc` subdirectory of
your project.
Expand Down
2 changes: 1 addition & 1 deletion doc
74 changes: 67 additions & 7 deletions org/Lodox.org
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,7 @@ Use [pandoc] if available, otherwise [erlmarkdown].
[erlmarkdown]: https://github.com/erlware/erlmarkdown"
(case (os:find_executable "pandoc")
('false (markdown:conv_utf8 markdown))
(pandoc (let* ((tmp-md (doto (filename:absname "./tmp.md")
(file:write_file markdown)))
(html (os:cmd (++ pandoc
" -f markdown_github -t html "
tmp-md))))
(file:delete tmp-md)
html))))
(pandoc (let ((`#(ok ,html) (pandoc:convert-string markdown))) html))))

(defun format-wikilinks
([`#m(libs ,libs modules ,modules) html init]
Expand Down Expand Up @@ -1391,6 +1385,72 @@ Equivalent to [[search-funcs/3]] with `` 'undefined `` as `starting-mod`."
(lists:takewhile (lambda (c) (=/= c #\:)) func-name))
#+END_SRC

** pandoc
:PROPERTIES:
:tangle: ../src/pandoc.lfe
:END:
[[https://github.com/quasiquoting/lodox/blob/master/src/pandoc.lfe][Source]]

A partial LFE port of [[https://github.com/FilterKaapi/pandex][Pandex]].
#+BEGIN_SRC lfe :exports none
<<generated()>>
#+END_SRC
#+BEGIN_SRC lfe
(defmodule pandoc
(doc "A partial LFE port of [Pandex][].

[Pandex]: https://github.com/FilterKaapi/pandex")
(export all))

(include-lib "clj/include/compose.lfe")

(defun convert-string (string)
"Equivalent to `(`[[convert-string/3]]` string \"markdown_github\" \"html\")`."
(convert-string string "markdown_github" "html"))

(defun convert-string (string from to)
"Equivalent to `(`[[convert-string/4]]` string from to [])`."
(convert-string string from to []))

(defun convert-string (string from to _options)
(let ((dot-temp ".temp"))
(if (filelib:is_dir dot-temp) 'ok (file:make_dir dot-temp))
(let ((name (filename:join dot-temp (random-name))))
(file:write_file name string)
(let ((`#(ok ,output) (convert-file name from to)))
(file:delete name)
`#(ok ,output)))))

(defun convert-file (file)
"Equivalent to `(`[[convert-file/3]]` file \"markdown_github\" \"html\")`."
(convert-file file "markdown" "html"))

(defun convert-file (file from to)
"Equivalent to `(`[[convert-file/4]]` file from to [])`."
(convert-file file from to []))

(defun convert-file (file from to _options)
"[[convert-file/4]] works under the hood of all the other functions."
(let ((output (os:cmd (++ "pandoc " file " -f " from " -t " to))))
`#(ok ,output)))

(defun random-name ()
(++ (random-string) "-" (timestamp) ".md"))

(defun random-string ()
(random:seed (erlang:monotonic_time)
(erlang:time_offset)
(erlang:unique_integer))
(-> #0x100000000000000
(random:uniform)
(integer_to_list 36)
(string:to_lower)))

(defun timestamp ()
(let ((`#(,megasec ,sec ,_microsec) (os:timestamp)))
(-> (* megasec 1000000) (+ sec) (integer_to_list))))
#+END_SRC

* Macros
:PROPERTIES:
:noweb: yes
Expand Down
Loading

0 comments on commit c9e48dd

Please sign in to comment.