Skip to content

Commit 742a0c4

Browse files
Omikhleiaalerque
authored andcommitted
fix(packages): Ignore @preamble in bibTeX bibliography
Skip `@preamble` as done for `@comment`. The `@preamble` command is used to provide TeX or LaTeX macros that are processed by BibTeX program, but it is unspecified what to do with these when converting to a format that does not use TeX. See #2051
1 parent ca906f0 commit 742a0c4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/bibtex/init.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ local bibtexparser = epnf.define(function (_ENV)
2121
local value = balanced + doubleq + myID
2222
local pair = Cg(myTag * _ * "=" * _ * C(value)) * _ * sep^-1 / function (...) local t= {...}; return t[1], t[#t] end
2323
local list = Cf(Ct("") * pair^0, rawset)
24-
local commentKey = Cmt(R("az", "AZ")^1, function(_, _, a)
25-
return a:lower() == "comment"
24+
local skippedType = Cmt(R("az", "AZ")^1, function(_, _, tag)
25+
-- ignore both @comment and @preamble
26+
local t = tag:lower()
27+
return t == "comment" or t == "preamble"
2628
end)
2729

2830
START "document"
29-
document = (V"comment" + V"entry")^1 -- order important: @comment must have precedence over @other
31+
document = (V"skipped" + V"entry")^1 -- order important: skipped (@comment, @preamble) must be first
3032
* (-1 + E("Unexpected character at end of input"))
31-
comment = WS +
32-
( V"blockcomment" + (P"%" * (1-S"\r\n")^0 * S"\r\n") / function () return "" end) -- Don't bother telling me about comments
33-
blockcomment = (P("@") * commentKey) + balanced / function () return "" end -- Don't bother telling me about comments
33+
skipped = WS +
34+
( V"blockskipped" + (P"%" * (1-S"\r\n")^0 * S"\r\n") / "")
35+
blockskipped = (P("@") * skippedType) + balanced / ""
3436
entry = Ct( P("@") * Cg(myTag, "type") * _ * P("{") * _ * Cg(myID, "label") * _ * sep * list * P("}") * _ )
3537
end)
3638
-- luacheck: pop

0 commit comments

Comments
 (0)