public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* HTML/PDF Indexes
@ 2020-08-11 19:45 Marty Heyman
       [not found] ` <6109678b-fa72-4fab-b176-abe5dcb50039o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Marty Heyman @ 2020-08-11 19:45 UTC (permalink / raw)
  To: pandoc-discuss


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

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.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: HTML/PDF Indexes
       [not found] ` <6109678b-fa72-4fab-b176-abe5dcb50039o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-08-11 23:26   ` T. Kurt Bond
       [not found]     ` <CAN1EhV_4p5mS5ejS+-BAUYDNfxEsUMRuaibV+1qyh06Tnghj_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2020-08-13 15:01   ` Dmitriy Krasilnikov
  1 sibling, 1 reply; 8+ messages in thread
From: T. Kurt Bond @ 2020-08-11 23:26 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- 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 --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: HTML/PDF Indexes
       [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
  2020-08-14  9:10       ` jcr
  2 siblings, 0 replies; 8+ messages in thread
From: Marty Heyman @ 2020-08-12  0:43 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 6426 bytes --]

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:

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

 <x-msg://8/#cb2-1>all: context-index.ctx.pdf
 <x-msg://8/#cb2-2>
 <x-msg://8/#cb2-3>%.ctx.pdf : %.md
 <x-msg://8/#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:

 <x-msg://8/#cb3-1>local function has_value (tab, val)
 <x-msg://8/#cb3-2>   for index, value in ipairs(tab) do
 <x-msg://8/#cb3-3>      if value == val then
 <x-msg://8/#cb3-4>         return true
 <x-msg://8/#cb3-5>      end
 <x-msg://8/#cb3-6>   end
 <x-msg://8/#cb3-7>   return false
 <x-msg://8/#cb3-8>end
 <x-msg://8/#cb3-9>
 <x-msg://8/#cb3-10>function Span(el)
 <x-msg://8/#cb3-11>   if el.classes and #el.classes > 0 then
 <x-msg://8/#cb3-12>      if has_value(el.classes, 'index') then
 <x-msg://8/#cb3-13>         if FORMAT == "context" then
 <x-msg://8/#cb3-14>            table.insert(el.content, 1, pandoc.RawInline('context', '\\index{'))
 <x-msg://8/#cb3-15>            table.insert(el.content, pandoc.RawInline('context', '}'))
 <x-msg://8/#cb3-16>         end
 <x-msg://8/#cb3-17>      end
 <x-msg://8/#cb3-18>   end
 <x-msg://8/#cb3-19>   return el.content
 <x-msg://8/#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 <mailto: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 <mailto: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 <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 <mailto:tkurtbond-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, https://tkurtbond.github.io <https://tkurtbond.github.io/>

-- 
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 <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 <mailto:pandoc-discuss+unsubscribe@googlegroups.com>.
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 <https://groups.google.com/d/msgid/pandoc-discuss/CAN1EhV_4p5mS5ejS%2B-BAUYDNfxEsUMRuaibV%2B1qyh06Tnghj_A%40mail.gmail.com?utm_medium=email&utm_source=footer>.
<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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.

[-- Attachment #2: Type: text/html, Size: 33303 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: HTML/PDF Indexes
       [not found] ` <6109678b-fa72-4fab-b176-abe5dcb50039o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-08-11 23:26   ` T. Kurt Bond
@ 2020-08-13 15:01   ` Dmitriy Krasilnikov
       [not found]     ` <CALZUCcDqRwBXYiTLdC6EXgZV+TQzn8qcF+W_HvxSPEULHFojAA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Dmitriy Krasilnikov @ 2020-08-13 15:01 UTC (permalink / raw)
  To: Finn Mathisen

What output format you're planning to use?

вт, 11 авг. 2020 г. в 22:45, Marty Heyman <marty.heyman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> 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.

-- 
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/CALZUCcDqRwBXYiTLdC6EXgZV%2BTQzn8qcF%2BW_HvxSPEULHFojAA%40mail.gmail.com.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: HTML/PDF Indexes
       [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-14  9:10       ` jcr
  2 siblings, 1 reply; 8+ messages in thread
From: Håkon Wium Lie @ 2020-08-13 17:32 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

T. Kurt Bond wrote:

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

I'm generating indexes and ToCs in HTML with the help of CSS and
Javascript. Here's a sample document:

  https://css4.pub/2020/musick/musick.html
  https://css4.pub/2020/musick/musick.pdf
  https://css4.pub/

The solution depends on Prince, a commercial product with a free
personal license. (I on the board of the company behind Prince.)

In the example, JavaScript keeps track of page numbers and is able to
combine page ranges so that the index doesn't show «3, 4, 5», but
rather «3-5». This example requires a version of Prince released in
May 2020, or newer.

  https://www.princexml.com/latest/

Cheers,

Håkon Wium Lie     haakon-EO96REbE7qRuMpJDpNschA@public.gmane.org    www.wiumlie.no/en 

-- 
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/24373.31048.70150.87943%40gargle.gargle.HOWL.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: HTML/PDF Indexes
       [not found]     ` <CALZUCcDqRwBXYiTLdC6EXgZV+TQzn8qcF+W_HvxSPEULHFojAA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2020-08-13 18:45       ` Marty Heyman
  0 siblings, 0 replies; 8+ messages in thread
From: Marty Heyman @ 2020-08-13 18:45 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

We’re primarily interested in PDF and HTML. Thanks.

On Aug 13, 2020, at 11:01 AM, Dmitriy Krasilnikov <dmitriy.krasilnikov@gmail.com> wrote:

What output format you're planning to use?

вт, 11 авг. 2020 г. в 22:45, Marty Heyman <marty.heyman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> 
> 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.

-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CALZUCcDqRwBXYiTLdC6EXgZV%2BTQzn8qcF%2BW_HvxSPEULHFojAA%40mail.gmail.com.

-- 
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/53E0BD4F-B46B-416B-9625-A7C615D309F1%40gmail.com.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: HTML/PDF Indexes
       [not found]         ` <24373.31048.70150.87943-4mDQ13Tdud8Jw5R7aSpS0dP8p4LwMBBS@public.gmane.org>
@ 2020-08-13 18:46           ` Marty Heyman
  0 siblings, 0 replies; 8+ messages in thread
From: Marty Heyman @ 2020-08-13 18:46 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Thanks. I’ll take a look at that.

On Aug 13, 2020, at 1:32 PM, Håkon Wium Lie <haakon-EO96REbE7qRuMpJDpNschA@public.gmane.org> wrote:

T. Kurt Bond wrote:

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

I'm generating indexes and ToCs in HTML with the help of CSS and
Javascript. Here's a sample document:

 https://css4.pub/2020/musick/musick.html
 https://css4.pub/2020/musick/musick.pdf
 https://css4.pub/

The solution depends on Prince, a commercial product with a free
personal license. (I on the board of the company behind Prince.)

In the example, JavaScript keeps track of page numbers and is able to
combine page ranges so that the index doesn't show «3, 4, 5», but
rather «3-5». This example requires a version of Prince released in
May 2020, or newer.

 https://www.princexml.com/latest/

Cheers,

Håkon Wium Lie     haakon-EO96REbE7qRuMpJDpNschA@public.gmane.org    www.wiumlie.no/en 

-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/24373.31048.70150.87943%40gargle.gargle.HOWL.

-- 
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/A27A3FC7-4987-4576-A2B2-24F410C40A4E%40gmail.com.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: HTML/PDF Indexes
       [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
@ 2020-08-14  9:10       ` jcr
  2 siblings, 0 replies; 8+ messages in thread
From: jcr @ 2020-08-14  9:10 UTC (permalink / raw)
  To: pandoc-discuss


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

I think the code for ConTeXt would work for LaTeX. However, I have a 
somewhat more complicated filter that allows me to avoid repeating things 
that I want indexed. I can just write [Pellenor]{.index} and get 
"\index{Pellenor}Pellenor" in LaTeX. If the words have to appear in a 
different order, I have an "l" attribute that gives the number of "last 
names" (i.e., the number of words that have to be moved to the beginning). 
So [John Doe]{.index l=1} produces "\index{Doe, John}John Doe" in LaTeX, 
and [Juan Rodríguez García]{.index l=2} produces "\index{Rodríguez García, 
Juan}Juan Rodríguez García". An "s" (suffix) attribute will add its value 
to the end of the "first name": Ambrose{.index s="of Milan"} produces 
"\index{Ambrose of Milan}Ambrose". As it stands, the filter doesn't have a 
good way to produce "\index{Doe, John}Doe". Those are rare enough in my 
document that I just handle them in a post-processing phase that I needed 
for other reasons: it would check for "Doe" in index items and replace it 
with "Doe, John". A solution could be to add a "first name" attribute to 
support a syntax like [Doe]{.index f="John"}. Alternatively, modify the 
handling of the s attribute to not add a space before it if the value 
begins with a comma. They you could write [Doe]{.index s=", John"}.

This is clipped out of a larger filter. It doesn't check the format because 
the filter is only used when the format is LaTeX.
function latexForIndex(el)
  local c = el.content
  local s = pandoc.utils.stringify(el)
  local first, last
  -- If an l attribute gives the number of last names, then split s.
  if el.attributes.l then
    local words = {}
    for w in s:gmatch("%S+") do table.insert(words, w) end
    first = table.concat(words, ' ', 1, #words-el.attributes.l)
    last = table.concat(words, ' ', #words-el.attributes.l+1)
  else
    first = s
    last = nil
  end
  -- Append suffix if defined in s attribute.
  if el.attributes.s then
    first = first .. ' ' .. el.attributes.s
  end
  local latexStr
  if last then
    latexStr = '\\index{' .. last .. ', ' .. first .. '}'
  else
    latexStr = '\\index{' .. first .. '}'
  end
  -- Insert index entry before content so it lists the page where the 
content starts.
  table.insert(c, 1, pandoc.RawInline('latex', latexStr))
  return c
end

function Span (el)
  if el.classes[1] == "index" then
    return latexForIndex(el)
  end
end




On Wednesday, August 12, 2020 at 1:26:55 AM UTC+2, T. Kurt Bond 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 Markdownlinkcolor: greenlinkcontrastcolor: red---# Section One[Éomer]{.index}[Éomer] let blow the horns to rally all men to hisbanner that could come thither; for he thought to make a greatshield-wall at the last, and stand, and fight there on foot till allfell, and do deeds of song on the fields of[Pelennor]{.index}Pelennor, though no man should be left in the Westto remember the last [Mark, King of the]{.index}King of the Mark.  Sohe rode to a green hillock and there set his banner, and the [WhiteHorse]{.index}White Horse ran rippling in the wind.
>
> … 

> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 
> <javascript:>> 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-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>.
>> 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, tkur...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>, 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/0b617fb9-b4b1-4baa-ab01-fffecb2a05d5o%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-08-14  9:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 19:45 HTML/PDF Indexes Marty Heyman
     [not found] ` <6109678b-fa72-4fab-b176-abe5dcb50039o-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-08-11 23:26   ` T. Kurt Bond
     [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

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).