From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32234 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JDTS Newsgroups: gmane.text.pandoc Subject: Re: Lua filter to fix incorrectly nested lists? Date: Sat, 25 Feb 2023 14:06:45 -0800 (PST) Message-ID: References: <163effbf-b672-4501-9171-8c4681034a96n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_474_47910910.1677362805683" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8949"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDEZRENAQYORB54M5KPQMGQEPQ754NY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Feb 25 23:06:51 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qv1-f61.google.com ([209.85.219.61]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pW2gs-0002BQ-87 for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 25 Feb 2023 23:06:50 +0100 Original-Received: by mail-qv1-f61.google.com with SMTP id ge13-20020a05621427cd00b005739f5f9d7csf1080797qvb.22 for ; Sat, 25 Feb 2023 14:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=u8be6mPT2KILVOP9gexRJH0dyTWdn73ZUQ2ubprh5XM=; b=ZKHxz7fMe1Cqi0lXlUEh2vaUNa0O7qeA9vIJy9mA04moifHXCWEYgbg8YAZbG0lrfo Aj1471jtlcK2+nE6GgcYtgrc9Mq7NUWHcXeul27y2f0MUWH0OO5ziquisn4MPelao0rf bU6222Nk5ZkNUs4RY7KYZ1gVjgXedYNohL7M0uLwKbhr0dam1SYUYzueBJELMQ1ylxcn qdmhdP+FqDTY9SmCVXzRjxRRr4ATwZgb4Q+GyHICuBlqEU5cC9URzu+7uVIJArALR1kS XAExuf/wNN5x2XTzyHJOKb+d33vLR1VjD1BJcf0MP1RKxE2X/4MNnFJfa3V8um6c9AWo aeUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=u8be6mPT2KILVOP9gexRJH0dyTWdn73ZUQ2ubprh5XM=; b=hnMPDwSZVZTzmu/gxcYKkqz7SnSQ3dINiE2wTMi7AcgJUW6z50h5FsL2BfbeU33/md a3nhTcow1d7xYJu4FcHoBKH8UXnRjySqefi/vTl+v1uwDp6602VAh04qWbN4HlziBpcz iXgIDhkze+vvMCsvFTcmmYS9580R03ii4dyJyhW52IPr3akKu6iZMx+E7ds5qZ9Wi9an K1QkHnsCIDWs6/9CzEhpT/K4TWEeXRPSxIJAY+zHpntL/2RhIOgldXvBc4fcXKvrLvsB hY6dWmxfTkJip5QnuAdtm+N1/MrXMFTSJGfJl6/xmIv84g2BEkm8vQAmUSiBRVps1Oxt klDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=u8be6mPT2KILVOP9gexRJH0dyTWdn73ZUQ2ubprh5XM=; b=49Qt9zI1gqsDEs0J9fLHcw5rMJ98CXTx4GzvqwZgkj0wNg6aBZ1ccZi1Sn/0GZH8ZG ESv6ioWPyK4PKdpPKLZs1VFNsd+Al+LPwCw2HaeDwLRvvbz8z8jMeN1/UXnPreIHC7qb fEyE15dFPpl8zG9O4W0WWa/KsBvl0EpDjDKyoOByg8RoLDpHjBgGuGJi2rKaXUqnGUDK j9L8ocBf5Wm0u/wif4x0bgaiRTRyCzuRSvTIVfk2WxI3Yszpz0IId4UcYO8G2UyXJBxO esw/uvCSiJyw2wRrNRHUFsomL+1icuDUzuBkQ7IUqkVEWizbOHTNY+SUzYXZbOjeyQXM tWsg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AO0yUKVTp5IXUuEg2YUUtvEENZm0LZ0SUu3yI1gMt93zM7OJYuEWDLXJ Qe/zi0TeuzCuI4kHsHvUvy0= X-Google-Smtp-Source: AK7set9txU4UbsxDcgYV00hG+L51cCCbzLkXTU/NGJWSf3AjdlRjMkpySM8VEIa8low2qKQ7+lSSAQ== X-Received: by 2002:a05:620a:12c3:b0:742:7398:b1da with SMTP id e3-20020a05620a12c300b007427398b1damr1575273qkl.11.1677362809126; Sat, 25 Feb 2023 14:06:49 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:620a:27cf:b0:71b:3402:f9a1 with SMTP id i15-20020a05620a27cf00b0071b3402f9a1ls1255882qkp.0.-pod-prod-gmail; Sat, 25 Feb 2023 14:06:46 -0800 (PST) X-Received: by 2002:a05:620a:4f:b0:742:74da:6e2c with SMTP id t15-20020a05620a004f00b0074274da6e2cmr1103671qkt.11.1677362806362; Sat, 25 Feb 2023 14:06:46 -0800 (PST) In-Reply-To: X-Original-Sender: jdtsmith-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:32234 Archived-At: ------=_Part_474_47910910.1677362805683 Content-Type: multipart/alternative; boundary="----=_Part_475_495592781.1677362805683" ------=_Part_475_495592781.1677362805683 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks. Any pointers to lua filters that do something similar? On Saturday, February 25, 2023 at 10:01:08=E2=80=AFAM UTC-5 Julien Dutant w= rote: > Looks feasible. Pandoc converts the first html to: > > [ BulletList > [ [ Plain > [ ... Inlines ] > ] > , [ BulletList > [ [ Plain > [ ... Inlines ] > ] > , [ Plain > [ ... Inlines ] > ] > ] > ] > , [ Plain > [ Inlines ] > ] > ] > ] > > I.e., the sublist is converted to its own list item. So the filter should= =20 > pick up list, check if any item within them consists of a lone sublist, a= nd=20 > if so, move it to the previous item. (And best, apply the filter=20 > recursively to that sublist itself.) > > On Saturday, February 25, 2023 at 2:26:04=E2=80=AFPM UTC JDTS wrote: > >> The Apple Notes app produces (via AppleScript) HTML for notes with neste= d=20 >> lists structured like: >> >>
    >> >>
  • Level 1 element 1
  • >> >>
      >> >>
    • Level 2 element 1
    • >> >>
    • Level 2 element 2
    • >> >>
    >> >>
  • Level 1 element 2
  • >> >>
>> >> As you can see, the sublist is incorrectly positioned. It should be=20 >> positioned *within* the
  • Level 1 element 1 item, ala: >> >>
      >> >>
    • Level 1 element 1 >> >>
        >> >>
      • Level 2 element 1
      • >> >>
      • Level 2 element 2
      • >> >>
      >> >>
    • >> >>
    • Level 1 element 2
    • >> >>
    >> >> Is there a straightforward way with Lua filters to fix this at the AST= =20 >> level, for arbitrary-depth sublist nesting? >> > --=20 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 e= mail 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/d030f117-9471-46dd-b730-d1ea81e3b040n%40googlegroups.com. ------=_Part_475_495592781.1677362805683 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks. =C2=A0Any pointers to lua filters that do something similar?
    <= br />
    On S= aturday, February 25, 2023 at 10:01:08=E2=80=AFAM UTC-5 Julien Dutant wrote= :
    Looks = feasible. Pandoc converts the first html to:

    [ Bul= letList
    =C2=A0 =C2=A0 [ [ Plain
    =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ = ... Inlines ]
    =C2=A0 =C2=A0 =C2=A0 ]
    =C2=A0 =C2=A0 , [ BulletList
    = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ [ Plain
    =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ ... Inlines ]
    =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 ]
    =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 , [ Plain
    =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ ... Inlines=C2=A0 ]
    = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ]
    =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ]
    =C2=A0 =C2=A0 =C2=A0 ]
    =C2=A0 =C2=A0 , [ Plain
    =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 [ Inlines ]
    =C2=A0 =C2=A0 =C2=A0 ]
    =C2=A0 = =C2=A0 ]
    ]

    I.e., the sublist is converted t= o its own list item. So the filter should pick up list, check if any item w= ithin them consists of a lone sublist, and if so, move it to the previous i= tem. (And best, apply the filter recursively to that sublist itself.)

    On Saturday, February 25, 2023 at 2:26:04=E2=80=AFPM UTC JDTS wro= te:
    The Apple Notes ap= p produces (via AppleScript) HTML for notes with nested lists structured li= ke:

    <ul>

    <li>Level 1 element 1</li>=

    <ul>

    <li>Level 2 element 1</li>=

    <li>Level 2 element 2</li>=

    </ul>

    <li>Level 1 element 2</li>=

    </ul>


    As you can see, the sublist is incorrectly positioned. =C2= =A0It should be positioned=C2=A0within=C2=A0the <li> Level 1 element 1 item, ala:

    <= div>

    <ul>

    <li>Level 1 element 1

    =C2=A0 =C2=A0 <ul>

    =C2=A0 =C2=A0 <li>Level 2 element 1</li>

    =C2=A0 =C2=A0 <li>Level 2 elem= ent 2</li>

    =C2=A0 =C2= =A0 </ul>

    </li><= br>

    <li>Level 1 elemen= t 2</li>

    </ul>


    Is there a straightforward way wi= th Lua filters to fix this at the AST level, for arbitrary-depth sublist ne= sting?

    --
    You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
    To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
    To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/d030f117-9471-46dd-b730-d1ea81e3b040n%40googlegroups.= com.
    ------=_Part_475_495592781.1677362805683-- ------=_Part_474_47910910.1677362805683--