public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: Ken Dow <thekenshow-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	pandoc-discuss
	<pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: How to Assign Class to HTML Table using a Filter
Date: Wed, 30 Jan 2019 11:06:39 -0800	[thread overview]
Message-ID: <yh480kmunirmm8.fsf@johnmacfarlane.net> (raw)
In-Reply-To: <553f3670-7cb1-402f-9a92-89f3774d17c0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


I don't know anything about PHP, but if you look at
the API docs for Text.Pandoc.Definition, you'll see
that the Table element doesn't have attributes
(including class).

Best you can do is insert it into a Div with
attributes.

Ken Dow <thekenshow-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi,
>
> I'd like to assign a class to every table in my HTML output. I've got PHP 
> filters <https://github.com/glassdimly/pandocfilters-php> working but can't 
> figure out how to manipulate the AST to do what I want.
>
> Building on an example PHP filter, I have:
>
> Pandoc_Filter::toJSONFilter(function ($type, $value, $format, $meta) {
>     if ('Str' == $type) {
>         // use mb_convert_case instead of ucwords so filter works with 
> unicode
>         return mb_convert_case($value, MB_CASE_LOWER, "UTF-8");
>     }
>     if ('Table' == $type) {
>         $attrs = array('classes' => 'table');
>         // return ???
>     }
> });
>
> The 'Str' manipulation works as expected, and any code I put into the 
> 'Table' section is executed, but I can't get started on how to proceed from 
> there. Any pointers would be very welcome!
>
> -- 
> 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/553f3670-7cb1-402f-9a92-89f3774d17c0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


  parent reply	other threads:[~2019-01-30 19:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 14:50 Ken Dow
     [not found] ` <553f3670-7cb1-402f-9a92-89f3774d17c0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-01-30 19:06   ` John MacFarlane [this message]
     [not found]     ` <yh480kmunirmm8.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-01-30 21:53       ` Ken Dow
     [not found]         ` <b411caba-b372-4f99-aca5-36c5b614c91c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-01-31  0:37           ` John MacFarlane
2019-01-31  1:22             ` Ken
2019-01-31  5:10               ` John MacFarlane
     [not found]                 ` <m2k1ilxvhf.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-01-31 12:52                   ` Ken Dow
     [not found]                     ` <fdd9a7c1-f66f-4116-bbff-2ee91842c4a8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-01-31 15:06                       ` John MacFarlane
     [not found]                         ` <m25zu4yigh.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-01-31 15:09                           ` John MacFarlane
     [not found]                             ` <m236p8yicd.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-01-31 16:49                               ` Ken Dow
     [not found]                                 ` <ae8d390d-1006-4c90-96ed-3f921f7a0dfa-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-01-31 19:08                                   ` John MacFarlane
     [not found]             ` <yh480kef8tr7aj.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-01-31  2:51               ` Ken Dow

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=yh480kmunirmm8.fsf@johnmacfarlane.net \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=thekenshow-Re5JQEeQqe8AvxtiuMwx3w@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).