Skip to content

Commit

Permalink
added include_recent
Browse files Browse the repository at this point in the history
  • Loading branch information
kvakil committed Jun 5, 2017
1 parent 0ef7b93 commit c015b71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion log.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

\begin{luacode}
local includer = require "lua.includer"
includer.include_year("2017")
includer.include_recent("2017", 10)
\end{luacode}

\end{document}
24 changes: 18 additions & 6 deletions lua/includer.moon
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,24 @@ output_month_entry = (filename) ->
tex.sprint "\\chapter{#{nice_month filename}}"
tex.sprint "\\clearpage"

--- includes recent entries
-- @tparam string year the year as a string (e.g. "2017")
-- @tparam int n the number of entries to include
lua.includer.include_recent = (year, n) ->
all_files = include year
entry_files = [f for f in skeys all_files when is_day_entry(f) or is_month(f)]
-- @todo always include month including the days
skip = #entry_files - n
for _, filename in pairs entry_files
if skip < 1
if is_day_entry filename
output_day_entry filename
elseif is_month filename
output_month_entry filename
else
skip -= 1

--- includes all files in the directory year/
-- @tparam string year the year as a string (e.g. "2017")
lua.includer.include_year = (year) ->
all_files = include year
for filename in skeys all_files
if is_day_entry filename
output_day_entry filename
elseif is_month filename
output_month_entry filename
lua.includer.include_recent year, math.huge

0 comments on commit c015b71

Please sign in to comment.