diff --git a/filters/hugo_makedeps.lua b/filters/hugo_makedeps.lua index da16a8d..60031e6 100644 --- a/filters/hugo_makedeps.lua +++ b/filters/hugo_makedeps.lua @@ -92,10 +92,11 @@ images and local links to Markdown files. For each such link, this process will (recursively, via breadth-first search). -Usage: This filter is intended to be used with individual files that are placed directly in -the working directory. +Usage: This filter is intended to be used with individual files that are placed either directly +in the working directory or in a subdirectory. Examples: pandoc -L hugo_makedeps.lua -t markdown readme.md + pandoc -L hugo_makedeps.lua -t markdown subdir/leaf/readme.md Credits: Work on this filter was partially inspired by some ideas shared in "include-files" @@ -104,19 +105,19 @@ Krewinkel (@tarleb), license: MIT). The 'hugo_makedeps.lua' filter has been deve from scratch and is neither based on nor contains any third-party code. -Caveats: +Caveats (see 'hugo_rewritelinks.lua'): (a) All referenced Markdown files must have UNIQUE NAMES. (b) References to the top index page (landing page) are (presumably) not working. ]]-- -- vars -local img = {} -- list of collected images to ensure deterministic order in generated list (for testing) -local images = {} -- set of collected images to avoid processing the same file/image several times -local link_img = {} -- dependencies for _index.md: all referenced images +local img = {} -- list of collected images (new_image) to ensure deterministic order in generated list (for testing) +local images = {} -- set of collected images (new_image:old_image) to avoid processing the same file/image several times +local link_img = {} -- dependencies for _index.md: all referenced images (old_target:new_image) -local links = {} -- set of collected links to avoid processing the same file/link several times -local weights = {} -- list of collected links to calculate the "weight" property for a page +local links = {} -- set of collected links (old_target:new_target) to avoid processing the same file/link several times +local weights = {} -- list of collected links (old_target) to calculate the "weight" property for a page local frontier = {} -- queue to implement breadth-first search for visiting links local frontier_first = 0 -- first element in queue @@ -129,47 +130,29 @@ local ROOT = "." -- absolute path to working directory when start -- helper -local function _is_relative (target) - return pandoc.path.is_relative(target) -end - -local function _is_url (target) - return target:match('https?://.*') -end - -local function _is_markdown (target) - return target:match('.*%.md') -end - local function _is_local_path (path) - return _is_relative(path) and - not _is_url(path) + return pandoc.path.is_relative(path) and -- is relative path + not path:match('https?://.*') -- is not http(s) end local function _is_local_markdown_file_link (inline) return inline and inline.t and - inline.t == "Link" and - _is_markdown(inline.target) and - _is_local_path(inline.target) + inline.t == "Link" and -- is pandoc.Link + inline.target:match('.*%.md') and -- is markdown + _is_local_path(inline.target) -- is relative & not http(s) end -local function _old_path (include_path, file) - return pandoc.path.normalize(pandoc.path.join({include_path, file})) +local function _prepend_include_path (path) + local include_path = pandoc.path.make_relative(pandoc.system.get_working_directory(), ROOT) + return pandoc.path.normalize(pandoc.path.join({ include_path, path })) end -local function _new_path (include_path, parent_file, file) - local parent = (parent_file == INDEX_MD) and "." or parent_file - return pandoc.path.normalize(pandoc.path.join({PREFIX, include_path, parent, file})) -end - -local function _new_path_idx (include_path, parent_file) - return _new_path(include_path, parent_file, "_index.md") -end - -local function _filename_woext (target) - local name, _ = pandoc.path.split_extension(pandoc.path.filename(target)) - return name +local function _new_path (parent, file) + local parent, _ = pandoc.path.split_extension(pandoc.path.filename(parent)) + local name = (parent == INDEX_MD) and "." or parent + local path = _prepend_include_path(name) + return pandoc.path.normalize(pandoc.path.join({ PREFIX, path, file })) end @@ -196,85 +179,79 @@ local function _dequeue () end --- processing of markdown files, links and images -local function _remember_file (include_path, md_file, newl) - -- safe as PREFIX/include_path/(md_file?)/_index.md: include_path/(md_file .. ".md") - local oldl = _old_path(include_path, md_file .. ".md") +-- store for each processed file the old and the new path +local function _remember_file (target) + local old_target = target -- old link: include_path/target + local new_target = _new_path(target, "_index.md") -- new link: PREFIX/include_path/(md_file?)/_index.md - if not links[newl] then - weights[#weights + 1] = newl - links[newl] = oldl + -- safe as PREFIX/include_path/(md_file?)/_index.md: include_path/target + if not links[old_target] then + weights[#weights + 1] = old_target + links[old_target] = new_target -- store old target as key for convenience, otherwise we would need to calculate the new target already in '_filter_blocks_in_dir' ... (1 old_target : 1 new_target) else - io.stderr:write("\t (_remember_file) WARNING: new path '" .. newl .. "' (from '" .. oldl .. "') has been already processed ... THIS SHOULD NOT HAPPEN ... \n") + io.stderr:write("\t (_remember_file) WARNING: new path '" .. new_target .. "' (from '" .. old_target .. "') has been already processed ... THIS SHOULD NOT HAPPEN ... \n") end end -local function _remember_image (include_path, md_file, image_src, newl) - -- safe as PREFIX/include_path/(md_file?)/file(image_src): include_path/image_src - local oldi = _old_path(include_path, image_src) - local newi = _new_path(include_path, md_file, pandoc.path.filename(image_src)) +-- store for each processed file the old and new image source +local function _remember_image (image_src, target) + local old_image = _prepend_include_path(image_src) -- old src: include_path/image_src + local new_image = _new_path(target, pandoc.path.filename(image_src)) -- new src: PREFIX/include_path/(md_file?)/file(image_src) - if not images[newi] then - img[#img + 1] = newi -- list: we want the same sequence for each run - images[newi] = oldi -- set: do not store images twice + -- safe as PREFIX/include_path/(md_file?)/file(image_src): include_path/image_src + if not images[new_image] then + img[#img + 1] = new_image -- list: we want the same sequence for each run + images[new_image] = old_image -- store new image src as key because the same image can be referenced by different markdown files and needs to be copied in all cases to the new locations (1 old_image : n new_image) -- create a dependency for corresponding '_index.md' - link_img[newl] = link_img[newl] and (link_img[newl] .. " " .. newi) or (newi) + link_img[target] = link_img[target] and (link_img[target] .. " " .. new_image) or (new_image) end end ---[[ -process Pandoc document (list of blocks): - -(1) "save" link to current document, i.e. do not process this document again -(2) collect all images and all links in this document (local, relative, not HTTP, links to Markdown files) -]]-- -local function _process_doc (blocks, md_file, include_path) - -- new link: PREFIX/include_path/(md_file?)/_index.md - local newl = _new_path_idx(include_path, md_file) - - -- if not already processed: - if not links[newl] then - -- remember this file - _remember_file(include_path, md_file, newl) - - -- enqueue local landing page "include_path/readme.md" for later processing - _enqueue(_old_path(include_path, INDEX_MD .. ".md")) - - -- collect and enqueue all new images and links in this file 'include_path/md_file' - local collect_images_links = { - Image = function (image) - if _is_local_path(image.src) then - -- remember this image - _remember_image(include_path, md_file, image.src, newl) - end - end, - Link = function (link) - if _is_local_markdown_file_link(link) then - -- enqueue "include_path/link.target" for later processing - _enqueue(_old_path(include_path, link.target)) +-- process all blocks in context of target's directory +local function _filter_blocks_in_dir (blocks, target) + -- change into directory of 'target' to resolve potential '../' in path + pandoc.system.with_working_directory( + pandoc.path.directory(target), -- may still contain '../' + function () + -- same as 'pandoc.path.directory(target)' but w/o '../' since Pandoc cd'ed here + local target = _prepend_include_path(pandoc.path.filename(target)) + + -- if not already processed: + if not links[target] then + -- remember this file (path w/o '../') + _remember_file(target) + + -- enqueue local landing page of current path for later processing ("include_path/readme.md") + _enqueue(_prepend_include_path(INDEX_MD .. ".md")) + + -- collect and enqueue all new images and links in current file 'include_path/target' + blocks:walk({ + Image = function (image) + if _is_local_path(image.src) then + _remember_image(image.src, target) + end + end, + Link = function (link) + if _is_local_markdown_file_link(link) then + _enqueue(_prepend_include_path(link.target)) + end + end + }) end - end - } - blocks:walk(collect_images_links) - end + end) end -local function _handle_file (oldl) - local fh = io.open(oldl, "r") +-- open file and read content (and parse recursively and return list of blocks via '_filter_blocks_in_dir') +function _handle_file (target) + local fh = io.open(target, "r") if not fh then - io.stderr:write("\t (_handle_file) WARNING: cannot open file '" .. oldl .. "' ... skipping ... \n") + io.stderr:write("\t (_handle_file) WARNING: cannot open file '" .. target .. "' ... skipping ... \n") else local blocks = pandoc.read(fh:read "*all", "markdown", PANDOC_READER_OPTIONS).blocks fh:close() - pandoc.system.with_working_directory( - pandoc.path.directory(oldl), -- may still contain '../' - function () - -- same as 'pandoc.path.directory(oldl)' but w/o '../' since Pandoc cd'ed here - local include_path = pandoc.path.make_relative(pandoc.system.get_working_directory(), ROOT) - _process_doc(blocks, _filename_woext(oldl), include_path) - end) + _filter_blocks_in_dir(blocks, target) end end @@ -282,22 +259,26 @@ end -- emit structures for make.deps local function _emit_images () local inlines = pandoc.List:new() - for _, newi in ipairs(img) do - inlines:insert(pandoc.RawInline("markdown", newi .. ": " .. images[newi] .. "\n")) - inlines:insert(pandoc.RawInline("markdown", "WEB_IMAGE_TARGETS += " .. newi .. "\n\n")) + for _, new_image in ipairs(img) do + local old_image = images[new_image] + + inlines:insert(pandoc.RawInline("markdown", new_image .. ": " .. old_image .. "\n")) + inlines:insert(pandoc.RawInline("markdown", "WEB_IMAGE_TARGETS += " .. new_image .. "\n\n")) end return inlines end local function _emit_links () local inlines = pandoc.List:new() - for weight, newl in ipairs(weights) do - inlines:insert(pandoc.RawInline("markdown", newl .. ": " .. links[newl] .. "\n")) - if link_img[newl] then - inlines:insert(pandoc.RawInline("markdown", newl .. ": " .. link_img[newl] .. "\n")) + for weight, old_target in ipairs(weights) do + local new_target = links[old_target] + + inlines:insert(pandoc.RawInline("markdown", new_target .. ": " .. old_target .. "\n")) + if link_img[old_target] then + inlines:insert(pandoc.RawInline("markdown", new_target .. ": " .. link_img[old_target] .. "\n")) end - inlines:insert(pandoc.RawInline("markdown", newl .. ": WEIGHT=" .. weight .. "\n")) - inlines:insert(pandoc.RawInline("markdown", "WEB_MARKDOWN_TARGETS += " .. newl .. "\n\n")) + inlines:insert(pandoc.RawInline("markdown", new_target .. ": WEIGHT=" .. weight .. "\n")) + inlines:insert(pandoc.RawInline("markdown", "WEB_MARKDOWN_TARGETS += " .. new_target .. "\n\n")) end return inlines end @@ -310,16 +291,20 @@ function Pandoc (doc) INDEX_MD = doc.meta.indexMD or "readme" -- we do need the name w/o extension ROOT = pandoc.system.get_working_directory() -- remember our project root + -- get filename (input file) + local input_files = PANDOC_STATE.input_files + local file = #input_files >= 1 and input_files[#input_files] or "." + -- landing page: process all images and links - _process_doc(doc.blocks, INDEX_MD, ".") + _handle_file(file) -- process files recursively: breadth-first search - local oldl = _dequeue() - while oldl do - _handle_file(oldl) - oldl = _dequeue() + local target = _dequeue() + while target do + _handle_file(target) + target = _dequeue() end -- emit dependency makefile - return pandoc.Pandoc({pandoc.Plain(_emit_images()), pandoc.Plain(_emit_links())}, doc.meta) + return pandoc.Pandoc({ pandoc.Plain(_emit_images()), pandoc.Plain(_emit_links()) }, doc.meta) end diff --git a/filters/hugo_rewritelinks.lua b/filters/hugo_rewritelinks.lua index 5c9403d..fc364b6 100644 --- a/filters/hugo_rewritelinks.lua +++ b/filters/hugo_rewritelinks.lua @@ -37,7 +37,7 @@ Examples: pandoc -L hugo_rewritelinks.lua -t markdown test/subdir/leaf/foo.md -Caveats: +Caveats (see 'hugo_makedeps.lua'): (a) All referenced Markdown files must have UNIQUE NAMES. (b) References to the top index page (landing page) are (presumably) not working. ]]-- diff --git a/filters/include_mdfiles.lua b/filters/include_mdfiles.lua index b2c0fcd..527be54 100644 --- a/filters/include_mdfiles.lua +++ b/filters/include_mdfiles.lua @@ -54,7 +54,7 @@ end local function _prepend_include_path (path) local include_path = pandoc.path.make_relative(pandoc.system.get_working_directory(), ROOT) - return pandoc.path.normalize(pandoc.path.join({include_path, path})) + return pandoc.path.normalize(pandoc.path.join({ include_path, path })) end diff --git a/filters/test/Makefile b/filters/test/Makefile index 6ed3c4e..df97fae 100644 --- a/filters/test/Makefile +++ b/filters/test/Makefile @@ -2,7 +2,9 @@ DIFF ?= diff --strip-trailing-cr -u PANDOC ?= pandoc FILES_TRANSFORM = readme.md -FILES_MAKEDEPS = readme.md +FILES_MAKEDEPS1 = readme.md +FILES_MAKEDEPS2 = subdir/readme.md +FILES_MAKEDEPS3 = subdir/leaf/readme.md FILES_INCLUDEMD1 = summary.md FILES_INCLUDEMD2 = readme.md FILES_INCLUDEMD3 = subdir/readme.md @@ -16,33 +18,37 @@ LUA_INCLUDEMD = ../include_mdfiles.lua test: test_rewritelinks test_makedeps test_includemd test_rewritelinks: $(FILES_TRANSFORM) - @$(PANDOC) -L $(LUA_REWRITELINKS) -t native $^ \ + @$(PANDOC) -L $(LUA_REWRITELINKS) -t native $^ \ | $(DIFF) expected_rewritelinks1.native - - @$(PANDOC) -L $(LUA_REWRITELINKS) -M indexMD="foo" -t native $^ \ + @$(PANDOC) -L $(LUA_REWRITELINKS) -M indexMD="foo" -t native $^ \ | $(DIFF) expected_rewritelinks2.native - - @$(PANDOC) -L $(LUA_REWRITELINKS) -M indexMD="readme" -t native $^ \ + @$(PANDOC) -L $(LUA_REWRITELINKS) -M indexMD="readme" -t native $^ \ | $(DIFF) expected_rewritelinks3.native - - @$(PANDOC) -L $(LUA_REWRITELINKS) -M weight=42 -M indexMD="readme" -t native $^ \ + @$(PANDOC) -L $(LUA_REWRITELINKS) -M weight=42 -M indexMD="readme" -t native $^ \ | $(DIFF) expected_rewritelinks4.native - -test_makedeps: $(FILES_MAKEDEPS) - @$(PANDOC) -L $(LUA_MAKEDEPS) -t native $^ \ +test_makedeps: $(FILES_MAKEDEPS1) $(FILES_MAKEDEPS2) $(FILES_MAKEDEPS3) + @$(PANDOC) -L $(LUA_MAKEDEPS) -t native $(FILES_MAKEDEPS1) \ | $(DIFF) expected_makedeps1.native - - @$(PANDOC) -L $(LUA_MAKEDEPS) -M indexMD="foo" -t native $^ \ + @$(PANDOC) -L $(LUA_MAKEDEPS) -M indexMD="foo" -t native $(FILES_MAKEDEPS1) \ | $(DIFF) expected_makedeps2.native - - @$(PANDOC) -L $(LUA_MAKEDEPS) -M indexMD="readme" -t native $^ \ + @$(PANDOC) -L $(LUA_MAKEDEPS) -M indexMD="readme" -t native $(FILES_MAKEDEPS1) \ | $(DIFF) expected_makedeps3.native - - @$(PANDOC) -L $(LUA_MAKEDEPS) -M prefix="foobar" -M indexMD="readme" -t native $^ \ + @$(PANDOC) -L $(LUA_MAKEDEPS) -M prefix="foobar" -M indexMD="readme" -t native $(FILES_MAKEDEPS1) \ | $(DIFF) expected_makedeps4.native - + @$(PANDOC) -L $(LUA_MAKEDEPS) -t native $(FILES_MAKEDEPS2) \ + | $(DIFF) expected_makedeps5.native - + @$(PANDOC) -L $(LUA_MAKEDEPS) -t native $(FILES_MAKEDEPS3) \ + | $(DIFF) expected_makedeps6.native - test_includemd: $(FILES_INCLUDEMD1) $(FILES_INCLUDEMD2) $(FILES_INCLUDEMD3) $(FILES_INCLUDEMD4) - @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD1) \ + @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD1) \ | $(DIFF) expected_inludemd1.native - - @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD2) \ + @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD2) \ | $(DIFF) expected_inludemd2.native - - @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD3) \ + @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD3) \ | $(DIFF) expected_inludemd3.native - - @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD4) \ + @$(PANDOC) -L $(LUA_INCLUDEMD) -t native $(FILES_INCLUDEMD4) \ | $(DIFF) expected_inludemd4.native - @@ -56,15 +62,19 @@ expected_rewritelinks3.native: $(FILES_TRANSFORM) expected_rewritelinks4.native: $(FILES_TRANSFORM) $(PANDOC) -L $(LUA_REWRITELINKS) -M weight=42 -M indexMD="readme" -t native -o $@ $^ -expected: expected_makedeps1.native expected_makedeps2.native expected_makedeps3.native expected_makedeps4.native -expected_makedeps1.native: $(FILES_MAKEDEPS) +expected: expected_makedeps1.native expected_makedeps2.native expected_makedeps3.native expected_makedeps4.native expected_makedeps5.native expected_makedeps6.native +expected_makedeps1.native: $(FILES_MAKEDEPS1) $(PANDOC) -L $(LUA_MAKEDEPS) -t native -o $@ $^ -expected_makedeps2.native: $(FILES_MAKEDEPS) +expected_makedeps2.native: $(FILES_MAKEDEPS1) $(PANDOC) -L $(LUA_MAKEDEPS) -M indexMD="foo" -t native -o $@ $^ -expected_makedeps3.native: $(FILES_MAKEDEPS) +expected_makedeps3.native: $(FILES_MAKEDEPS1) $(PANDOC) -L $(LUA_MAKEDEPS) -M indexMD="readme" -t native -o $@ $^ -expected_makedeps4.native: $(FILES_MAKEDEPS) +expected_makedeps4.native: $(FILES_MAKEDEPS1) $(PANDOC) -L $(LUA_MAKEDEPS) -M prefix="foobar" -M indexMD="readme" -t native -o $@ $^ +expected_makedeps5.native: $(FILES_MAKEDEPS2) + $(PANDOC) -L $(LUA_MAKEDEPS) -t native -o $@ $^ +expected_makedeps6.native: $(FILES_MAKEDEPS3) + $(PANDOC) -L $(LUA_MAKEDEPS) -t native -o $@ $^ expected: expected_inludemd1.native expected_inludemd2.native expected_inludemd3.native expected_inludemd4.native expected_inludemd1.native: $(FILES_INCLUDEMD1) @@ -79,7 +89,7 @@ expected_inludemd4.native: $(FILES_INCLUDEMD4) clean: rm -rf expected_rewritelinks1.native expected_rewritelinks2.native expected_rewritelinks3.native expected_rewritelinks4.native - rm -rf expected_makedeps1.native expected_makedeps2.native expected_makedeps3.native expected_makedeps4.native + rm -rf expected_makedeps1.native expected_makedeps2.native expected_makedeps3.native expected_makedeps4.native expected_makedeps5.native expected_makedeps6.native rm -rf expected_inludemd1.native expected_inludemd2.native expected_inludemd3.native expected_inludemd4.native .PHONY: test test_rewritelinks test_makedeps test_includemd expected clean diff --git a/filters/test/expected_makedeps2.native b/filters/test/expected_makedeps2.native index e15576c..ae75ca6 100644 --- a/filters/test/expected_makedeps2.native +++ b/filters/test/expected_makedeps2.native @@ -1,7 +1,7 @@ [ Plain - [ RawInline (Format "markdown") "a.png: img/a.png\n" + [ RawInline (Format "markdown") "readme/a.png: img/a.png\n" , RawInline - (Format "markdown") "WEB_IMAGE_TARGETS += a.png\n\n" + (Format "markdown") "WEB_IMAGE_TARGETS += readme/a.png\n\n" , RawInline (Format "markdown") "file-b/a.png: img/a.png\n" , RawInline (Format "markdown") "WEB_IMAGE_TARGETS += file-b/a.png\n\n" @@ -23,9 +23,6 @@ , RawInline (Format "markdown") "WEB_IMAGE_TARGETS += subdir/readme/c.png\n\n" - , RawInline (Format "markdown") "readme/a.png: img/a.png\n" - , RawInline - (Format "markdown") "WEB_IMAGE_TARGETS += readme/a.png\n\n" , RawInline (Format "markdown") "orga/syllabus/modulbeschreibung.png: orga/img/modulbeschreibung.png\n" @@ -46,11 +43,15 @@ "WEB_IMAGE_TARGETS += subdir/leaf/bar/d.png\n\n" ] , Plain - [ RawInline (Format "markdown") "_index.md: foo.md\n" - , RawInline (Format "markdown") "_index.md: a.png\n" - , RawInline (Format "markdown") "_index.md: WEIGHT=1\n" + [ RawInline + (Format "markdown") "readme/_index.md: readme.md\n" , RawInline - (Format "markdown") "WEB_MARKDOWN_TARGETS += _index.md\n\n" + (Format "markdown") "readme/_index.md: readme/a.png\n" + , RawInline + (Format "markdown") "readme/_index.md: WEIGHT=1\n" + , RawInline + (Format "markdown") + "WEB_MARKDOWN_TARGETS += readme/_index.md\n\n" , RawInline (Format "markdown") "file-a/_index.md: file-a.md\n" , RawInline @@ -108,15 +109,6 @@ , RawInline (Format "markdown") "WEB_MARKDOWN_TARGETS += subdir/readme/_index.md\n\n" - , RawInline - (Format "markdown") "readme/_index.md: readme.md\n" - , RawInline - (Format "markdown") "readme/_index.md: readme/a.png\n" - , RawInline - (Format "markdown") "readme/_index.md: WEIGHT=8\n" - , RawInline - (Format "markdown") - "WEB_MARKDOWN_TARGETS += readme/_index.md\n\n" , RawInline (Format "markdown") "orga/syllabus/_index.md: orga/syllabus.md\n" @@ -124,7 +116,7 @@ (Format "markdown") "orga/syllabus/_index.md: orga/syllabus/modulbeschreibung.png\n" , RawInline - (Format "markdown") "orga/syllabus/_index.md: WEIGHT=9\n" + (Format "markdown") "orga/syllabus/_index.md: WEIGHT=8\n" , RawInline (Format "markdown") "WEB_MARKDOWN_TARGETS += orga/syllabus/_index.md\n\n" @@ -132,14 +124,14 @@ (Format "markdown") "orga/resources/_index.md: orga/resources.md\n" , RawInline - (Format "markdown") "orga/resources/_index.md: WEIGHT=10\n" + (Format "markdown") "orga/resources/_index.md: WEIGHT=9\n" , RawInline (Format "markdown") "WEB_MARKDOWN_TARGETS += orga/resources/_index.md\n\n" , RawInline (Format "markdown") "orga/exams/_index.md: orga/exams.md\n" , RawInline - (Format "markdown") "orga/exams/_index.md: WEIGHT=11\n" + (Format "markdown") "orga/exams/_index.md: WEIGHT=10\n" , RawInline (Format "markdown") "WEB_MARKDOWN_TARGETS += orga/exams/_index.md\n\n" @@ -147,7 +139,7 @@ (Format "markdown") "orga/grading/_index.md: orga/grading.md\n" , RawInline - (Format "markdown") "orga/grading/_index.md: WEIGHT=12\n" + (Format "markdown") "orga/grading/_index.md: WEIGHT=11\n" , RawInline (Format "markdown") "WEB_MARKDOWN_TARGETS += orga/grading/_index.md\n\n" @@ -158,7 +150,7 @@ (Format "markdown") "subdir/leaf/bar/_index.md: subdir/leaf/bar/b.png subdir/leaf/bar/d.png\n" , RawInline - (Format "markdown") "subdir/leaf/bar/_index.md: WEIGHT=13\n" + (Format "markdown") "subdir/leaf/bar/_index.md: WEIGHT=12\n" , RawInline (Format "markdown") "WEB_MARKDOWN_TARGETS += subdir/leaf/bar/_index.md\n\n" diff --git a/filters/test/expected_makedeps5.native b/filters/test/expected_makedeps5.native new file mode 100644 index 0000000..4b20759 --- /dev/null +++ b/filters/test/expected_makedeps5.native @@ -0,0 +1,75 @@ +[ Plain + [ RawInline + (Format "markdown") "subdir/c.png: subdir/img/c.png\n" + , RawInline + (Format "markdown") "WEB_IMAGE_TARGETS += subdir/c.png\n\n" + , RawInline + (Format "markdown") + "subdir/leaf/foo/b.png: subdir/leaf/img/b.png\n" + , RawInline + (Format "markdown") + "WEB_IMAGE_TARGETS += subdir/leaf/foo/b.png\n\n" + , RawInline + (Format "markdown") + "subdir/leaf/b.png: subdir/leaf/img/b.png\n" + , RawInline + (Format "markdown") + "WEB_IMAGE_TARGETS += subdir/leaf/b.png\n\n" + , RawInline + (Format "markdown") + "subdir/leaf/bar/b.png: subdir/leaf/img/b.png\n" + , RawInline + (Format "markdown") + "WEB_IMAGE_TARGETS += subdir/leaf/bar/b.png\n\n" + , RawInline + (Format "markdown") + "subdir/leaf/bar/d.png: subdir/leaf/img/d.png\n" + , RawInline + (Format "markdown") + "WEB_IMAGE_TARGETS += subdir/leaf/bar/d.png\n\n" + ] +, Plain + [ RawInline + (Format "markdown") "subdir/_index.md: subdir/readme.md\n" + , RawInline + (Format "markdown") "subdir/_index.md: subdir/c.png\n" + , RawInline + (Format "markdown") "subdir/_index.md: WEIGHT=1\n" + , RawInline + (Format "markdown") + "WEB_MARKDOWN_TARGETS += subdir/_index.md\n\n" + , RawInline + (Format "markdown") + "subdir/leaf/foo/_index.md: subdir/leaf/foo.md\n" + , RawInline + (Format "markdown") + "subdir/leaf/foo/_index.md: subdir/leaf/foo/b.png\n" + , RawInline + (Format "markdown") "subdir/leaf/foo/_index.md: WEIGHT=2\n" + , RawInline + (Format "markdown") + "WEB_MARKDOWN_TARGETS += subdir/leaf/foo/_index.md\n\n" + , RawInline + (Format "markdown") + "subdir/leaf/_index.md: subdir/leaf/readme.md\n" + , RawInline + (Format "markdown") + "subdir/leaf/_index.md: subdir/leaf/b.png\n" + , RawInline + (Format "markdown") "subdir/leaf/_index.md: WEIGHT=3\n" + , RawInline + (Format "markdown") + "WEB_MARKDOWN_TARGETS += subdir/leaf/_index.md\n\n" + , RawInline + (Format "markdown") + "subdir/leaf/bar/_index.md: subdir/leaf/bar.md\n" + , RawInline + (Format "markdown") + "subdir/leaf/bar/_index.md: subdir/leaf/bar/b.png subdir/leaf/bar/d.png\n" + , RawInline + (Format "markdown") "subdir/leaf/bar/_index.md: WEIGHT=4\n" + , RawInline + (Format "markdown") + "WEB_MARKDOWN_TARGETS += subdir/leaf/bar/_index.md\n\n" + ] +] diff --git a/filters/test/expected_makedeps6.native b/filters/test/expected_makedeps6.native new file mode 100644 index 0000000..9a26e5f --- /dev/null +++ b/filters/test/expected_makedeps6.native @@ -0,0 +1,22 @@ +[ Plain + [ RawInline + (Format "markdown") + "subdir/leaf/b.png: subdir/leaf/img/b.png\n" + , RawInline + (Format "markdown") + "WEB_IMAGE_TARGETS += subdir/leaf/b.png\n\n" + ] +, Plain + [ RawInline + (Format "markdown") + "subdir/leaf/_index.md: subdir/leaf/readme.md\n" + , RawInline + (Format "markdown") + "subdir/leaf/_index.md: subdir/leaf/b.png\n" + , RawInline + (Format "markdown") "subdir/leaf/_index.md: WEIGHT=1\n" + , RawInline + (Format "markdown") + "WEB_MARKDOWN_TARGETS += subdir/leaf/_index.md\n\n" + ] +]