Thank you SO MUCH. That was fast and this looks very complete!

On Aug 11, 2020, at 7:26 PM, T. Kurt Bond <tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

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:

---
title: Test out Indexes from Spans in Markdown
linkcolor: green
linkcontrastcolor: red
---

# Section One

[Éomer]{.index}[Éomer] let blow the horns to rally all men to his
banner that could come thither; for he thought to make a great
shield-wall at the last, and stand, and fight there on foot till all
fell, and do deeds of song on the fields of
[Pelennor]{.index}Pelennor, though no man should be left in the West
to remember the last [Mark, King of the]{.index}King of the Mark.  So
he rode to a green hillock and there set his banner, and the [White
Horse]{.index}White Horse ran rippling in the wind.

| Out of doubt, out of dark to the day's rising
| I came singing in the sun, sword unsheathing.
| To hope's end I rode and to heart's breaking:
| Now for wrath, now for ruin and a red nightfall!

These staves he spoke, yet he laughed as he said them. For once more
lust of battle was on him; and he was still unscathed, and he was
young, and he was king: the lord of a fell people. And lo! even as he
laughed at despair he looked out again on the [Ships,
Black]{.pandoc}black ships, and he lifted up his sword to defy them.

``` {=context}
\completeindex
```

I build it using a make file, GNUmakefile:

all: context-index.ctx.pdf

%.ctx.pdf : %.md
	pandoc -w context -o $@ --lua-filter=context-index.lua $<

The pandoc command to build it loads a Lua Filtercontext-index.lua:

local function has_value (tab, val)
   for index, value in ipairs(tab) do
      if value == val then
         return true
      end
   end
   return false
end

function Span(el)
   if el.classes and #el.classes > 0 then
      if has_value(el.classes, 'index') then
         if FORMAT == "context" then
            table.insert(el.content, 1, pandoc.RawInline('context', '\\index{'))
            table.insert(el.content, pandoc.RawInline('context', '}'))
         end
      end
   end
   return el.content
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-/JYPxA39Uh5TLH3MbocFFw@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.


--

--
You received this message because you are subscribed to a topic in the Google Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pandoc-discuss/W2SB9OwC8nI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.
<context-index.zip><context-index.ctx.pdf>

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3AAEA7EE-DE35-42DB-82A7-3AE45EC88CD2%40gmail.com.