Pandoc use

Skip to first unread message

Aug 16, 2021, 10:31:48 AMAug 16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi folks,
Linux is Debian buster + Erlang packages V.1:24.0.5-1 from erlang-solutions.
The final goal is to convert a blog's comments posts to html files, in order to serve them faster with nginx and to generate more easily other pages.
I feel miserable as I spent hours to try to get pandoc working into Nitrogen, but to no avail :(

* Template is a copy of ORG index.html, just added :[[[page:jypandoc()]]] after [[[page:body()]]]
** adding: options=[ {from, "markdown"}, {to, "html"} ] to the main() Fn ruins the page rendering :/
* tstpandoc.erl is a copy of ORG index.erl (just kept the button anf the text below, in which I added:
** jypandoc - >  wf:pandoc(
"= Welcome to Nitrogen! =

== This is Title level 2 ==

For beautifiers we have **bold** and //italic//.
" )).
*** adding: [ {from, "markdown"}, {to, "html"} ] to this Fn doesn't change anything (page is still ruined) - removing the wf:pandoc call also fails:
error:undef -------------------------- [{wf,pandoc, [<<"= Welcome to Nitrogen! =\n\n== This is Title level 2 ==\n\nFor beautifiers we have **bold** and //italic//.\n\nThere is also __underline__, --strike-- and ``monospaced``.\n\n+ Numbered Title level 1 +\n blablabla\n++ Numbered Title level 2 ++\n bliblibli\n+++ Numbered Title level 3 +++\n blobloblo\n\n\n- This is a list of items\n- Just use hyphens\n - More indent opens a sublist\n\n\nTWO (!) blank lines close all the lists.\n">>, [{from,"markdown"},{to,"html"}]], []}, {element_function,call_next_function,1, [{file,"src/elements/other/element_function.erl"}, {line,35}]}, {wf_render_elements,call_element_render,3, [{file,"src/lib/wf_render_elements.erl"},{line,153}]}, {wf_render_elements,prepare_and_render,3, [{file,"src/lib/wf_render_elements.erl"},{line,122}]}, {wf_render_elements,inner_render_elements,1, [{file,"src/lib/wf_render_elements.erl"},{line,42}]}, {wf_render_elements,inner_render_elements,1, [{file,"src/lib/wf_render_elements.erl"},{line,42}]}, {wf_render_elements,prepare_and_render,3, [{file,"src/lib/wf_render_elements.erl"},{line,122}]}, {wf_render_elements,render_elements,1, [{file,"src/lib/wf_render_elements.erl"},{line,34}]}]

So, after many tries, here I am (sniff)

Aug 21, 2021, 5:34:25 PMAug 21
to Nitrogen Project / The Nitrogen Web Framework for Erlang
In case of somebody meet the same problem, the call was baaad,
I added this at the end of the " inner_body() -> […]" bloc of a copy of index.erl:
, wf_pandoc:convert(
"same bla bla as before
(format = txt2tags == t2t for pandoc call)"
, [ {from, "t2t"}, {to, "html"} ]

I was also forced to modify 2 things, as described in this ticket, the default scratch DIR and a file of simple_bridge: simple_bridge_util.erl that did not created this DIR ; just in case, I repeat this here:
Move the scratch dir from "./scratch" (bad, where does it go?) to "/var/tmp/scratch" (good, well identified) - into: etc/simple_bridge.config
diff etc/simple_bridge.config_ORG etc/simple_bridge.config
< {scratch_dir, "./scratch"}
> %%%%%% {scratch_dir, "./scratch"}
> {scratch_dir, "/var/tmp/scratch"}

Check if the scratch DIR exist and if not, create it - into: lib/simple_bridge/src/simple_bridge_util.erl

diff simple_bridge_util.erl_ORG simple_bridge_util.erl

< Other -> Other
> %%%Other -> Other
> Other -> > % +1 L: the DIR of temporaries is not auto-created, do it
>            % otherwise a wf_pandoc(…) call will fail with :
>            % openBinaryFile: does not exist (No such file or directory)
>            ok = filelib:ensure_dir(Other ++ "/"),
> Other

Reply all
Reply to author
0 new messages