From f9a7ab5beb20097ab8dd35b6218c576847b3b81a Mon Sep 17 00:00:00 2001 From: Florian Berthold Date: Thu, 7 May 2026 12:20:44 +0200 Subject: [PATCH] UI/Markdown: surface spellbook in MD output and sidebar - New AE:GenerateMarkdownSpellbook(): one section per spell tab (General, class, pet) with icon + name + db.ascension.gg link + rank. Skips empty tabs. - /coae export mdspellbook new slash subcommand - /coae export md now appends a Spellbook section after Talents in the full wiki page - UI sidebar: "MD Spellbook" button added under Markdown (Wiki) --- CoaExporter/Core.lua | 46 +++++++++++++++++++++++++++++++++- CoaExporter/UI/ExportFrame.lua | 12 ++++++--- README.md | 3 ++- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/CoaExporter/Core.lua b/CoaExporter/Core.lua index 441ad5a..eb14d68 100644 --- a/CoaExporter/Core.lua +++ b/CoaExporter/Core.lua @@ -262,6 +262,44 @@ function AE:GenerateMarkdownEnchants() return table.concat(lines, "\n") end +function AE:GenerateMarkdownSpellbook() + local sb = self.CollectSpellbook and self.CollectSpellbook() or { tabs = {} } + + local lines = {} + table.insert(lines, "## Spellbook\n") + + if not sb.tabs or #sb.tabs == 0 then + table.insert(lines, "*Spellbook not available - run `/coae debug` to check collector.*\n") + return table.concat(lines, "\n") + end + + table.insert(lines, string.format("Total: **%d** spells across %d tab(s).\n", + sb.totalSpells or 0, #sb.tabs)) + + for _, tab in ipairs(sb.tabs) do + if tab.spells and #tab.spells > 0 then + table.insert(lines, string.format("### %s (%d)", tab.name or "Tab", #tab.spells)) + table.insert(lines, "") + table.insert(lines, "| Icon | Spell | Rank |") + table.insert(lines, "|------|-------|------|") + for _, sp in ipairs(tab.spells) do + local icon = sp.icon or "" + local iconImg = icon ~= "" and string.format( + '', + icon) or "" + local link = (sp.spellID or 0) > 0 + and string.format("[%s](https://db.ascension.gg/?spell=%d)", sp.name or "", sp.spellID) + or (sp.name or "") + local rank = (sp.rank ~= nil and sp.rank ~= "") and tostring(sp.rank) or "-" + table.insert(lines, string.format("| %s | %s | %s |", iconImg, link, rank)) + end + table.insert(lines, "") + end + end + + return table.concat(lines, "\n") +end + function AE:GenerateMarkdownFull() local data = self:AssembleExport("all") or {} local char = data.character or {} @@ -326,6 +364,10 @@ function AE:GenerateMarkdownFull() table.insert(lines, "*No talent data - run `/coae debug` to check collector.*") end + -- Spellbook section + table.insert(lines, "") + table.insert(lines, self:GenerateMarkdownSpellbook()) + return table.concat(lines, "\n") end @@ -335,7 +377,7 @@ local HELP = [[ CoaExporter commands: /coae export all|talents|spellbook|gear|enchants -/coae export mdgear|mdenchants|md (full wiki) +/coae export mdgear|mdenchants|mdspellbook|md (full wiki) /coae catalog all|skills|talents /coae catalog dispels [class]|passives [class]|status /coae scrolls scan|export|reset|status @@ -350,6 +392,8 @@ local function HandleExport(rest) AE:ShowExport(AE:GenerateMarkdownGear(), "CoaExporter - Markdown Gear (Ctrl+C)") elseif rest == "mdenchants" then AE:ShowExport(AE:GenerateMarkdownEnchants(), "CoaExporter - Markdown Enchants (Ctrl+C)") + elseif rest == "mdspellbook" then + AE:ShowExport(AE:GenerateMarkdownSpellbook(), "CoaExporter - Markdown Spellbook (Ctrl+C)") elseif rest == "md" or rest == "mdfull" or rest == "wiki" then AE:ShowExport(AE:GenerateMarkdownFull(), "CoaExporter - Wiki Markdown (Ctrl+C)") elseif rest == "all" or rest == "talents" or rest == "spellbook" or rest == "gear" or rest == "enchants" then diff --git a/CoaExporter/UI/ExportFrame.lua b/CoaExporter/UI/ExportFrame.lua index b8293b1..b09c5ea 100644 --- a/CoaExporter/UI/ExportFrame.lua +++ b/CoaExporter/UI/ExportFrame.lua @@ -33,19 +33,25 @@ local function buildSections() { "Enchants", function() local ae = ce(); if ae then ae:Export("enchants") end end }, }}, { title = "Markdown (Wiki)", items = { - { "MD Gear", function() + { "MD Gear", function() local ae = ce() if ae and ae.GenerateMarkdownGear then showExport(ae:GenerateMarkdownGear() or "", "CoaExporter - Markdown Gear (Ctrl+C)") end end }, - { "MD Enchants", function() + { "MD Enchants", function() local ae = ce() if ae and ae.GenerateMarkdownEnchants then showExport(ae:GenerateMarkdownEnchants() or "", "CoaExporter - Markdown Enchants (Ctrl+C)") end end }, - { "MD Full", function() + { "MD Spellbook", function() + local ae = ce() + if ae and ae.GenerateMarkdownSpellbook then + showExport(ae:GenerateMarkdownSpellbook() or "", "CoaExporter - Markdown Spellbook (Ctrl+C)") + end + end }, + { "MD Full", function() local ae = ce() if ae and ae.GenerateMarkdownFull then showExport(ae:GenerateMarkdownFull() or "", "CoaExporter - Wiki Markdown (Ctrl+C)") diff --git a/README.md b/README.md index 5d89281..125a687 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ Primary slash: `/coae`. Aliases: `/coaexp`, `/ascx`, `/asxc`. /coae export mdgear Markdown gear table (Wiki.js) /coae export mdenchants Markdown enchants table -/coae export md Full wiki page (header + gear + enchants + talents) +/coae export mdspellbook Markdown spellbook (one section per tab) +/coae export md Full wiki page (header + gear + enchants + talents + spellbook) ``` ### Mystic scroll catalog (per-account, slow scan)