Repository navigation
Conversation
…ext, as panclude does
…ory; the same AST as panclude.lua, then pantable
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A table's CSV can now come from a file named by the code block's
includeattribute:The
includekey in the YAML block andinclude-encodingare unchanged, so nothing breaks.The attribute and panclude
This is the
includeattribute of panclude, a Lua filter that appends a file's content to the element naming it. pantable does the same to a code block of classtable, then reads the block as before:\n;\n(a YAML header, then the file's rows; the block's own rows, then the file's); an empty file adds nothing;So
pandoc -F pantableandpandoc -L panclude.lua -F pantablebuild the same table: either may do the including, and after panclude, pantable sees an ordinary code block. Two differences when pantable does it alone:includekey's does; panclude starts at the document's directory. The two agree when pandoc runs from the document's directory;startLine,endLine(start-line,end-line),dedentandraw, are not read: the whole file is included, and a warning names them.A file that cannot be read (not found, a directory, not UTF-8) leaves the code block as it is, attribute and all, with an error naming the path and the reason, never the file's content: what the
includekey does for a missing file, and what panclude does.Given both the attribute and the key, the attribute's file is appended first, then the key reads the CSV from its own file, as it always has.
Tests
include_external_csv), a missing file (include_external_csv_invalid_path); and new ones: an empty block, the block's rows then the file's, an empty file, a byte order mark and CRLF, a file beginning with a YAML block, a file that is not UTF-8, a directory, the attribute and the key together.include_key,include_key_invalid_path(the former attribute-less cases) andencoding(include-encoding).tests/test_include.pychecks the messages, and that, for each golden case with the attribute,pandoc -L panclude.lua -F pantablegives the same native AST aspandoc -F pantable. It downloadspanclude.luafrom GitHub at a fixed commit into a temporary directory, and skips when it cannot.Choices that could go the other way
includekey's missing file. With theincludekey, a directory or a file that does not decode still stops the filter with Python's exception; that is left as it was.include-encodingapplies to the key's file.panclude.luacould be vendored.