Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
76ae9e07
Commit
76ae9e07
authored
Oct 07, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting doc to be easier to convert to wiki format
parent
fcef9938
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
316 additions
and
178 deletions
+316
-178
README.textile
README.textile
+233
-178
Gemfile
test/Gemfile
+1
-0
Gemfile.lock
test/Gemfile.lock
+2
-0
Rakefile
test/Rakefile
+80
-0
No files found.
README.textile
View file @
76ae9e07
This diff is collapsed.
Click to expand it.
test/Gemfile
View file @
76ae9e07
...
@@ -20,4 +20,5 @@ end
...
@@ -20,4 +20,5 @@ end
group
:docs
do
group
:docs
do
gem
'github-markup'
gem
'github-markup'
gem
'RedCloth'
gem
'RedCloth'
gem
'nokogiri'
end
end
test/Gemfile.lock
View file @
76ae9e07
...
@@ -28,6 +28,7 @@ GEM
...
@@ -28,6 +28,7 @@ GEM
linecache (0.43)
linecache (0.43)
linecache19 (0.5.11)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
ruby_core_source (>= 0.1.4)
nokogiri (1.5.0)
open4 (1.0.1)
open4 (1.0.1)
rack (1.3.2)
rack (1.3.2)
rake (0.8.7)
rake (0.8.7)
...
@@ -71,6 +72,7 @@ DEPENDENCIES
...
@@ -71,6 +72,7 @@ DEPENDENCIES
github-markup
github-markup
jasmine (= 1.0.2.1)
jasmine (= 1.0.2.1)
json (= 1.4.3)
json (= 1.4.3)
nokogiri
rake
rake
ruby-debug
ruby-debug
ruby-debug19
ruby-debug19
test/Rakefile
View file @
76ae9e07
...
@@ -17,6 +17,86 @@ namespace :docs do
...
@@ -17,6 +17,86 @@ namespace :docs do
puts
"Preview rendered to
#{
output
}
"
puts
"Preview rendered to
#{
output
}
"
end
end
end
end
desc
"Convert docs to Nginx wiki format."
task
:convert_to_wiki
do
require
'redcloth'
require
'nokogiri'
file
=
"
#{
base_dir
}
/README.textile"
puts
file
filename
=
File
.
basename
(
file
)
readme
=
File
.
read
(
file
)
File
.
open
(
"
#{
base_dir
}
/misc/
#{
filename
}
.html"
,
'w'
)
{
|
f
|
f
.
write
(
RedCloth
.
new
(
readme
).
to_html
)
}
output
=
"
#{
base_dir
}
/misc/
#{
filename
}
.wiki"
File
.
open
(
output
,
'w'
)
{
|
f
|
f
.
write
(
convert_to_wiki_syntax
(
readme
))
}
puts
"Preview rendered to
#{
output
}
"
end
def
convert_to_wiki_syntax
(
text
)
doc
=
Nokogiri
::
HTML
(
RedCloth
.
new
(
text
).
to_html
)
convert_elements
(
doc
.
children
.
to_a
)
end
def
convert_elements
(
nodes
)
result
=
""
nodes
.
each
do
|
node
|
if
node
.
element?
&&
!
node
.
text?
childrens
=
node
.
children
.
to_a
unless
childrens
.
empty?
result
+=
convert_element
(
convert_elements
(
childrens
),
node
)
end
elsif
node
.
text?
result
+=
node
.
text
end
end
result
end
def
convert_element
(
text
,
node
)
tag
=
node
.
name
text
||=
""
case
tag
when
"strong"
"'''
#{
text
}
'''"
when
"b"
"'''
#{
text
}
'''"
when
"em"
"''
#{
text
}
''"
when
"h1"
"
\n
=
#{
text
}
="
when
"h2"
"
\n
==
#{
text
}
=="
when
"h3"
"
\n
===
#{
text
}
==="
when
"h4"
"
\n
====
#{
text
}
===="
when
"h5"
"
\n
=====
#{
text
}
====="
when
"h6"
"
\n
======
#{
text
}
======"
when
"p"
"
\n
#{
text
}
"
when
"a"
if
node
.
attributes
[
'href'
].
value
.
start_with?
(
"#"
)
"[[
#{
node
.
attributes
[
'href'
].
value
}
|
#{
text
}
]]"
else
"[
#{
node
.
attributes
[
'href'
].
value
}
#{
text
}
]"
end
when
"html"
text
when
"body"
text
when
"span"
text
else
"<
#{
tag
}
>
#{
text
}
</
#{
tag
}
>"
end
end
end
end
desc
"Run all tests."
desc
"Run all tests."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment