public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: A A <amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Assigning identifiers to definition items
Date: Sun, 12 Nov 2023 17:35:14 +0100	[thread overview]
Message-ID: <CAMwawgNn46NLk5=FcWsL7gSVPkrmb7y6s0qBAVzWQ0dWPu09kA@mail.gmail.com> (raw)
In-Reply-To: <CAEe_xxjOecwEVJSiO+BQDVHqc1zaDxHZuuzDSTDjZEmQna4xOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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

Thanks a lot, will be playing around with it.

On Sun, 12 Nov 2023 at 11:50, 'William Lupton' via pandoc-discuss <
pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote:

> BTW, sorry for failing to read your original message properly!
>
> Right. The auto-identifiers.lua filter is not yet in pandoc-ext, but I'll
> look into adding it. Note that it doesn't remove the need to add an
> identifier (it just derives the identifier from the content).
>
> I think that auto-defined identifiers are only appropriate for terms, not
> for definitions, but you could use a filter such as the one shown below to
> auto-add identifiers to definitions if their terms have identifiers. Using
> this input (based on Bastien's):
>
> [Term 1]{#t1}
>
> : Definition 1
>
> : Definition 2
>
> Term 2
>
> : Definition 1
>
> Here Term 1 has [this meaning](#t1-def2).
>
> gives this HTML:
>
> <dl>
> <dt><span id="t1">Term 1</span></dt>
> <dd>
> <p><span id="t1-def1"></span>Definition 1</p>
> </dd>
> <dd>
> <p><span id="t1-def2"></span>Definition 2</p>
> </dd>
> <dt>Term 2</dt>
> <dd>
> <p>Definition 1</p>
> </dd>
> </dl>
> <p>Here Term 1 has <a href="#t1-def2">this meaning</a>.</p>
>
> The filter:
>
> function DefinitionList(list)
>     local changed = false
>     for _, item in ipairs(list.content) do
>         local term = item[1]
>         local defs = item[2]
>         if (#term > 0 and term[1].tag == 'Span' and
>             #term[1].attr.identifier > 0) then
>             local term_id = term[1].attr.identifier
>             for i, def in ipairs(defs) do
>                 if #def > 0 then
>                     local def_id = string.format('%s-def%s', term_id, i)
>                     def[1].content:insert(
>                         1, pandoc.Span({}, pandoc.Attr(def_id)))
>                     changed = true
>                 end
>             end
>         end
>     end
>     if changed then
>         return list
>     end
> end
>
> On Sun, 12 Nov 2023 at 10:27, A A <amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> Hey William,
>>
>> I'd be interested in getting a hold of that filter you mentioned, I can
>> see how it would greatly reduce the amount of bookkeeping required here.
>>
>> I did check in https://github.com/pandoc/lua-filters as well as the link
>> you provided but couldn't find it. I could also technically make my own
>> filter or post-process the resulting document using JS but if you have that
>> filter on hand that would be very helpful.
>>
>> Regards,
>>
>> Amine
>>
>> On Sun, 12 Nov 2023 at 11:13, A A <amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>
>>> Nevermind sorry. Please disregard my last reply. The anchor link works
>>> fine.
>>>
>>> On Sun, 12 Nov 2023 at 11:05, A A <amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>>
>>>> Ok, thanks for that, but when I try to convert something like the
>>>> following:
>>>>
>>>> [USA]{#usa}
>>>> : United States of America
>>>>
>>>> The resulting HTML looks like this:
>>>>
>>>> <dt><span id="usa">USA</span></dt>
>>>> <dd>
>>>> United States of America
>>>> </dd>
>>>>
>>>> The hash symbol gets dropped which basically makes that span useless as
>>>> the target of an anchor link. I think I’m probably still doing something
>>>> wrong but I’m not sure what.
>>>>
>>>> On Sat, 11 Nov 2023 at 23:57, Bastien DUMONT bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org
>>>> <http://mailto:bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org> wrote:
>>>>
>>>> Same thing, but on the definition:
>>>>>
>>>>> Term 1
>>>>>
>>>>> : Definition 1
>>>>>
>>>>> : [Definition 2]{#t1-def2}
>>>>>
>>>>> Term 2
>>>>>
>>>>> : Definition 1
>>>>>
>>>>> Here Term 1 has [this meaning](#t1-def2).
>>>>>
>>>>> You will not get the id on the <dd> element directly, but on a <span>
>>>>> inside <dd>.
>>>>>
>>>>> Le Saturday 11 November 2023 à 10:57:48PM, A A a écrit :
>>>>> > Thanks William, this will certainly come in handy, however I was
>>>>> asking about
>>>>> > linking to specific *definitions*, not *terms*, i.e. in the case
>>>>> where I have
>>>>> > multiple definitions for a single term, I'd like to be able to link
>>>>> to only one
>>>>> > of them from another definition or from the main body of my
>>>>> document....
>>>>> >
>>>>> > On Mon, 6 Nov 2023 at 16:02, 'William Lupton' via pandoc-discuss <[1]
>>>>> > pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote:
>>>>> >
>>>>> >     You can use [2]bracketed spans to do this manually, as in:
>>>>> >
>>>>> >     [Term 1]{#term-1}
>>>>> >     ...
>>>>> >     Reference to [Term 1](#term-1).
>>>>> >
>>>>> >     We use an auto-identifiers.lua filter that I could probably add
>>>>> to [3]
>>>>> >     pandoc-ext. This will auto-derive the identifiers from the span
>>>>> content.
>>>>> >     This allows you to write this:
>>>>> >
>>>>> >     [Term 1]{}
>>>>> >     ...
>>>>> >     Reference to [Term 1]().
>>>>> >
>>>>> >     or this (the t: is used as a prefix):
>>>>> >
>>>>> >     [Term 1]{#t:}
>>>>> >     ...
>>>>> >     Reference to [Term 1](#t:).
>>>>> >
>>>>> >     The latter example generates this HTML.
>>>>> >
>>>>> >     <dt><span id="t:term-1">Term 1</span></dt>
>>>>> >     ...
>>>>> >     <p>Reference to <a href="#t:term-1">Term 1</a>.</p>
>>>>> >
>>>>> >     On Mon, 6 Nov 2023 at 12:14, A A <[4]amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>> wrote:
>>>>> >
>>>>> >
>>>>> >         Pandoc will convert the following markdown:
>>>>> >
>>>>> >         Term 1
>>>>> >
>>>>> >         : Definition 1
>>>>> >
>>>>> >         : Definition 2
>>>>> >
>>>>> >         Term 2
>>>>> >
>>>>> >         : Definition 1
>>>>> >
>>>>> >         To the following HTML:
>>>>> >
>>>>> >         <dl>
>>>>> >         <dt>Term 1</dt>
>>>>> >         <dd>
>>>>> >         <p>Definition 1</p>
>>>>> >         </dd>
>>>>> >         <dd>
>>>>> >         <p>Definition 2</p>
>>>>> >         </dd>
>>>>> >         <dt>Term 2</dt>
>>>>> >         <dd>
>>>>> >         <p>Definition 1</p>
>>>>> >         </dd>
>>>>> >         </dl>
>>>>> >
>>>>> >         How easy/straightforward is it to assign identifiers to
>>>>> specific
>>>>> >         definition items in markdown? For example such that the
>>>>> resulting HTML
>>>>> >         looks like the following:
>>>>> >
>>>>> >         <dl>
>>>>> >         <dt>Term 1</dt>
>>>>> >         <dd id="def-1-term-1">
>>>>> >         <p>Definition 1</p>
>>>>> >         </dd>
>>>>> >         <dd>
>>>>> >         <p>Definition 2</p>
>>>>> >         </dd>
>>>>> >         <dt>Term 2</dt>
>>>>> >         <dd>
>>>>> >         <p>Definition 1</p>
>>>>> >         </dd>
>>>>> >         </dl>
>>>>> >
>>>>> >         --
>>>>> >         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 [5]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>> >         To view this discussion on the web visit [6]
>>>>> https://groups.google.com/d
>>>>> >         /msgid/pandoc-discuss/
>>>>> >         CAMwawgNTwDo55QU5dZsgeXQpG9jAr1_RevLPdshEjFgqyF%3DgLQ%
>>>>> 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 [7]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>> >     To view this discussion on the web visit [8]
>>>>> https://groups.google.com/d/
>>>>> >     msgid/pandoc-discuss/
>>>>> >     CAEe_xxiyw7-04ghifFmDDv3XH0rBVL-WszRX44%3D27Q_OP%2BXSnA%
>>>>> 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 [9]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>> > To view this discussion on the web visit [10]
>>>>> https://groups.google.com/d/msgid/
>>>>> > pandoc-discuss/
>>>>> > CAMwawgMn0hHWHAk7wAk0GYFrjgh%3Do5R3yhZjB5kSpcNxWhvb%3DA%
>>>>> 40mail.gmail.com.
>>>>> >
>>>>> > References:
>>>>> >
>>>>> > [1] mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>> > [2] https://pandoc.org/MANUAL.html#extension-bracketed_spans
>>>>> > [3] https://github.com/pandoc-ext
>>>>> > [4] mailto:amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
>>>>> > [5] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>> > [6]
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgNTwDo55QU5dZsgeXQpG9jAr1_RevLPdshEjFgqyF%3DgLQ%40mail.gmail.com?utm_medium=email&utm_source=footer
>>>>> > [7] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>> > [8]
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxiyw7-04ghifFmDDv3XH0rBVL-WszRX44%3D27Q_OP%2BXSnA%40mail.gmail.com?utm_medium=email&utm_source=footer
>>>>> > [9] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>> > [10]
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgMn0hHWHAk7wAk0GYFrjgh%3Do5R3yhZjB5kSpcNxWhvb%3DA%40mail.gmail.com?utm_medium=email&utm_source=footer
>>>>>
>>>>> --
>>>>> 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/ZVAG4DKHakT2qzn6%40localhost
>>>>> .
>>>>
>>>>
>>>>> --
>> 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/CAMwawgMH_vudUviXZa8odQ-jyn5Snk3YYGzx4K9to2RBQ_dpOA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/pandoc-discuss/CAMwawgMH_vudUviXZa8odQ-jyn5Snk3YYGzx4K9to2RBQ_dpOA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/CAEe_xxjOecwEVJSiO%2BBQDVHqc1zaDxHZuuzDSTDjZEmQna4xOg%40mail.gmail.com
> <https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxjOecwEVJSiO%2BBQDVHqc1zaDxHZuuzDSTDjZEmQna4xOg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAMwawgNn46NLk5%3DFcWsL7gSVPkrmb7y6s0qBAVzWQ0dWPu09kA%40mail.gmail.com.

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

      parent reply	other threads:[~2023-11-12 16:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06 12:13 A A
     [not found] ` <CAMwawgNTwDo55QU5dZsgeXQpG9jAr1_RevLPdshEjFgqyF=gLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-06 15:02   ` 'William Lupton' via pandoc-discuss
     [not found]     ` <CAEe_xxiyw7-04ghifFmDDv3XH0rBVL-WszRX44=27Q_OP+XSnA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-11 21:57       ` A A
2023-11-11 22:57         ` Bastien DUMONT
2023-11-12 10:05           ` A A
     [not found]             ` <CAMwawgNoS75CPOstiM0Xv7xtBLK+Ff3Jp1o2udPnBQaHhH06VQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-12 10:13               ` A A
     [not found]                 ` <CAMwawgM3gEOSrSQFvE9k2_6+J=gmvW0MP6bo6dXVBvNNagufTQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-12 10:27                   ` A A
     [not found]                     ` <CAMwawgMH_vudUviXZa8odQ-jyn5Snk3YYGzx4K9to2RBQ_dpOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-12 10:50                       ` 'William Lupton' via pandoc-discuss
     [not found]                         ` <CAEe_xxjOecwEVJSiO+BQDVHqc1zaDxHZuuzDSTDjZEmQna4xOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-12 16:35                           ` A A [this message]

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='CAMwawgNn46NLk5=FcWsL7gSVPkrmb7y6s0qBAVzWQ0dWPu09kA@mail.gmail.com' \
    --to=amine.aboufirass-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).