Edited: All the plugin category pages to add plugin descriptions
This uses descriptions extracted from the plugin pages themselves. This was @claremacrae's excellent idea since it retains any descriptions for plugins that are no longer present in the json feed.
This is intended as a one-time manual content adjustment. It was scripted to produce, but these areas of the category pages appear to be manually curated by humans, not machine generated, so I hesitate to introduce anything that manipulates them. Because of that the code that generates this is very strict and only manipulates lines that appear to be exactly a link to the target plugin page. There are a few examples where descriptions are not present or where the link line has been edited -- these lines have all been left exactly as they were. For example in the discontinued plugins page
- [[obsidian-extra-md-commands|Extra Markdown Commands]] (use [[obsidian-smarter-md-hotkeys|Smarter Markdown Hotkeys]] instead.)
Additionally this PR does not add descriptions to the uncategorized plugins page, as that has been automated in the related PR #551
This is another step in the overall progression of encouraging descriptions on all the plugin pages as described in #343
Code
Please forgive that this is not in python. As a throw-away one-time script I did it in the language that I know best. If we end up pursuing some ongoing automation, of course it will be in python. This script is meant to run in the root of the repository.
#!/usr/bin/env ruby
descriptions_hash = {} # key: page_name, value: description
Dir["02 - Community Expansions/02.05 All Community Expansions/Plugins/*.md"].map do |plugin_page_path|
contents = File.read(plugin_page_path)
if contents =~ /Mobile compatible: .*\n\n(.*)\n\n%% -----/
descriptions_hash[File.basename(plugin_page_path, '.md')] = $1&.strip
end
end
Dir["02 - Community Expansions/02.01 Plugins by Category/*.md"].each do |category_page_path|
contents = File.readlines(category_page_path)
in_list = false
out_list = false
new_contents = contents.map do |line|
out_list = true if in_list && line =~ /^## /
in_list = true if line =~ /^## Plugins in this category/
if in_list && !out_list
if line =~ /^- \[\[(.*?)(?:\|(.*)){0,1}\]\]\s*\n$/
page_name, link_alias = $1, $2
p page_name: page_name, link_alias: link_alias, line: line
description = descriptions_hash[page_name]
if !description.nil?
"- [[#{page_name}|#{link_alias}]]: #{description}\n"
else
line # no description, leave it alone.
end
else
line # leave the line alone.
end
else
line
end
end
File.write(category_page_path, new_contents.join)
end