A new option for converting to PreTeXt

67 views
Skip to first unread message

Oscar Levin

unread,
Apr 16, 2019, 12:52:13 AM4/16/19
to PreTeXt development
Hi all,

I've been playing around with Pandoc recently and noticed that it has a mechanism for creating custom "writers".  I've started on a writer for PreTeXt!  You can see progress here: https://github.com/oscarlevin/pandoc-pretext.

My motivation is this: over the summer I will be helping some people at UNC start authoring a Math for Elementary Teachers book in PreTeXt.  Many of the materials they have already written are in Word.  I don't want to retype everything, or copy past and manually insert <p> and <m> tags everywhere.   Pandoc can read word files (among many others), even with math in them.  The "reader" converts all the elements to an AST (abstract syntax tree).  Then one of its many "writers" converts the AST to the specified output format.  Now that output format can be PreTeXt.  All that is required is an instillation of Pandoc and the "pretext.lua" file.

I've only tested this minimally, so I would be grateful for feedback.  I hope to add some features, although this will never be as robust as Davids LaTeX converter.  But for a quick job, it might be easier for someone starting out.

Oscar.

Rob Beezer

unread,
Apr 16, 2019, 4:17:53 PM4/16/19
to prete...@googlegroups.com
Dear Oscar,

Very exciting! I'll see about a test-drive tomorrow.

Rob

On 4/15/19 9:52 PM, Oscar Levin wrote:
> Hi all,
>
> I've been playing around with Pandoc <https://pandoc.org/>recently and noticed
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com
> <mailto:pretext-dev...@googlegroups.com>.
> To post to this group, send email to prete...@googlegroups.com
> <mailto:prete...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/e25ed725-3a96-4644-82b8-3e9498d1a94a%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-dev/e25ed725-3a96-4644-82b8-3e9498d1a94a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Rob Beezer

unread,
Apr 16, 2019, 11:38:33 PM4/16/19
to PreTeXt development
Not tomorrow.  Tonight.

Got the following

rob@lava:/tmp/pan$ pandoc ~/mathbook/mathbook/README.md -t pretext.lua -o test.ptx
PANIC
: unprotected error in call to Lua API ([string "pretext.lua"]:12: attempt to index global 'pandoc' (a nil value))

Similar result with a different input file.  (I copied pretext/lua into the working directory.)

Cursory Googling didn't get me past this.  I don't have Lua installed.

Rob
> To post to this group, send email to prete...@googlegroups.com

Oscar Levin

unread,
Apr 17, 2019, 12:11:23 AM4/17/19
to PreTeXt development
Hmmm.  Thanks for the report.  I just pushed a possible fix (there are some commands that are part of the custom writer template that I don't think I use, such as pandoc.pipe, which is commented out just now).

 I assume you have pandoc installed, right?  Can you convert files using the built in writers?  Say 
pandoc examples/README.md -o test.db

This is helpful: i do have extra stuff installed that helped me debug, so I don't know what a clean pandoc install looks like.

Oscar.
> <mailto:pretext-dev+unsub...@googlegroups.com>.
> To post to this group, send email to prete...@googlegroups.com

Rob Beezer

unread,
Apr 17, 2019, 12:03:51 PM4/17/19
to prete...@googlegroups.com
I've moved this onto an issue for Oscar's project:

https://github.com/oscarlevin/pandoc-pretext/issues/1

On 4/16/19 9:11 PM, Oscar Levin wrote:
> Hmmm.  Thanks for the report.  I just pushed a possible fix (there are some
> commands that are part of the custom writer template that I don't think I use,
> such as pandoc.pipe, which is commented out just now).
>
>  I assume you have pandoc installed, right?  Can you convert files using the
> built in writers?  Say
> |
> pandoc examples/README.md -o test.db
> |
>
> This is helpful: i do have extra stuff installed that helped me debug, so I
> don't know what a clean pandoc install looks like.
>
> Oscar.
>
> On Tuesday, April 16, 2019 at 9:38:33 PM UTC-6, Rob Beezer wrote:
>
> Not tomorrow.  Tonight.
>
> Got the following
>
> |
> rob@lava:/tmp/pan$ pandoc ~/mathbook/mathbook/README.md -t pretext.lua -o
> test.ptx
> PANIC:unprotected error incall to LuaAPI ([string"pretext.lua"]:12:attempt
> to index global'pandoc'(a nilvalue))
> |
>
> Similar result with a different input file.  (I copied pretext/lua into the
> working directory.)
>
> Cursory Googling didn't get me past this.  I don't have Lua installed.
>
> Rob
>
> On Tuesday, April 16, 2019 at 1:17:53 PM UTC-7, Rob Beezer wrote:
>
> Dear Oscar,
>
> Very exciting!  I'll see about a test-drive tomorrow.
>
> Rob
>
> On 4/15/19 9:52 PM, Oscar Levin wrote:
> > Hi all,
> >
> > I've been playing around with Pandoc <https://pandoc.org/>recently
> and noticed
> > that it has a mechanism for creating custom "writers".  I've started
> on a writer
> > for PreTeXt!  You can see progress here:
> > https://github.com/oscarlevin/pandoc-pretext
> <https://github.com/oscarlevin/pandoc-pretext>.
> > to prete...@googlegroups.com <javascript:>
> > <mailto:pretext-dev...@googlegroups.com <javascript:>>.
> > To post to this group, send email to prete...@googlegroups.com
> <javascript:>
> > <mailto:prete...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/pretext-dev/e25ed725-3a96-4644-82b8-3e9498d1a94a%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com
> <mailto:pretext-dev...@googlegroups.com>.
> To post to this group, send email to prete...@googlegroups.com
> <mailto:prete...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/83ecd7fc-282c-4189-8bc3-53ac6a78dd43%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-dev/83ecd7fc-282c-4189-8bc3-53ac6a78dd43%40googlegroups.com?utm_medium=email&utm_source=footer>.

Rob Beezer

unread,
Apr 19, 2019, 10:47:18 AM4/19/19
to prete...@googlegroups.com
For the record, I was testing with a mildly out-of-date version of Pandoc,
provided by latest Ubuntu LTS release. Oscar's got everything sorted, so it
should be safe to test again. Thanks, Oscar.
Reply all
Reply to author
Forward
0 new messages