From cb8151f76688be06015fc4a08cdf8166207d8d73 Mon Sep 17 00:00:00 2001 From: DanielJDufour Date: Sat, 23 Jul 2022 19:47:18 -0400 Subject: [PATCH] search for nested tags in find-tags-by-name --- find-tags-by-name.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/find-tags-by-name.js b/find-tags-by-name.js index 72030f7..2dcc7f9 100644 --- a/find-tags-by-name.js +++ b/find-tags-by-name.js @@ -3,10 +3,15 @@ const findTagByName = require("./find-tag-by-name.js"); function findTagsByName(xml, tagName, options) { const tags = []; const debug = (options && options.debug) || false; + const nested = options && typeof options.nested === "boolean" ? options.nested : true; let startIndex = (options && options.startIndex) || 0; let tag; while ((tag = findTagByName(xml, tagName, { debug, startIndex }))) { - startIndex = tag.end; + if (nested) { + startIndex = tag.start + 1 + tagName.length; + } else { + startIndex = tag.end; + } tags.push(tag); } if (debug) console.log("findTagsByName found", tags.length, "tags");