get("#537") -- printShortenedReferenceTree get("#534") -- parseQuestionnaire get("#532") -- getBridgeMap get("#533") -- replaceSnippetIDs get("#539") -- tableToLine parseQuestionnaire("#2000291") _, _, masterSourceID, masterDestID = getSnippetTitle(masterBridgeID):find("A master bridge from (#%d+) to (#%d+)") idmap = getBridgeMap(masterBridgeID) -- walk the reference tree refTree = {} printShortenedReferenceTree(masterSourceID, "", {}, refTree) for line in all(refTree) do _, _, id = line:find("^ *(#%d+) %- ") if id then -- ref tree part found. identify type & action dest = idmap[id] if dest ~= nil and dest:find("^#") then -- type: already bridged verdict = 'bridged. '..dest else verdict = verdicts[id] if id == masterSourceID then -- type: is master source (thus already bridged) verdict = 'done (is master source)' end end print(id..": "..(verdict or "no verdict")) if verdict == 'copy verbatim' then -- assume source type is nt -- we interpret 'copy verbatim' as bridge-translate all IDs -- we find in the original snippet (in title or text) sourceID = id sourceTitle = getSnippetTitle(sourceID) sourceText = getSnippet(sourceID) destTitle = replaceSnippetIDs(sourceTitle, idmap) destText = replaceSnippetIDs(sourceText, idmap) if (destTitle..destText):find("<unbridged #") then print("Snippet contains unbridged elements, skipping node") goto nextNode end snippet = {type='nt', title=destTitle, text=destText} print("lua [[ ") print(" destID = create "..tableToLine(snippet)) print(" create {type='nt', title='Bridge from "..sourceID.." to '..destID..' following master bridge "..masterBridgeID.."', text=destID}") print("]]") -- end after first node processed goto done else print("Unknown verdict, skipping node") end end ::nextNode:: end ::done::
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #538 |
Snippet name: | Duplicator, attempt 2 |
Eternal ID of this version: | #538/1 |
Text MD5: | 64ed724fe652a814a3dac05de090c221 |
Author: | stefan |
Category: | |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-03-16 23:15:30 |
Source code size: | 2062 bytes / 61 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 822 / 182 |
Referenced in: | [show references] |