Comments for Textile text formatting
|Assignee:||Go MAEDA||% Done:|
Developing and maintaining a wiki page I often would like to add some hidden commentary which does not show in formatted view.
I think there is no way to do this at the moment. Code for Textile Comments is filtered and does not work.
Disfunctional Textile examples:
I know there is a plugin for this. I hope it will be made a core functionality soon. Cheers!
#2 Updated by Joel SCHAAL over 5 years ago
I stumbled across the same issue today, and wondered what I was doing wrong.
This marks Textile as not fully supported by Redmine for me (contrarily to what is written here: Wiki formatting > Text formatting).
Is Textile going to be abandoned in favor of Markdown ? I guess this issue would then be obsolete...
CommonMark Markdown (#32424) that is going to be introduced in Redmine 5.0.0 supports HTML comments. I think it would be nice if Textile supports HTML comments as well.
The following code adds HTML comments support to the Textile formatter.
diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index 2816e1c90..274f9cef8 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -298,6 +298,7 @@ class RedCloth3 < String @pre_list =  rip_offtags text no_textile text + clean_html_comment text escape_html_tags text # need to do this before #hard_break and #blocks block_textile_quotes text unless @lite_mode @@ -1217,4 +1218,8 @@ class RedCloth3 < String end end end + + def clean_html_comment(text) + text.gsub!(/^<!--[\s\S]*?-->$/, '') + end end
- File 20511.patch added
- Target version set to Candidate for next major release
Here is a patch.
HTML comments in Textile are escaped since r1403. This patch may appear to roll back that change, but I think it is not a problem. This is because the purpose of the change is to prevent mistakenly entered unclosed comments from affecting page rendering (see #1160) and unclosed comments are still escaped even after applying the patch. It is ensured by the test source:trunk/test/helpers/application_helper_test.rb@21440#L1304.