public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Span and Div elements without any attributes (in filter output)
@ 2013-10-11 11:55 BP Jonsson
       [not found] ` <5257E71D.9070706-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: BP Jonsson @ 2013-10-11 11:55 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

In a filter it's sometimes desirable to replace an element in its
parent element's content list with e.g. the contents of the
element itself, modified in some way. In practice this is hard to
do as you'll have to walk the AST data structure and collect
elements along with a reference to their parent element's content
list, which is a bit more complicated than just collecting the
(child) elements themselves. One possible workaround is to
convert the element into a Div or Span element and set it's
contents to whatever one wants to replace the original element
with. It works in the sense that the Span or Div element will
just sit there and, well, contain the data, but in HTML output it
will show up as a `<span>...</span>` or `<div>...</div>`, even
though it probably doesn't have any meaningful purpose in the
HTML document; it just makes the HTML harder to read and harder
to render.

I've tried to write a filter which removes Span and Div elements
which don't have any attributes at all (id, class or other
attributes) -- or alternatively those which have a `disembowel=1`
attribute, although the absence of any attributes seems a better
criterion -- but for various

reasons this has proved hard within a reasonable level of
'parsing', especially since the AST data structure is rather
radically altered in the process -- paths to elements change
during the process in ways that make the processing hard. What if
pandoc itself replaced such attribute-less Span and Div elements
with their content at least when the `--normalize` option is set?
After all pandoc parses the whole document anyway!

/bpj

P.S.
:   I am aware that there may be situations when a `<span>` or `<div>`
     may be meaningful in an HTML document, most notably perhaps
     when a CSS rule targets them as children of some other
     element, but it seems to me that even then it is probably
     most user friendly to give them a class describing their
     function if they are really intended to fulfill a function in
     the document, so that it might be reasonable for pandoc to
     remove such attribute-less elements at least under
     `-- normalize`.


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-10-18 15:10 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-11 11:55 Span and Div elements without any attributes (in filter output) BP Jonsson
     [not found] ` <5257E71D.9070706-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-12 14:50   ` John MacFarlane
     [not found]     ` <20131012145025.GE95559-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2013-10-13 12:15       ` BP Jonsson
     [not found]         ` <CAFC_yuSeX5gHKAGD8zYfbGkFFjFYjZdH3QNTzjRuZpryAp-0CQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-13 21:29           ` John MacFarlane
     [not found]             ` <20131013212946.GA25277-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
2013-10-14  2:06               ` Peter Sefton
     [not found]                 ` <CAGQnt7U9F7HcQ70yp11CsnKPW6r2R_CLe3WB8OGBeO=GiC46yg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-14  2:12                   ` Peter Sefton
     [not found]                     ` <CAGQnt7UOMMtsAu7+Lhmb2NvGxSq+zcLUPq0yaBcs=xL-Nyh0sQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-14  2:16                       ` Peter Sefton
     [not found]                         ` <CAGQnt7V4HxtkBDjaFtYK2o77B0HWqj6o__423hHGJyed7eAf2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-14  7:03                           ` John MacFarlane
2013-10-14  6:01               ` BP Jonsson
2013-10-16 14:16               ` BP Jonsson
     [not found]                 ` <CAFC_yuRuOgEKK8BG=eDsm1KG0_CbCda8_GAFWJPjp0Agt3Kq_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-16 16:13                   ` John MacFarlane
2013-10-16 16:32                   ` BP Jonsson
     [not found]                     ` <525EBF8A.7050106-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-16 17:49                       ` John MacFarlane
     [not found]                         ` <20131016174957.GA59114-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2013-10-17  9:02                           ` BP Jonsson
     [not found]                             ` <525FA791.60509-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-17 16:09                               ` John MacFarlane
     [not found]                                 ` <20131017160958.GC65594-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2013-10-17 19:31                                   ` BP Jonsson
     [not found]                                     ` <52603B2E.1080100-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-17 23:41                                       ` John MacFarlane
     [not found]                                         ` <20131017234100.GC25883-nFAEphtLEs+AA6luYCgp0U1S2cYJDpTV9nwVQlTi/Pw@public.gmane.org>
2013-10-18  9:26                                           ` BP Jonsson
     [not found]                                             ` <5260FECB.30409-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-18 15:10                                               ` John MacFarlane

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).