any2html 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/any2html.gemspec +1 -1
- data/bin/any2html +2 -2
- data/lib/textile_extensions.rb +63 -0
- metadata +2 -1
data/any2html.gemspec
CHANGED
data/bin/any2html
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'active_support/core_ext/object/inclusion'
|
2
|
+
|
3
|
+
module RailsGuides
|
4
|
+
module TextileExtensions
|
5
|
+
def notestuff(body)
|
6
|
+
# The following regexp detects special labels followed by a
|
7
|
+
# paragraph, perhaps at the end of the document.
|
8
|
+
#
|
9
|
+
# It is important that we do not eat more than one newline
|
10
|
+
# because formatting may be wrong otherwise. For example,
|
11
|
+
# if a bulleted list follows the first item is not rendered
|
12
|
+
# as a list item, but as a paragraph starting with a plain
|
13
|
+
# asterisk.
|
14
|
+
body.gsub!(/^(TIP|IMPORTANT|CAUTION|WARNING|NOTE|INFO)[.:](.*?)(\n(?=\n)|\Z)/m) do |m|
|
15
|
+
css_class = case $1
|
16
|
+
when 'CAUTION', 'IMPORTANT'
|
17
|
+
'warning'
|
18
|
+
when 'TIP'
|
19
|
+
'info'
|
20
|
+
else
|
21
|
+
$1.downcase
|
22
|
+
end
|
23
|
+
%Q(<div class="#{css_class}"><p>#{$2.strip}</p></div>)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def plusplus(body)
|
28
|
+
body.gsub!(/\+(.*?)\+/) do |m|
|
29
|
+
"<notextile><tt>#{$1}</tt></notextile>"
|
30
|
+
end
|
31
|
+
|
32
|
+
# The real plus sign
|
33
|
+
body.gsub!('<plus>', '+')
|
34
|
+
end
|
35
|
+
|
36
|
+
def brush_for(code_type)
|
37
|
+
case code_type
|
38
|
+
when 'ruby', 'sql', 'plain'
|
39
|
+
code_type
|
40
|
+
when 'erb'
|
41
|
+
'ruby; html-script: true'
|
42
|
+
when 'html'
|
43
|
+
'xml' # html is understood, but there are .xml rules in the CSS
|
44
|
+
else
|
45
|
+
'plain'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def code(body)
|
50
|
+
body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql|plain)>(.*?)</\1>}m) do |m|
|
51
|
+
<<HTML
|
52
|
+
<notextile>
|
53
|
+
<div class="code_container">
|
54
|
+
<pre class="brush: #{brush_for($1)}; gutter: false; toolbar: false">
|
55
|
+
#{ERB::Util.h($2).strip}
|
56
|
+
</pre>
|
57
|
+
</div>
|
58
|
+
</notextile>
|
59
|
+
HTML
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: any2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- any2html.gemspec
|
74
74
|
- bin/any2html
|
75
75
|
- lib/any2html.rb
|
76
|
+
- lib/textile_extensions.rb
|
76
77
|
homepage: http://github.com/danchoi/any2html
|
77
78
|
licenses: []
|
78
79
|
post_install_message:
|