public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: "T. Kurt Bond" <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: HTML/PDF Indexes
Date: Tue, 11 Aug 2020 19:26:38 -0400	[thread overview]
Message-ID: <CAN1EhV_4p5mS5ejS+-BAUYDNfxEsUMRuaibV+1qyh06Tnghj_A@mail.gmail.com> (raw)
In-Reply-To: <6109678b-fa72-4fab-b176-abe5dcb50039o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 4605 bytes --]

Here's an example of how to generate indexes from Markdown using a Lua
filter and ConTeXt output.

I have an input file, context-index.md:

 <#cb1-1>--- <#cb1-2>title: Test out Indexes from Spans in Markdown
<#cb1-3>linkcolor: green <#cb1-4>linkcontrastcolor: red <#cb1-5>---
<#cb1-6> <#cb1-7># Section One <#cb1-8> <#cb1-9>[Éomer]{.index}[Éomer]
let blow the horns to rally all men to his <#cb1-10>banner that could
come thither; for he thought to make a great <#cb1-11>shield-wall at
the last, and stand, and fight there on foot till all <#cb1-12>fell,
and do deeds of song on the fields of
<#cb1-13>[Pelennor]{.index}Pelennor, though no man should be left in
the West <#cb1-14>to remember the last [Mark, King of the]{.index}King
of the Mark.  So <#cb1-15>he rode to a green hillock and there set his
banner, and the [White <#cb1-16>Horse]{.index}White Horse ran rippling
in the wind. <#cb1-17> <#cb1-18>| Out of doubt, out of dark to the
day's rising <#cb1-19>| I came singing in the sun, sword unsheathing.
<#cb1-20>| To hope's end I rode and to heart's breaking: <#cb1-21>|
Now for wrath, now for ruin and a red nightfall! <#cb1-22>
<#cb1-23>These staves he spoke, yet he laughed as he said them. For
once more <#cb1-24>lust of battle was on him; and he was still
unscathed, and he was <#cb1-25>young, and he was king: the lord of a
fell people. And lo! even as he <#cb1-26>laughed at despair he looked
out again on the [Ships, <#cb1-27>Black]{.pandoc}black ships, and he
lifted up his sword to defy them. <#cb1-28> <#cb1-29>``` {=context}
<#cb1-30>\completeindex <#cb1-31>``` <#cb1-32>

I build it using a make file, GNUmakefile:

 <#cb2-1>all: context-index.ctx.pdf <#cb2-2> <#cb2-3>%.ctx.pdf : %.md
<#cb2-4>	pandoc -w context -o $@ --lua-filter=context-index.lua $<

The pandoc command to build it loads a Lua Filter
<https://pandoc.org/lua-filters.html>, context-index.lua:

 <#cb3-1>local function has_value (tab, val) <#cb3-2>   for index,
value in ipairs(tab) do <#cb3-3>      if value == val then <#cb3-4>
     return true <#cb3-5>      end <#cb3-6>   end <#cb3-7>   return
false <#cb3-8>end <#cb3-9> <#cb3-10>function Span(el) <#cb3-11>   if
el.classes and #el.classes > 0 then <#cb3-12>      if
has_value(el.classes, 'index') then <#cb3-13>         if FORMAT ==
"context" then <#cb3-14>            table.insert(el.content, 1,
pandoc.RawInline('context', '\\index{')) <#cb3-15>
table.insert(el.content, pandoc.RawInline('context', '}')) <#cb3-16>
      end <#cb3-17>      end <#cb3-18>   end <#cb3-19>   return
el.content <#cb3-20>end -- Span

Here's the pandoc command to build the PDF:

pandoc -w context -o context-index.ctx.pdf
--lua-filter=context-index.lua context-index.md

The PDF file it produces, context-index.ctx.pdf, is attached to this
e-mail. The makefile, the markdown source, and the lua filter are also in a
zip file attached to this message.

I'm not sure how to do this using LaTeX output or HTML output. Does anybody
else have ideas for those output formats?

On Tue, Aug 11, 2020 at 3:45 PM Marty Heyman <marty.heyman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> We would like to use Pandoc Markdown as Source Language for a few complex
> and large technical manuals (100s of pages). Indexing key germs is
> seriously important. I searched these discussions and didn't see an obvious
> path (nor from the manual). Any success or potentially useful avenues
> you've tried?
>
> --
> 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/6109678b-fa72-4fab-b176-abe5dcb50039o%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/6109678b-fa72-4fab-b176-abe5dcb50039o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
T. Kurt Bond, tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, https://tkurtbond.github.io

-- 
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/CAN1EhV_4p5mS5ejS%2B-BAUYDNfxEsUMRuaibV%2B1qyh06Tnghj_A%40mail.gmail.com.

[-- Attachment #1.2: Type: text/html, Size: 29662 bytes --]

[-- Attachment #2: context-index.zip --]
[-- Type: application/zip, Size: 1468 bytes --]

[-- Attachment #3: context-index.ctx.pdf --]
[-- Type: application/pdf, Size: 18053 bytes --]

  parent reply	other threads:[~2020-08-11 23:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11 19:45 Marty Heyman
     [not found] ` <6109678b-fa72-4fab-b176-abe5dcb50039o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-08-11 23:26   ` T. Kurt Bond [this message]
     [not found]     ` <CAN1EhV_4p5mS5ejS+-BAUYDNfxEsUMRuaibV+1qyh06Tnghj_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-08-12  0:43       ` Marty Heyman
2020-08-13 17:32       ` Håkon Wium Lie
     [not found]         ` <24373.31048.70150.87943-4mDQ13Tdud8Jw5R7aSpS0dP8p4LwMBBS@public.gmane.org>
2020-08-13 18:46           ` Marty Heyman
2020-08-14  9:10       ` jcr
2020-08-13 15:01   ` Dmitriy Krasilnikov
     [not found]     ` <CALZUCcDqRwBXYiTLdC6EXgZV+TQzn8qcF+W_HvxSPEULHFojAA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-08-13 18:45       ` Marty Heyman

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=CAN1EhV_4p5mS5ejS+-BAUYDNfxEsUMRuaibV+1qyh06Tnghj_A@mail.gmail.com \
    --to=tkurtbond-re5jqeeqqe8avxtiumwx3w@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).