typedown 0.0.1
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/History.txt +4 -0
- data/Manifest.txt +13 -0
- data/README.rdoc +118 -0
- data/Rakefile +24 -0
- data/VERSION +1 -0
- data/bin/typedown +75 -0
- data/lib/typedown/document.rb +62 -0
- data/lib/typedown.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/data/example.tpd +21 -0
- data/test/test_helper.rb +3 -0
- data/test/test_typedown.rb +11 -0
- data/typedown.gemspec +60 -0
- metadata +97 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
= typedown
|
2
|
+
|
3
|
+
* http://github.com/wrimle/typedown
|
4
|
+
|
5
|
+
== DESCRIPTION
|
6
|
+
|
7
|
+
Typedown is a markdown dialect optimized for fast typing on mobile devices.
|
8
|
+
The typedown is basically a preprocessor that translates typedown to markdown,
|
9
|
+
for further processing by a markdown parser.
|
10
|
+
|
11
|
+
At the moment the typedown syntax is mainly tested with the iPod touch/iPhone iOS
|
12
|
+
4.0.1 keyboard. It takes into account looks at how easy it is to get to important
|
13
|
+
characters on the keyboard, as well as features like auto-capitalizing.
|
14
|
+
|
15
|
+
A typical typedown document will look like this:
|
16
|
+
|
17
|
+
|
18
|
+
! Heading
|
19
|
+
|
20
|
+
Exclamation mark is chosen because the
|
21
|
+
first word after it is auto-capitalized. And
|
22
|
+
it is easier to get to than the hash (#) in the
|
23
|
+
iPhone/iPod touch keyboard layout.
|
24
|
+
|
25
|
+
//. This is a bold paragraph
|
26
|
+
that might run through several lines
|
27
|
+
before ending in a double line break.
|
28
|
+
The dot ensuers the first word is
|
29
|
+
auto-capitalized.
|
30
|
+
|
31
|
+
/. This paragraph is italic.
|
32
|
+
|
33
|
+
Single words may be /italic/ or //bold//. Or you
|
34
|
+
may use standard _markdown italic_ and __bold__
|
35
|
+
for more flexibility. The slash syntax only
|
36
|
+
works for single words and whole words, because
|
37
|
+
the slash may have other uses.
|
38
|
+
|
39
|
+
!! Subheading
|
40
|
+
|
41
|
+
As typedown is a preprocessor, one is free
|
42
|
+
to use standard markdown. There is one exception
|
43
|
+
though. The dash will no longer create
|
44
|
+
bullet-lists.
|
45
|
+
|
46
|
+
- Why? you ask.
|
47
|
+
|
48
|
+
- It is used for dialogue instead.
|
49
|
+
|
50
|
+
- Why?
|
51
|
+
|
52
|
+
- I want typedown to be a tool for journalists and writers.
|
53
|
+
In some countries, including mine, this is a usual style for
|
54
|
+
writing dialogue both in newspapers, magazines and fiction.
|
55
|
+
|
56
|
+
- Ah! you say. - I get it.
|
57
|
+
|
58
|
+
The dash does not auto-capitalize, though. Because of this
|
59
|
+
there is an alternative syntax:
|
60
|
+
|
61
|
+
-. You may add dialogue like this.
|
62
|
+
|
63
|
+
-. That dot is ugly.
|
64
|
+
|
65
|
+
-. Yeah, I agree. But this actually is faster to type. Saves a lot of shifting.
|
66
|
+
|
67
|
+
-. On the iPod again, I guess.
|
68
|
+
|
69
|
+
-. How did you know? I ask.
|
70
|
+
|
71
|
+
You grin.
|
72
|
+
|
73
|
+
|
74
|
+
== FEATURES/PROBLEMS:
|
75
|
+
|
76
|
+
The preprocessor at present is not aware of CODE
|
77
|
+
blocks or similar, and will not leave your regexps
|
78
|
+
alone.
|
79
|
+
|
80
|
+
== REQUIREMENTS:
|
81
|
+
|
82
|
+
Typedown is presently using bluecloth as its markdown
|
83
|
+
parser.
|
84
|
+
|
85
|
+
== SYNOPSIS:
|
86
|
+
|
87
|
+
require 'typedown'
|
88
|
+
|
89
|
+
doc = Typedown::Document.new content
|
90
|
+
doc << "! More content\n"
|
91
|
+
puts doc.to_markdown
|
92
|
+
puts doc.to_html
|
93
|
+
|
94
|
+
|
95
|
+
== LICENSE:
|
96
|
+
|
97
|
+
(The MIT License)
|
98
|
+
|
99
|
+
Copyright (c) 2010 Rune Myrland
|
100
|
+
|
101
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
102
|
+
a copy of this software and associated documentation files (the
|
103
|
+
'Software'), to deal in the Software without restriction, including
|
104
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
105
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
106
|
+
permit persons to whom the Software is furnished to do so, subject to
|
107
|
+
the following conditions:
|
108
|
+
|
109
|
+
The above copyright notice and this permission notice shall be
|
110
|
+
included in all copies or substantial portions of the Software.
|
111
|
+
|
112
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
113
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
114
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
115
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
116
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
117
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
118
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/typedown'
|
6
|
+
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'jeweler'
|
10
|
+
Jeweler::Tasks.new do |gem|
|
11
|
+
gem.name = "typedown"
|
12
|
+
gem.summary = %Q{A markdown dialect optimized for fast typing on mobile devices}
|
13
|
+
gem.description = %Q{Typedown is a markdown preprocessor which forwards it's output to a markdown parser. Presently bluecloth}
|
14
|
+
gem.email = "rmyrland@gmail.com"
|
15
|
+
gem.homepage = "http://github.com/wrimle/typedown"
|
16
|
+
gem.authors = ["wrimle"]
|
17
|
+
gem.add_dependency('bluecloth','>= 2.0.7')
|
18
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
23
|
+
end
|
24
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/typedown
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# = newsdown
|
4
|
+
#
|
5
|
+
# Format one or more text files with the newsdown formatter.
|
6
|
+
# Typedown is a dialect of markdown optimized for typing on mobile devices.
|
7
|
+
#
|
8
|
+
# = Synopsis
|
9
|
+
#
|
10
|
+
# newsdown [OPTIONS] [FILES]
|
11
|
+
#
|
12
|
+
#
|
13
|
+
#
|
14
|
+
|
15
|
+
$: << "lib"
|
16
|
+
require 'typedown'
|
17
|
+
require 'optparse'
|
18
|
+
|
19
|
+
|
20
|
+
DocumentWrapper = %{
|
21
|
+
<html>
|
22
|
+
<head><title>%s</title></head>
|
23
|
+
<body>
|
24
|
+
%s
|
25
|
+
</body>
|
26
|
+
</html>
|
27
|
+
}
|
28
|
+
|
29
|
+
def main
|
30
|
+
fragment = false
|
31
|
+
|
32
|
+
ARGV.options do |oparser|
|
33
|
+
oparser.banner = "Usage: #$0 [OPTIONS] FILES"
|
34
|
+
|
35
|
+
# Debug mode
|
36
|
+
oparser.on( "--debug", "-d", TrueClass, "Turn debugging output on" ) {
|
37
|
+
$DEBUG = true
|
38
|
+
}
|
39
|
+
|
40
|
+
# 'Fragment' mode
|
41
|
+
oparser.on( "--fragment", "-f", TrueClass,
|
42
|
+
"Output HTML fragments instead of whole documents" ) {
|
43
|
+
fragment = true
|
44
|
+
}
|
45
|
+
|
46
|
+
oparser.parse!
|
47
|
+
end
|
48
|
+
|
49
|
+
# Filter mode if no arguments
|
50
|
+
ARGV.push( "-" ) if ARGV.empty?
|
51
|
+
|
52
|
+
ARGV.each {|file|
|
53
|
+
if file == '-'
|
54
|
+
contents = $stdin.read
|
55
|
+
else
|
56
|
+
contents = File::read( file )
|
57
|
+
end
|
58
|
+
|
59
|
+
nd = Typedown::Document.new( contents )
|
60
|
+
$stderr.puts "Using Typedown version #{Typedown::VERSION}"
|
61
|
+
|
62
|
+
if fragment
|
63
|
+
$stdout.puts nd.to_html
|
64
|
+
else
|
65
|
+
$stdout.puts DocumentWrapper % [ file, nd.to_html ]
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
69
|
+
rescue => err
|
70
|
+
$stderr.puts "Aborting: Fatal error: %s" % err.message
|
71
|
+
exit 255
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
main
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
#require 'kramdown'
|
3
|
+
require 'bluecloth'
|
4
|
+
|
5
|
+
module Typedown
|
6
|
+
class Document < String
|
7
|
+
def initialize text = nil
|
8
|
+
super ""
|
9
|
+
self << text if text
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_markdown
|
13
|
+
text = self
|
14
|
+
|
15
|
+
# Translate '! headings' to '# headings'
|
16
|
+
text.gsub!(/^! /, "# ")
|
17
|
+
text.gsub!(/^!! /, "## ")
|
18
|
+
text.gsub!(/^!!! /, "### ")
|
19
|
+
text.gsub!(/^!!!! /, "#### ")
|
20
|
+
text.gsub!(/^!!!!! /, "##### ")
|
21
|
+
text.gsub!(/^!!!!!! /, "###### ")
|
22
|
+
|
23
|
+
# Dialogue dashes
|
24
|
+
text.gsub!(/^-\.? /, "― ")
|
25
|
+
text.gsub!(/\s-\.? /, " ― ")
|
26
|
+
|
27
|
+
# Insert placeholders around lead in
|
28
|
+
text.gsub!(/^\. (( *[^\n].+\n)*)/, "! x!\\1!x-!\n")
|
29
|
+
# Remove placeholders while using them to remove whitespace
|
30
|
+
text.gsub!(/^! x!\s*/, "**")
|
31
|
+
text.gsub!(/\s*!x-!$/, "**")
|
32
|
+
|
33
|
+
|
34
|
+
# Insert placeholders around lead in
|
35
|
+
text.gsub!(/^\/\/\. (( *[^\n].+\n)*)/, "! x!\\1!x-!\n")
|
36
|
+
# Remove placeholders while using them to remove whitespace
|
37
|
+
text.gsub!(/^! x!\s*/, "**")
|
38
|
+
text.gsub!(/\s*!x-!$/, "**")
|
39
|
+
|
40
|
+
|
41
|
+
# Insert placeholders around lead in
|
42
|
+
text.gsub!(/^\/\. (( *[^\n].+\n)*)/, "! x!\\1!x-!\n")
|
43
|
+
# Remove placeholders while using them to remove whitespace
|
44
|
+
text.gsub!(/^! x!\s*/, "*")
|
45
|
+
text.gsub!(/\s*!x-!$/, "*")
|
46
|
+
|
47
|
+
# Slash for _
|
48
|
+
text.gsub!(/(\s)\/(\S+)\/(\s)[\.\,\?\!]?/, "\\1_\\2_\\3")
|
49
|
+
text.gsub!(/(\s)\/\/(\S+)\/\/[\.\,\?\!]?(\s)/, "\\1__\\2__\\3")
|
50
|
+
text.gsub!(/(\s)\/\/\/(\S+)\/\/\/[\.\,\?\!]?(\s)/, "\\1___\\2___\\3")
|
51
|
+
text
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def to_html
|
56
|
+
#kramdown = Kramdown::Document.new to_markdown
|
57
|
+
#kramdown.to_html
|
58
|
+
bluecloth = BlueCloth::new( to_markdown )
|
59
|
+
bluecloth.to_html
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/typedown.rb
ADDED
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/typedown.rb'}"
|
9
|
+
puts "Loading typedown gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
! Heading
|
2
|
+
|
3
|
+
//. A lead-in saying what the article is about.
|
4
|
+
Some more lead-in.
|
5
|
+
And more.
|
6
|
+
|
7
|
+
Some body copy.
|
8
|
+
|
9
|
+
!! Subheading
|
10
|
+
|
11
|
+
More body copy.
|
12
|
+
|
13
|
+
- Dialogue like this, he said. - I tell you.
|
14
|
+
|
15
|
+
- Oh, yeah?
|
16
|
+
|
17
|
+
More body copy. Standard markdown /italic/ and //bold//.
|
18
|
+
|
19
|
+
!! Another subheading
|
20
|
+
|
21
|
+
And body copy again.
|
data/test/test_helper.rb
ADDED
data/typedown.gemspec
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{typedown}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["wrimle"]
|
12
|
+
s.date = %q{2010-08-13}
|
13
|
+
s.default_executable = %q{typedown}
|
14
|
+
s.description = %q{Typedown is a markdown preprocessor which forwards it's output to a markdown parser. Presently bluecloth}
|
15
|
+
s.email = %q{rmyrland@gmail.com}
|
16
|
+
s.executables = ["typedown"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"History.txt",
|
22
|
+
"Manifest.txt",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"bin/typedown",
|
27
|
+
"lib/typedown.rb",
|
28
|
+
"lib/typedown/document.rb",
|
29
|
+
"script/console",
|
30
|
+
"script/destroy",
|
31
|
+
"script/generate",
|
32
|
+
"test/data/example.tpd",
|
33
|
+
"test/test_helper.rb",
|
34
|
+
"test/test_typedown.rb",
|
35
|
+
"typedown.gemspec"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/wrimle/typedown}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
41
|
+
s.summary = %q{A markdown dialect optimized for fast typing on mobile devices}
|
42
|
+
s.test_files = [
|
43
|
+
"test/test_helper.rb",
|
44
|
+
"test/test_typedown.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<bluecloth>, [">= 2.0.7"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<bluecloth>, [">= 2.0.7"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<bluecloth>, [">= 2.0.7"])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: typedown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- wrimle
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-13 00:00:00 +02:00
|
19
|
+
default_executable: typedown
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bluecloth
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 7
|
34
|
+
version: 2.0.7
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Typedown is a markdown preprocessor which forwards it's output to a markdown parser. Presently bluecloth
|
38
|
+
email: rmyrland@gmail.com
|
39
|
+
executables:
|
40
|
+
- typedown
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README.rdoc
|
45
|
+
files:
|
46
|
+
- History.txt
|
47
|
+
- Manifest.txt
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- bin/typedown
|
52
|
+
- lib/typedown.rb
|
53
|
+
- lib/typedown/document.rb
|
54
|
+
- script/console
|
55
|
+
- script/destroy
|
56
|
+
- script/generate
|
57
|
+
- test/data/example.tpd
|
58
|
+
- test/test_helper.rb
|
59
|
+
- test/test_typedown.rb
|
60
|
+
- typedown.gemspec
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://github.com/wrimle/typedown
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --charset=UTF-8
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.3.7
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: A markdown dialect optimized for fast typing on mobile devices
|
95
|
+
test_files:
|
96
|
+
- test/test_helper.rb
|
97
|
+
- test/test_typedown.rb
|