I’m working on a markdown plugin and I’m having trouble adding a site setting to allow you to disable the feature. I wrote the plugin by following the structure of Discourse footnote, which has a setting allowing you to disable that plugin. I installed the footnote plugin and verified that it can be disabled from the UI and that its corresponding test passes. However, disabling my plugin from the site settings has no effect, and the unit test confirms this by failing.
I’m not sure what I’m doing differently compared to the footnote plugin. It’s possible my usage of opts.features
is completely wrong or making bad assumptions, because like pretty much everywhere else I just replaced “footnotes” with “ruby”. Any help would be appreciated.
The repo is here: https://github.com/seanblue/discourse-ruby
Key aspects related to the site setting would include:
https://github.com/seanblue/discourse-ruby/blob/master/config/settings.yml#L1-L4
https://github.com/seanblue/discourse-ruby/blob/master/plugin.rb#L9
And this is the test that keeps failing (not in the repo yet):
it "can be disabled" do
SiteSetting.enable_markdown_ruby = false
markdown = <<~MD
Here is some text: {漢字|かん|じ}.
MD
html = <<~HTML
<p>Here is some text: {漢字|かん|じ}.</p>
HTML
cooked = PrettyText.cook markdown.strip
expect(cooked).to eq(html.strip)
end
Not surprisingly, the failure says it’s getting the cooked text as if the markdown still applied.
expected: "<p>Here is some text: {漢字|かん|じ}.</p>"
got: "<p>Here is some text: <ruby>漢<rt>かん</rt>字<rt>じ</rt></ruby>.</p>"