Reputation: 175
I am getting the error: attempt to index a nil value (field 'attributes')
when trying to add a class to a Para element.
The documentation https://pandoc.org/lua-filters.html#pandoc.para seems to suggest that para (and BulletList) only have a content part but no attributes part. So how to add a class to these elements?
Filter:
Para = function (el)
el.attributes['class']='lead'
return el
end
Sample:
# this is the title
Lead text for this section
Expected result:
<p class="lead">Lead text for this section</p>
Upvotes: 5
Views: 541
Reputation: 22599
Unfortunately, the document model used by pandoc supports attributes only on a limited set of elements at the moment. See issue #684 in pandoc's issue tracker.
So the only viable method is to "manually" generate the HTML in the filter:
function Para (para)
return pandoc.Plain(
{pandoc.RawInline('html', '<p class="lead">')} ..
para.content ..
{pandoc.RawInline('html', '</p>')}
)
end
Upvotes: 5