diff options
author | Karl Berry <karl@freefriends.org> | 2011-08-06 23:40:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-08-06 23:40:52 +0000 |
commit | f031f598f31027d1018ef72f912ec392f411bb27 (patch) | |
tree | 127ba7c4f08244d857d4d6ee02073c9ea62bde17 /Master/texmf-dist/tex/lualatex | |
parent | ed6afc11e008945cafecd21b5af6f931918ec4fb (diff) |
new lualatex package luabibentry (28jun11)
git-svn-id: svn://tug.org/texlive/trunk@23435 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.lua | 104 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.sty | 56 |
2 files changed, 160 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.lua b/Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.lua new file mode 100644 index 00000000000..8fdceb2c8a7 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.lua @@ -0,0 +1,104 @@ +--- +--- This is file `luabibentry.lua', +--- generated with the docstrip utility. +--- +--- The original source files were: +--- +--- luabibentry.dtx (with options: `lua') +--- +--- Copyright (c) 2011 by Oliver Kopp <oliver.kopp.googlemail.com> +--- +--- This file was generated from file(s) of luabibentry distribution. +--- ----------------------------------------------------------------- +--- +--- This work may be distributed and/or modified under the conditions of +--- the LaTeX Project Public License, version 1.3c of the license. +--- The latest version of this license is in +--- http://www.latex-project.org/lppl.txt +--- and version 1.3c or later is part of all distributions of LaTeX +--- version 2005/12/01 or later. +--- +--- This work has the LPPL maintenance status "maintained". +--- +--- The Current Maintainer and author of this work is Oliver Kopp. +--- +--- This file may only be distributed together with the files listed in +--- `luabibentry.dtx'. You may however distribute the files listed in +--- `luabibentry.dtx' without this file. +--- +if (luatexbase and (luatexbase.provides_module)) then + luatexbase.provides_module({ + name = "luabibentry", + date = "2011/06/27", + version = "0.1", + description = "LuaLaTeX Package to Place Bibliography Entries in Text", + author = "Oliver Kopp", + licence = "LPPL v1.3c or later" + }) +end +module("luabibentry", package.seeall) +require("lualibs-file") + +-- stores all entries +local entries = {} + +-- builds the data by reading the given filename +function builddata(filename) + -- Parameters seem to be passed as arrays. + -- We access the first element of the parameter to get the filename + local file = io.open(filename[1], "r") + if file==nil then + texio.write_nl("luabibentry: could not open file " .. filename[1]) + return + end + local line = file:read("*line") + while (line~=nil) do + -- \bibitem is our marker for new entries + local i = string.find(line, "\\bibitem") + if i~=nil then + -- we expect the key in brackets in the same line + i = string.find(line,"{") + local lasti = 0 + -- we jump to the last bracket + while i~= nil do + lasti = i + i = string.find(line,"{",i+1) + end + local key = string.sub(line, lasti+1) + -- we use the text from the last opening bracket ("{") until + -- the end of the line minus one + -- we expect nothing more to follow in this line + key = string.sub(key, 1, string.len(key)-1) + -- the next lines are the entry + -- we expect an entry to be finished with a blank line + -- (or the end of the file) + line = file:read("*line") + local entry = "" + while (line~=nil) and (line~="") do + entry = entry .. line + line = file:read("*line") + end + -- remove the final dot (if present) + local entryLen = string.len(entry) + local lastChar = string.sub(entry, entryLen, entryLen) + if lastChar == "." then + entry = string.sub(entry, 1, entryLen-1) + end + entries[key]=entry + end + line = file:read("*line") + end + file:close() +end + +-- looks up the given key in the entries +-- in case an entry is not found, a bold question mark is printed +function bibentry(key) + local res = entries[key[1]] + if res==nil then + res = "\\textbf{?}" + end + tex.print(res) +end + + diff --git a/Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.sty b/Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.sty new file mode 100644 index 00000000000..263e59ec5d5 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/luabibentry/luabibentry.sty @@ -0,0 +1,56 @@ +%% +%% This is file `luabibentry.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% luabibentry.dtx (with options: `package') +%% +%% +%% +%% Copyright (c) 2011 by Oliver Kopp <oliver.kopp.googlemail.com> +%% +%% This file was generated from file(s) of luabibentry distribution. +%% ----------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, version 1.3c of the license. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% The Current Maintainer and author of this work is Oliver Kopp. +%% +%% This file may only be distributed together with the files listed in +%% `luabibentry.dtx'. You may however distribute the files listed in +%% `luabibentry.dtx' without this file. +%% +%% Usage: +%% +%% \setupbibentry{<bibliography>} before the usage of \bibentry. +%% \setupbibentry{\jobname} may be used if the bibliography has the same name as the .tex file. +%% +%% \bibentry{<entry>} where you want to have placed an entry. +%% In case an entry is not found "?" is output +%% +\NeedsTeXFormat{LaTeX2e}[1995/06/01] +\ProvidesPackage{luabibentry} +[2011/06/27 v0.1 LuaLaTeX Package to place bibliography entries in text] + +\RequirePackage{ifluatex} +\ifluatex\else + \PackageError{luabibentry}{lualatex needed}{% + Package `luabibentry' needs LuaTeX.\MessageBreak + So you should use `lualatex' to process you document!\MessageBreak + See documentation of `luabibentry' for further information.}% + \expandafter\expandafter\expandafter\csname endinput\endcsname +\fi +\directlua{dofile("luabibentry.lua")} +\newcommand{\setupbibentry}[1]{\directlua{luabibentry.builddata{"#1.bbl"}}} +\newcommand{\bibentry}[1]{\nocite{#1}\directlua{luabibentry.bibentry{"#1"}}} +\endinput +%% +%% End of file `luabibentry.sty'. |