color: $linkVisitedColor;
}
-//
-// Pandoc specific HTML
-//
-
#TOC {
- //ul {
- // list-style-type: decimal;
- // }
+ margin-top: 1em;
+ margin-bottom: 1em;
ul {
list-style-type: none;
- counter-reset: level1;
- }
- ul li:before {
- content: counter(level1) ". ";
- counter-increment: level1;
- }
- ul li ul {
- list-style-type: none;
- counter-reset: level2;
+ margin: 0;
}
- ul li ul li:before {
- content: counter(level1) "." counter(level2) " ";
- counter-increment: level2;
+ li ul {
+ margin-left: 25px;
}
+ // ul {
+ // list-style-type: none;
+ // counter-reset: level1;
+ // }
+ // ul li:before {
+ // content: counter(level1) ". ";
+ // counter-increment: level1;
+ // }
+ // ul li ul {
+ // list-style-type: none;
+ // counter-reset: level2;
+ // }
+ // ul li ul li:before {
+ // content: counter(level1) "." counter(level2) " ";
+ // counter-increment: level2;
+ // }
}
-a[href="#TOC"] {
- color: black;
- pointer-events: none;
- cursor: default;
- &:hover {
- text-decoration: none;
- }
-}
+//
+// pandoc specific
+//
+// a[href="#TOC"] {
+// color: black;
+// pointer-events: none;
+// cursor: default;
+// &:hover {
+// text-decoration: none;
+// }
+// }
require 'i18n'
require 'pathname'
require 'RedCloth'
-require 'pandoc-ruby'
-require 'iconv'
+require 'rbst'
+require 'rdiscount'
+
+#require 'pandoc-ruby'
+#require 'iconv'
class StaticPage
attr_accessor :path, :children, :name, :file_path, :props, :parent, :mount_point, :locales
def render_content_file(content_file, locale)
content = File.read(content_file).sub(PROPERTY_HEADER, '')
suffix = File.extname(content_file)
- if PANDOC_FORMATS[suffix]
- render_pandoc(content, suffix, locale)
- elsif REDCLOTH_FORMATS[suffix]
+ #if PANDOC_FORMATS[suffix]
+ # render_pandoc(content, suffix, locale)
+ if REDCLOTH_FORMATS[suffix]
render_redcloth(content, suffix, locale)
+ elsif RBST_FORMATS[suffix]
+ render_rbst(content, suffix, locale)
+ elsif RDISCOUNT_FORMATS[suffix]
+ render_rdiscount(content, suffix, locale)
else
"sorry, i don't understand how to render #{suffix}"
end
@suffix == '.haml' || File.exists?(self.absolute_template_path(locale) + '.haml')
end
- PANDOC_FORMATS = {
- '.md' => :markdown,
- '.markdown' => :markdown,
- #'.txt' => :textile,
- #'.textile' => :textile,
- '.rst' => :rst,
- '.latex' => :latex,
- '.pandoc' => :pandoc,
+ #PANDOC_FORMATS = {
+ # '.md' => :markdown,
+ # '.markdown' => :markdown,
+ # #'.txt' => :textile,
+ # #'.textile' => :textile,
+ # '.rst' => :rst,
+ # '.latex' => :latex,
+ # '.pandoc' => :pandoc,
+ #}
+
+ #def render_pandoc(string, suffix, locale)
+ # string = Iconv.conv("UTF-8//IGNORE", "UTF-8", string) # remove illegal utf-8
+ # args = [string, {:from => PANDOC_FORMATS[suffix], :to => :html}, "smart"]
+ # if props.locale(locale).toc != false
+ # args << "table_of_contents"
+ # args << {"template" => "'#{File.dirname(__FILE__) + '/template.html'}'"}
+ # end
+ # unless (title = explicit_title(locale)).nil?
+ # args << {"variable" => "title:'#{title}'"}
+ # end
+ # renderer = PandocRuby.new(*args)
+ # renderer.convert
+ #end
+
+ RBST_FORMATS = {
+ '.rst' => :rst
}
- def render_pandoc(string, suffix, locale)
- string = Iconv.conv("UTF-8//IGNORE", "UTF-8", string) # remove illegal utf-8
- args = [string, {:from => PANDOC_FORMATS[suffix], :to => :html}, "smart"]
- if props.locale(locale).toc != false
- args << "table_of_contents"
- args << {"template" => "'#{File.dirname(__FILE__) + '/template.html'}'"}
- end
+ def render_rbst(string, suffix, locale)
+ html = RbST.new(string).to_html
unless (title = explicit_title(locale)).nil?
- args << {"variable" => "title:'#{title}'"}
+ html = "<h1 class=\"first\">#{title}</h1>\n\n" + html
end
- renderer = PandocRuby.new(*args)
- renderer.convert
+ return html
end
- #
- # pandoc can do textile, but it does it HORRIBLY
- #
REDCLOTH_FORMATS = {
'.txt' => :textile,
- '.textile' => :textile,
+ '.textile' => :textile
}
def render_redcloth(string, suffix, locale)
unless (title = explicit_title(locale)).nil?
- string = "h1. #{title}\n\n" + string
+ string = "h1(first). #{title}\n\n" + string
end
RedCloth.new(string).to_html
end
+ RDISCOUNT_FORMATS = {
+ '.md' => :markdown,
+ '.markdown' => :markdown
+ }
+
+ def render_rdiscount(string, suffix, locale)
+ rd = RDiscount.new(string, :smart, :generate_toc, :autolink)
+ html = rd.to_html
+ if props.locale(locale).toc != false && rd.toc_content
+ html = "<div id=\"TOC\">%s</div>\n\n%s" % [rd.toc_content, html]
+ end
+ unless (title = explicit_title(locale)).nil?
+ html = "<h1 class=\"first\">#{title}</h1>\n\n" + html
+ end
+ return html
+ end
+
#
# returns title iff explicitly set.
#