Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org Abstract Block Export #57

Closed
biggs opened this issue Aug 25, 2018 · 5 comments
Closed

Org Abstract Block Export #57

biggs opened this issue Aug 25, 2018 · 5 comments

Comments

@biggs
Copy link

biggs commented Aug 25, 2018

Is it possible to allow export of the abstract block, i.e.
#+BEGIN_ABSTRACT
as a pandoc_metadata 'abstract'? This would allow export of an abstract before the TOC in latex documents, which currently requires a long:
#+PANDOC_METADATA "abstract: very long line"

@biggs biggs changed the title Is it possible to allow export of the org abstract block, i.e. Org Export Block Aug 25, 2018
@biggs biggs changed the title Org Export Block Org Abstract Block Export Aug 25, 2018
@tarleb
Copy link

tarleb commented Aug 25, 2018

Yes, this is possible, but requires some trickery. A simple way is to use a Lua filter: Put the following into a file and name it abstract-div-to-meta.lua. The file should either be in the same folder as your .org document, or in $HOME/.pandoc/filters/; the latter makes sense if you plan to re-use this technique with other documents.

-- file: abstract-div-to-meta.lua
local abstract = {}

function Div (div)
  if div.classes:includes 'ABSTRACT' then
    abstract = div.content
    return {}
  end
end

function Meta (meta)
  meta.abstract = pandoc.MetaBlocks(abstract)
  return meta
end

Now tell pandoc to use this by altering the variable org-pandoc-options. E.g., M-x (setq org-pandoc-options '((standalone . t) (lua-filter . "abstract-div-to-meta.lua"))). Your ABSTRACT block should now be converted into pandoc metadata on every export.

@biggs
Copy link
Author

biggs commented Aug 26, 2018

Thanks for the quick response, this does indeed seem to be the way to do it. However I'm currently getting an error with the LUA script:

Error occured. 
Error running filter abstract-div-to-meta.lua:
Error while running filter function: abstract-div-to-meta.lua:5: attempt to call a nil value (method 'includes')

Just to clarify, it runs without an abstract block, but not with one.

@biggs
Copy link
Author

biggs commented Aug 26, 2018

OK, I found a way to achieve more or less the desired functionality, using instead a top-level Abstract header:
https://github.com/pandoc/lua-filters/tree/master/abstract-to-meta

Thanks.

@biggs biggs closed this as completed Aug 26, 2018
@tarleb
Copy link

tarleb commented Aug 28, 2018

Happy the other filter works for you.

The error is puzzling, includes exists since pandoc 2.0.4. Are you using an older version?

@biggs
Copy link
Author

biggs commented Aug 31, 2018

Ah - that does appear to be the issue, 2.0.2. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants