public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: "Denis Bitouzé"
	<denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org>,
	pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: How to indent a block when exporting to reStructuredText
Date: Tue, 01 Dec 2020 10:55:48 -0800	[thread overview]
Message-ID: <m2czztxsnf.fsf@MacBook-Pro.hsd1.ca.comcast.net> (raw)
In-Reply-To: <877dq2iq4d.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>

Denis Bitouzé <denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org> writes:

> Would somebody kindly give me a starting point? I carefully read the
> pandoc filters docs and had a look at many examples out there but I've
> absolutely no idea how to:
>
> - find the starting Para,
> - collect blocks til I find the ending Para,
> - put these collected blocks (when I'll succeed to collect them) in
>   a Div with class "note".

Something like this (untested and surely buggy, you'll have to debug and fix):

function isNoteStart(block)
  return block.t == 'Para' and block.c == ??? <- fill in
end

function isNoteEnd(block)
  return block.t == 'Para' and block.c == ??? <- fill in
end

function Pandoc(el)

  local inNote = false
  local contents = {}
  local note = {}
  for _,block in el.blocks:
    if isNoteEnd(block) then
      inNote = false
      contents:insert(pandoc.Div(note, pandoc.Attr("",{"note"})))
    elseif isNoteStart(block) then
      inNote = true
      note = {}
    elseif inNote then
      note:insert(block)      
    else
      contents:insert(block)
    end
    el.blocks = contents
    return Pandoc(el)

end 

 

-- 
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/m2czztxsnf.fsf%40MacBook-Pro.hsd1.ca.comcast.net.


  parent reply	other threads:[~2020-12-01 18:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-29 21:54 Denis Bitouzé
     [not found] ` <875z5n7rsg.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-11-30  0:37   ` John MacFarlane
     [not found]     ` <m2o8jfof2r.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-11-30  8:38       ` Denis Bitouzé
     [not found]         ` <87eekbjl2a.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-11-30 19:47           ` Denis Bitouzé
     [not found]             ` <877dq2iq4d.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-01 18:55               ` John MacFarlane [this message]
     [not found]                 ` <m2czztxsnf.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-12-02 10:28                   ` Denis Bitouzé
     [not found]                     ` <871rg8fqo3.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-02 15:16                       ` EBkysko
     [not found]                         ` <0d1533ca-8cf8-4a50-8318-a770eaaf2d31n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-02 16:23                           ` EBkysko
2020-12-02 16:47                           ` Denis Bitouzé
     [not found]                             ` <87360oduiq.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-02 18:15                               ` John MacFarlane
     [not found]                                 ` <m2mtywoz0f.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-12-03  9:16                                   ` Denis Bitouzé
2020-12-02 19:15                               ` EBkysko
     [not found]                                 ` <c210b412-3d47-45d5-a7e7-c55b1086d587n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-03 10:11                                   ` Denis Bitouzé
     [not found]                                     ` <87k0tzci6s.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-03 15:49                                       ` EBkysko
     [not found]                                         ` <db1f8570-4afc-45ee-ac1f-0ae4435cf833n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-03 17:34                                           ` [SOCIAL]Re: " Denis Bitouzé
     [not found]                                             ` <874kl2dca6.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-03 20:17                                               ` BPJ
     [not found]                                                 ` <CADAJKhANzMvwhURnVUh49xZzRQFKUnpyCyeZtp+nQ7Nc82ZmVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-12-03 21:03                                                   ` EBkysko
     [not found]                                                     ` <7b398756-0b85-490b-b05e-8fd4fcaaecd5n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-03 22:00                                                       ` EBkysko
     [not found]                                                         ` <6221eae9-b70a-4f53-b512-7655c2ac6858n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-04  9:28                                                           ` BPJ
     [not found]                                                             ` <CADAJKhDptqz5OCCDNxXL6p6qDBk0kKkpr-y+8+ikZmspxC0ULA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-12-04  9:37                                                               ` BPJ
     [not found]                                                                 ` <CADAJKhAHahcvktOyqyY+EB87DJSqo3aaVT7eeBtpDvCcfka5Vg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-12-04 20:51                                                                   ` [SOCIAL]Re: " Denis Bitouzé
     [not found]                                                                     ` <878sadxpkk.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-05 22:48                                                                       ` BPJ
2020-12-04 14:50                                                               ` EBkysko
2020-12-04  8:43                                                       ` [SOCIAL]Re: " Denis Bitouzé
2020-12-03 21:06                                                   ` BPJ
     [not found]                                                     ` <CADAJKhAM88Cm+-G9oVGM0eJUpPpUUpCkPVQrabNSqKXJOY7r-w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-12-04  8:42                                                       ` [SOCIAL]Re: " Denis Bitouzé
2020-12-03 20:20                                               ` EBkysko
     [not found]                                                 ` <0a5a4d99-e862-43c4-8664-4b1b60f36e00n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-03 22:44                                                   ` EBkysko
     [not found]                                                     ` <ef8524a3-956b-4e42-adeb-761197c42d08n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-04  8:46                                                       ` [SOCIAL]Re: " Denis Bitouzé
     [not found]                                                         ` <87eek6arh1.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-04 14:31                                                           ` EBkysko
     [not found]                                                             ` <8c84d892-5412-4fd4-9718-70866142d19dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-12-04 20:28                                                               ` [SOCIAL]Re: " Denis Bitouzé
2020-12-04  8:25                                                   ` Denis Bitouzé

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=m2czztxsnf.fsf@MacBook-Pro.hsd1.ca.comcast.net \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=denis.bitouze-PToOLB6qFnLddoiwg0DPyg@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).