public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: simple dictionary with pandoc
Date: Sun, 12 Jul 2020 10:27:21 +0200	[thread overview]
Message-ID: <87tuydkuja.fsf@zeitkraut.de> (raw)
In-Reply-To: <f8c4c0d5-fb07-4f8a-9c87-8bb654cfd525o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

Hi Tamás,

Tamás Ferenci writes:

> I was thinking of implementing a very-very simple dictionary with pandoc.
> The idea is the following: I store the necessary information in a
> YAML-file, such as this:
>
> ---
> dictionary:
> - hungarian: asztal
>   english: table
>   remark: Can be made of wood.
> - hungarian: szék
>   english: chair
>   remark: We sit on it.
> ...
>
> Then I use a pandoc conversion with a custom template to produce a markdown
> file (arranging them in a table or list), to which I again apply pandoc to
> convert to HTML. Both a Hungarian-English and an English-Hungarian
> dictionary could be produced; a simple script could automate this whole
> process, using the above YAML file as an input and producing the two HTML
> files as outputs.
>
> My first problem is however whether it is possible at all to sort the
> entries (alphabetically) with a template?

No, sorting in templates is not possible. See
https://github.com/jgm/doctemplates for a full list of pandoc templating
engine features.

> If not, are there any good solutions to this problem? Or pandoc is simply
> not suited to solve a task like this...?

You could write a Lua filter which converts the dictionary into a normal
table. This has the advantage that you'd not be limited to a single
output format. Sorting is possible in Lua, but somewhat awkward. See
https://www.lua.org/manual/5.3/manual.html#pdf-table.sort. Unicode and
locale aware sorting is even harder.

A better solution might be to write the dictionary as a CSV file, use
external tools to sort it, then use pandoc's CSV reader to produce a
table.

Cheers,
Albert

--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87tuydkuja.fsf%40zeitkraut.de.


  parent reply	other threads:[~2020-07-12  8:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-11 21:40 Tamás Ferenci
     [not found] ` <f8c4c0d5-fb07-4f8a-9c87-8bb654cfd525o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-07-12  8:27   ` Albert Krewinkel [this message]
2020-07-12 16:14   ` BPJ
     [not found]     ` <CADAJKhBj-BMcD7S94q1gu3cpxQDv9Dz18cUxrmi0rq2Ft0nQ9A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-07-13 19:42       ` Ferenci Tamas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuydkuja.fsf@zeitkraut.de \
    --to=albert+pandoc-9eawchwdxg8hfhg+jk9f0w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).