Permalink
Browse files

Adds support of macros and wiki links and makes ToC insertion optional

The default Redmine syntax for wiki link insertion is replaced by the following
new one; `wiki:<WikiPageName>` where `<WikiPageName>` is the name of the linked
wiki page.

To include the ToC add `:toc:` in the wiki page.
  • Loading branch information...
1 parent 255b6e1 commit f73b57b079174cecaa6af07936712944af91bc68 @gpr committed Sep 27, 2010
Showing with 31 additions and 7 deletions.
  1. +15 −3 README
  2. +3 −2 app/helpers/redmine_asciidoc_formatter/helper.rb
  3. +13 −2 lib/redmine_asciidoc_formatter/wiki_formatter.rb
View
18 README
@@ -1,15 +1,27 @@
# Redmine Asciidoc Formatter
-## Notes
-
## Installation
See redmine plugin installation howto.
This plugin requires asciidoc (sudo apt-get install asciidoc).
You should also install pygments (sudo apt-get install python-pygments) and
-source-highlight (sudo apt-get install source-highlight)
+source-highlight (sudo apt-get install source-highlight).
+
+## Documentation
+
+The formattter supports all asciidoc standard syntaxes. It supports also Redmine macros
+( `{{Macro()}}`, automatic links (#<ID>, source:<path/to/file>, commit:<ref>...) and also a
+new syntax for wiki links:
+ wiki:<WikiPageName> where <WikiPageName> is the name of the linked wiki page.
+
+## Known Limitations
+
+The inclusion of the ToC is automatic but that causes a issue; the ToC is included
+everywhere, even for issue descriptions and project summaries.
+
+The ToC is sometimes not generated (no root cause identified).
## Notes
@@ -18,11 +18,12 @@ def wikitoolbar_for(field_id)
end
def initial_page_content(page)
- "#{'='*page.pretty_title.length}\n#{page.pretty_title}\n#{'='*page.pretty_title.length}"
+ "#{page.pretty_title}\n#{'='*page.pretty_title.length}"
end
def heads_for_wiki_formatter
- stylesheet_link_tag('asciidoc-xhtml11', :plugin => 'redmine_asciidoc_formatter') +
+ stylesheet_link_tag('jstoolbar') +
+ stylesheet_link_tag('asciidoc-xhtml11', :plugin => 'redmine_asciidoc_formatter') +
javascript_include_tag('toc-footnote', :plugin => 'redmine_asciidoc_formatter') +
javascript_include_tag('asciidoc-xhtml11', :plugin => 'redmine_asciidoc_formatter')
end
@@ -9,9 +9,20 @@ def initialize(text)
end
def to_html(&block)
+ arg = ""
+
+ @text.gsub!(/([\{\}]){2}/, '%%\1%%')
+
+ if @text.match(':toc:')
+ arg = "-a toc "
+ end
+
conf = File.join(RAILS_ROOT,'vendor','plugins','redmine_asciidoc_formatter','lib','redmine_asciidoc_formatter','redmine.conf')
- arg = "--conf-file="+conf
- AsciiDoc.new(@text).to_html(arg)
+ arg += "--conf-file="+conf
+
+ html = AsciiDoc.new(@text).to_html(arg)
+ html.gsub!(/%%([\{\}])%%/,'\1\1')
+ html.gsub(/wiki:(\w+(\/\w+)*)/, '[[\1]]')
rescue => e
return("<pre>problem parsing wiki text: #{e.message}\n"+
"original text: \n"+

0 comments on commit f73b57b

Please sign in to comment.