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

Provide method for metadata processing in lua filters #3584

Merged
merged 6 commits into from
Apr 26, 2017

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Apr 17, 2017

Allow processing of metadata without having to push the whole document to the lua stack. Additionally, the pandoc.reader lua submodule is removed in favor of a simple read function which takes a string and format specifier as arguments.

Additional API change: All functions defined directly in the Text.Pandoc module are pushed to Text.Pandoc.Extensions or one of the newly introduced Text.Pandoc.Readers or Text.Pandoc.Writers modules. This is technically not necessary.

This change is intended as a solution to #1960. The following uses the metadata from metadata-file.yaml.

return {
  {
    Meta = function(meta)
      local metafile = io.open('metadata-file.yaml', 'r')
      local content = metafile:read("*a")
      metafile:close()
      return pandoc.read(content, "markdowns").meta
    end,
  }
}

tarleb added 6 commits April 16, 2017 21:00
Meta elements that are treated as lua tables (i.e. MetaList,
MetaInlines, MetaBlocks, and MetaMap), are no longer wrapped in an
additional table but simply marked via a metatable.  This allows
treating those meta values just like normal tables, while still making
empty elements of those values distinguishable.
Extension parsing and processing functions were defined in the top-level
Text.Pandoc module.  These functions are moved to the Extensions
submodule as to enable reuse in other submodules.
Reader helper functions were defined in the top-level Text.Pandoc
module. These functions are moved to the Readers submodule as to enable
reuse in other submodules.
Writer helper functions were defined in the top-level Text.Pandoc
module. These functions are moved to the Writer submodule as to enable
reuse in other submodules.
A single `read` function parsing pandoc-supported formats is added to
the module. This is simpler and more convenient than the previous method
of exposing all reader functions individually.
@tarleb tarleb force-pushed the lua-meta-handling branch from 38da229 to 178d106 Compare April 17, 2017 13:20
@tarleb tarleb force-pushed the lua-meta-handling branch 2 times, most recently from 5772449 to 4bd9698 Compare April 18, 2017 18:26
@jgm
Copy link
Owner

jgm commented Apr 26, 2017

@tarleb
These look fine to me, so go ahead and merge them.

By the way, at some point we'll need a tutorial on how to use the lua filters.

@tarleb tarleb merged commit 24ef672 into jgm:master Apr 26, 2017
@tarleb tarleb deleted the lua-meta-handling branch April 26, 2017 21:28
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

Successfully merging this pull request may close these issues.

2 participants