Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit f73b57b079174cecaa6af07936712944af91bc68 1 parent 255b6e1
@gpr authored
View
18 README
@@ -1,7 +1,5 @@
# Redmine Asciidoc Formatter
-## Notes
-
## Installation
See redmine plugin installation howto.
@@ -9,7 +7,21 @@ 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
View
5 app/helpers/redmine_asciidoc_formatter/helper.rb
@@ -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
View
15 lib/redmine_asciidoc_formatter/wiki_formatter.rb
@@ -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"+
Please sign in to comment.
Something went wrong with that request. Please try again.