public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Ken Dow <thekenshow-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: 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 13:53:15 -0800 (PST)	[thread overview]
Message-ID: <b411caba-b372-4f99-aca5-36c5b614c91c@googlegroups.com> (raw)
In-Reply-To: <yh480kmunirmm8.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>


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

Hi John,

Thanks for the quick reply. Now that you've pointed it out, I can see that:

Div Attr 
<https://hackage.haskell.org/package/pandoc-types-1.17.5.4/docs/Text-Pandoc-Definition.html#t:Attr> 
[Block 
<https://hackage.haskell.org/package/pandoc-types-1.17.5.4/docs/Text-Pandoc-Definition.html#t:Block>
]

Means that a div can have attributes, but

Table [Inline 
<https://hackage.haskell.org/package/pandoc-types-1.17.5.4/docs/Text-Pandoc-Definition.html#t:Inline>
] [Alignment 
<https://hackage.haskell.org/package/pandoc-types-1.17.5.4/docs/Text-Pandoc-Definition.html#t:Alignment>
] [Double 
<https://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#t:Double>
] [TableCell 
<https://hackage.haskell.org/package/pandoc-types-1.17.5.4/docs/Text-Pandoc-Definition.html#t:TableCell>
] [[TableCell 
<https://hackage.haskell.org/package/pandoc-types-1.17.5.4/docs/Text-Pandoc-Definition.html#t:TableCell>
]]

A table does not have that. 

I did look at this page, but my next task is to learn how to read this 
documentation format...!

Looks like I'll need to post-process the HTML output with a separate 
script. 

On Wednesday, 30 January 2019 14:06:54 UTC-5, John MacFarlane wrote:
>
>
> 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 <theke...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
> <javascript:>. 
> > 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. 
>

-- 
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/b411caba-b372-4f99-aca5-36c5b614c91c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

  parent reply	other threads:[~2019-01-30 21:53 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
     [not found]     ` <yh480kmunirmm8.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-01-30 21:53       ` Ken Dow [this message]
     [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=b411caba-b372-4f99-aca5-36c5b614c91c@googlegroups.com \
    --to=thekenshow-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).