kramdown-man 0.1.3 → 0.1.8
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.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +32 -0
- data/.gitignore +1 -0
- data/ChangeLog.md +29 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +9 -8
- data/Rakefile +12 -34
- data/gemspec.yml +2 -4
- data/lib/kramdown/converter/man.rb +399 -27
- data/lib/kramdown/man.rb +3 -2
- data/lib/kramdown/man/task.rb +1 -1
- data/lib/kramdown/man/version.rb +1 -1
- data/man/kramdown-man.1 +43 -36
- data/man/kramdown-man.1.md +6 -2
- data/spec/kramdown/converter/man_spec.rb +180 -97
- data/spec/kramdown/document_spec.rb +19 -0
- data/spec/kramdown/man_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -1
- metadata +23 -60
- data/.travis.yml +0 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 164ce0fc23aa69a61fb65b7c99d26e76a9ab76fc798962f06940412bb1dcbcfd
|
4
|
+
data.tar.gz: 2161ba26365fe958c5a0b5f063706dfe7566d9c1213cb6f84bc63b50dfae4030
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54bd2ea4c4b967a5af505900f6ea8f02edb00900f6e5e6d67d1c015e776e602fe81d1dc641c62f2d7b614fecb224b3cc6003330b38eaa322f80b7296ee96850c
|
7
|
+
data.tar.gz: 28a7d09d3e41e9f108c2a73e966d9ecf31a4343b98b4452c23eab9978b7af77f8ec63a2b870726bb2c39cd0ecd0490fd922ea4e389716c4863fb68fe02dafa3e
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: ['**']
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby:
|
16
|
+
- 2.4
|
17
|
+
- 2.5
|
18
|
+
- 2.6
|
19
|
+
- 2.7
|
20
|
+
- 3.0
|
21
|
+
- jruby
|
22
|
+
name: Ruby ${{ matrix.ruby }}
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v2
|
25
|
+
- name: Set up Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby }}
|
29
|
+
- name: Install dependencies
|
30
|
+
run: bundle install --jobs 4 --retry 3
|
31
|
+
- name: Run tests
|
32
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
### 0.1.8 / 2020-12-26
|
2
|
+
|
3
|
+
* Upgrade to kramdown 2.x.
|
4
|
+
|
5
|
+
### 0.1.7 / 2020-07-22
|
6
|
+
|
7
|
+
* Fixed a bug where kramdown's version of `kramdown/converter/man` was being
|
8
|
+
loaded instead of kramdown-man's version.
|
9
|
+
|
10
|
+
### 0.1.6 / 2015-12-25
|
11
|
+
|
12
|
+
* Commented out duplicate Hash entries that were causing warnings.
|
13
|
+
|
14
|
+
### 0.1.5 / 2013-05-19
|
15
|
+
|
16
|
+
* Translate unicode symbols into roff glyphs.
|
17
|
+
* Convert typographic symbols and smart quotes into glyphs.
|
18
|
+
* Simplify `\fB\fC` as `\fC` (Colin Watson).
|
19
|
+
* Use `\fB` for codespans (Colin Watson).
|
20
|
+
* Escape `--` as `\-\-` (Colin Watson).
|
21
|
+
* Escape `\` as `\e` (Colin Watson).
|
22
|
+
* Emit `.TP` or `.HP` if the paragraph begins with a strong element.
|
23
|
+
|
24
|
+
### 0.1.4 / 2013-05-05
|
25
|
+
|
26
|
+
* Improve detection of tagged paragraphs.
|
27
|
+
* Support emitted a hanging paragraph (`.HP`) for command synopsis lines.
|
28
|
+
* Strip leading whitespace from each line of emitted text.
|
29
|
+
|
1
30
|
### 0.1.3 / 2013-05-05
|
2
31
|
|
3
32
|
* Initial release:
|
data/Gemfile
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -5,8 +5,6 @@
|
|
5
5
|
* [Documentation](http://rubydoc.info/gems/kramdown-man/frames)
|
6
6
|
* [Email](mailto:postmodern.mod3 at gmail.com)
|
7
7
|
|
8
|
-
[](https://travis-ci.org/postmodern/kramdown-man)
|
9
|
-
|
10
8
|
## Description
|
11
9
|
|
12
10
|
A [Kramdown][kramdown] convert for converting Markdown files into man pages.
|
@@ -15,14 +13,14 @@ A [Kramdown][kramdown] convert for converting Markdown files into man pages.
|
|
15
13
|
|
16
14
|
* Converts markdown to [roff]:
|
17
15
|
* Supports codespans, emphasis and strong fonts.
|
18
|
-
* Supports normal and tagged paragraphs.
|
16
|
+
* Supports normal, hanging and tagged paragraphs.
|
19
17
|
* Supports bullet lists.
|
20
18
|
* Supports multi-paragraph list items and blockquotes.
|
21
19
|
* Supports horizontal rules.
|
22
20
|
* Supports converting `[bash](man:bash(1))` links into man page references.
|
23
21
|
* Provides Rake task for converting `man/*.md` into man pages.
|
24
22
|
* Uses the pure-Ruby [Kramdown][kramdown] markdown parser.
|
25
|
-
* Supports [Ruby]
|
23
|
+
* Supports [Ruby] 2.0 and [JRuby].
|
26
24
|
|
27
25
|
## Synopsis
|
28
26
|
|
@@ -69,6 +67,10 @@ Define a `man` and file tasks which render all `*.md` files within the
|
|
69
67
|
|
70
68
|
Normal paragraph.
|
71
69
|
|
70
|
+
`command` [`--foo`] *FILE*
|
71
|
+
|
72
|
+
`command` [`--foo`] *FILE*
|
73
|
+
|
72
74
|
`--tagged`
|
73
75
|
Text here.
|
74
76
|
|
@@ -152,7 +154,7 @@ Email <bob@example.com>
|
|
152
154
|
|
153
155
|
## Requirements
|
154
156
|
|
155
|
-
* [kramdown] ~>
|
157
|
+
* [kramdown] ~> 2.0
|
156
158
|
|
157
159
|
## Install
|
158
160
|
|
@@ -166,13 +168,12 @@ Email <bob@example.com>
|
|
166
168
|
|
167
169
|
## Copyright
|
168
170
|
|
169
|
-
Copyright (c) 2013 Hal Brodigan
|
171
|
+
Copyright (c) 2013-2020 Hal Brodigan
|
170
172
|
|
171
173
|
See {file:LICENSE.txt} for details.
|
172
174
|
|
173
|
-
[kramdown]: http://kramdown.
|
175
|
+
[kramdown]: http://kramdown.gettalong.org/
|
174
176
|
[roff]: http://en.wikipedia.org/wiki/Roff
|
175
177
|
|
176
178
|
[Ruby]: http://www.ruby-lang.org/
|
177
179
|
[JRuby]: http://jruby.org/
|
178
|
-
[Rubinius]: http://rubini.us/
|
data/Rakefile
CHANGED
@@ -1,45 +1,23 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rake'
|
5
|
-
|
6
3
|
begin
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Gem::Tasks.new
|
11
|
-
rescue LoadError => e
|
12
|
-
warn e.message
|
13
|
-
warn "Run `gem install rubygems-tasks` to install Gem::Tasks."
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError => error
|
6
|
+
abort error.message
|
14
7
|
end
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
RSpec::Core::RakeTask.new
|
21
|
-
rescue LoadError => e
|
22
|
-
task :spec do
|
23
|
-
abort "Please run `gem install rspec` to install RSpec."
|
24
|
-
end
|
25
|
-
end
|
9
|
+
require 'rake'
|
10
|
+
require 'rubygems/tasks'
|
11
|
+
Gem::Tasks.new
|
26
12
|
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
RSpec::Core::RakeTask.new
|
27
15
|
task :test => :spec
|
28
16
|
task :default => :spec
|
29
17
|
|
30
|
-
|
31
|
-
|
32
|
-
require 'yard'
|
33
|
-
|
34
|
-
YARD::Rake::YardocTask.new
|
35
|
-
rescue LoadError => e
|
36
|
-
task :yard do
|
37
|
-
abort "Please run `gem install yard` to install YARD."
|
38
|
-
end
|
39
|
-
end
|
18
|
+
require 'yard'
|
19
|
+
YARD::Rake::YardocTask.new
|
40
20
|
task :doc => :yard
|
41
21
|
|
42
|
-
|
43
|
-
|
44
|
-
require 'kramdown/man/tasks'
|
45
|
-
Kramdown::Man::Tasks.new
|
22
|
+
require 'kramdown/man/task'
|
23
|
+
Kramdown::Man::Task.new
|
data/gemspec.yml
CHANGED
@@ -7,9 +7,7 @@ email: postmodern.mod3@gmail.com
|
|
7
7
|
homepage: https://github.com/postmodern/kramdown-man#readme
|
8
8
|
|
9
9
|
dependencies:
|
10
|
-
kramdown: ~>
|
10
|
+
kramdown: ~> 2.0
|
11
11
|
|
12
12
|
development_dependencies:
|
13
|
-
|
14
|
-
rubygems-tasks: ~> 0.2
|
15
|
-
yard: ~> 0.8
|
13
|
+
bundler: ~> 2.0
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
require_relative '../man/version'
|
3
3
|
|
4
4
|
require 'kramdown/converter/base'
|
5
5
|
|
@@ -8,33 +8,399 @@ module Kramdown
|
|
8
8
|
#
|
9
9
|
# Converts markdown into a roff man-page.
|
10
10
|
#
|
11
|
-
class Man < Base
|
11
|
+
class Man < ::Kramdown::Converter::Base
|
12
12
|
|
13
13
|
# Comment header
|
14
14
|
HEADER = [
|
15
15
|
".\\\" Generated by kramdown-man #{::Kramdown::Man::VERSION}",
|
16
|
-
".\\\" https://github.com/postmodern/kramdown-
|
16
|
+
".\\\" https://github.com/postmodern/kramdown-man#readme"
|
17
17
|
].join("\n")
|
18
18
|
|
19
19
|
# Typographic Symbols and their UTF8 chars
|
20
20
|
TYPOGRAPHIC_SYMS = {
|
21
|
-
:ndash =>
|
22
|
-
:mdash =>
|
23
|
-
:hellip =>
|
24
|
-
:laquo =>
|
25
|
-
:raquo =>
|
26
|
-
:laquo_space =>
|
27
|
-
:raquo_space =>
|
21
|
+
:ndash => '\-\-',
|
22
|
+
:mdash => '\[em]',
|
23
|
+
:hellip => '\.\.\.',
|
24
|
+
:laquo => '\[Fo]',
|
25
|
+
:raquo => '\[Fc]',
|
26
|
+
:laquo_space => '\[Fo]',
|
27
|
+
:raquo_space => '\[Fc]'
|
28
28
|
}
|
29
29
|
|
30
30
|
# Smart Quotes and their UTF8 chars
|
31
31
|
SMART_QUOTES = {
|
32
|
-
:lsquo =>
|
33
|
-
:rsquo =>
|
34
|
-
:ldquo =>
|
35
|
-
:rdquo =>
|
32
|
+
:lsquo => '\[oq]',
|
33
|
+
:rsquo => '\[cq]',
|
34
|
+
:ldquo => '\[lq]',
|
35
|
+
:rdquo => '\[rq]'
|
36
36
|
}
|
37
37
|
|
38
|
+
GLYPHS = {
|
39
|
+
'Ð' => '\[-D]',
|
40
|
+
'ð' => '\[Sd]',
|
41
|
+
'Þ' => '\[TP]',
|
42
|
+
'þ' => '\[Tp]',
|
43
|
+
'ß' => '\[ss]',
|
44
|
+
# Ligatures and Other Latin Glyphs
|
45
|
+
'ff' => '\[ff]',
|
46
|
+
'fi' => '\[fi]',
|
47
|
+
'fl' => '\[fl]',
|
48
|
+
'ffi' => '\[Fi]',
|
49
|
+
'ffl' => '\[Fl]',
|
50
|
+
'Ł' => '\[/L]',
|
51
|
+
'ł' => '\[/l]',
|
52
|
+
'Ø' => '\[/O]',
|
53
|
+
'ø' => '\[/o]',
|
54
|
+
'Æ' => '\[AE]',
|
55
|
+
'æ' => '\[ae]',
|
56
|
+
'Œ' => '\[OE]',
|
57
|
+
'œ' => '\[oe]',
|
58
|
+
'IJ' => '\[IJ]',
|
59
|
+
'ij' => '\[ij]',
|
60
|
+
'ı' => '\[.i]',
|
61
|
+
'ȷ' => '\[.j]',
|
62
|
+
# Accented Characters
|
63
|
+
'Á' => '\[\'A]',
|
64
|
+
'Ć' => '\[\'C]',
|
65
|
+
'É' => '\[\'E]',
|
66
|
+
'Í' => '\[\'I]',
|
67
|
+
'Ó' => '\[\'O]',
|
68
|
+
'Ú' => '\[\'U]',
|
69
|
+
'Ý' => '\[\'Y]',
|
70
|
+
'á' => '\[\'a]',
|
71
|
+
'ć' => '\[\'c]',
|
72
|
+
'é' => '\[\'e]',
|
73
|
+
'í' => '\[\'i]',
|
74
|
+
'ó' => '\[\'o]',
|
75
|
+
'ú' => '\[\'u]',
|
76
|
+
'ý' => '\[\'y]',
|
77
|
+
'Ä' => '\[:A]',
|
78
|
+
'Ë' => '\[:E]',
|
79
|
+
'Ï' => '\[:I]',
|
80
|
+
'Ö' => '\[:O]',
|
81
|
+
'Ü' => '\[:U]',
|
82
|
+
'Ÿ' => '\[:Y]',
|
83
|
+
'ä' => '\[:a]',
|
84
|
+
'ë' => '\[:e]',
|
85
|
+
'ï' => '\[:i]',
|
86
|
+
'ö' => '\[:o]',
|
87
|
+
'ü' => '\[:u]',
|
88
|
+
'ÿ' => '\[:y]',
|
89
|
+
'Â' => '\[^A]',
|
90
|
+
'Ê' => '\[^E]',
|
91
|
+
'Î' => '\[^I]',
|
92
|
+
'Ô' => '\[^O]',
|
93
|
+
'Û' => '\[^U]',
|
94
|
+
'â' => '\[^a]',
|
95
|
+
'ê' => '\[^e]',
|
96
|
+
'î' => '\[^i]',
|
97
|
+
'ô' => '\[^o]',
|
98
|
+
'û' => '\[^u]',
|
99
|
+
'À' => '\[`A]',
|
100
|
+
'È' => '\[`E]',
|
101
|
+
'Ì' => '\[`I]',
|
102
|
+
'Ò' => '\[`O]',
|
103
|
+
'Ù' => '\[`U]',
|
104
|
+
'à' => '\[`a]',
|
105
|
+
'è' => '\[`e]',
|
106
|
+
'ì' => '\[`i]',
|
107
|
+
'ò' => '\[`o]',
|
108
|
+
'ù' => '\[`u]',
|
109
|
+
'Ã' => '\[~A]',
|
110
|
+
'Ñ' => '\[~N]',
|
111
|
+
'Õ' => '\[~O]',
|
112
|
+
'ã' => '\[~a]',
|
113
|
+
'ñ' => '\[~n]',
|
114
|
+
'õ' => '\[~o]',
|
115
|
+
'Š' => '\[vS]',
|
116
|
+
'š' => '\[vs]',
|
117
|
+
'Ž' => '\[vZ]',
|
118
|
+
'ž' => '\[vz]',
|
119
|
+
'Ç' => '\[,C]',
|
120
|
+
'ç' => '\[,c]',
|
121
|
+
'Å' => '\[oA]',
|
122
|
+
'å' => '\[oa]',
|
123
|
+
# Accents
|
124
|
+
'˝' => '\[a"]',
|
125
|
+
'¯' => '\[a-]',
|
126
|
+
'˙' => '\[a.]',
|
127
|
+
# '^' => '\[a^]',
|
128
|
+
'´' => "\\´",
|
129
|
+
'`' => '\`',
|
130
|
+
'˘' => '\[ab]',
|
131
|
+
'¸' => '\[ac]',
|
132
|
+
'¨' => '\[ad]',
|
133
|
+
'ˇ' => '\[ah]',
|
134
|
+
'˚' => '\[ao]',
|
135
|
+
# '~' => '\(ti',
|
136
|
+
'˛' => '\[ho]',
|
137
|
+
'^' => '\(ha',
|
138
|
+
'~' => '\[ti]',
|
139
|
+
# Quotes
|
140
|
+
'„' => '\[Bq]',
|
141
|
+
'‚' => '\[bq]',
|
142
|
+
'“' => '\[lq]',
|
143
|
+
'”' => '\[rq]',
|
144
|
+
'‘' => '\[oq]',
|
145
|
+
'’' => '\[cq]',
|
146
|
+
"'" => '\(aq',
|
147
|
+
'"' => '\[dq]',
|
148
|
+
'«' => '\[Fo]',
|
149
|
+
'»' => '\[Fc]',
|
150
|
+
'‹' => '\[fo]',
|
151
|
+
'›' => '\[fc]',
|
152
|
+
# Punctuation
|
153
|
+
'.' => '\.',
|
154
|
+
'¡' => '\[r!]',
|
155
|
+
'¿' => '\[r?]',
|
156
|
+
'—' => '\[em]',
|
157
|
+
'–' => '\[en]',
|
158
|
+
'‐' => '\[hy]',
|
159
|
+
# Brackets
|
160
|
+
'[' => '\[lB]',
|
161
|
+
']' => '\[rB]',
|
162
|
+
'{' => '\[lC]',
|
163
|
+
'}' => '\[rC]',
|
164
|
+
'⟨' => '\[la]',
|
165
|
+
'⟩' => '\[ra]',
|
166
|
+
# '⎪' => '\[bv]',
|
167
|
+
# '⎪' => '\[braceex]',
|
168
|
+
'⎡' => '\[bracketlefttp]',
|
169
|
+
'⎣' => '\[bracketleftbt]',
|
170
|
+
'⎢' => '\[bracketleftex]',
|
171
|
+
'⎤' => '\[bracketrighttp]',
|
172
|
+
'⎦' => '\[bracketrightbt]',
|
173
|
+
'⎥' => '\[bracketrightex]',
|
174
|
+
'╭' => '\[lt]',
|
175
|
+
'⎧' => '\[bracelefttp]',
|
176
|
+
'┥' => '\[lk]',
|
177
|
+
'⎨' => '\[braceleftmid]',
|
178
|
+
'╰' => '\[lb]',
|
179
|
+
'⎩' => '\[braceleftbt]',
|
180
|
+
# '⎪' => '\[braceleftex]',
|
181
|
+
'╮' => '\[rt]',
|
182
|
+
'⎫' => '\[bracerighttp]',
|
183
|
+
'┝' => '\[rk]',
|
184
|
+
'⎬' => '\[bracerightmid]',
|
185
|
+
'╯' => '\[rb]',
|
186
|
+
'⎭' => '\[bracerightbt]',
|
187
|
+
'⎪' => '\[bracerightex]',
|
188
|
+
'⎛' => '\[parenlefttp]',
|
189
|
+
'⎝' => '\[parenleftbt]',
|
190
|
+
'⎜' => '\[parenleftex]',
|
191
|
+
'⎞' => '\[parenrighttp]',
|
192
|
+
'⎠' => '\[parenrightbt]',
|
193
|
+
'⎟' => '\[parenrightex]',
|
194
|
+
# Arrows
|
195
|
+
'←' => '\[<-]',
|
196
|
+
'→' => '\[->]',
|
197
|
+
'↔' => '\[<>]',
|
198
|
+
'↓' => '\[da]',
|
199
|
+
'↑' => '\[ua]',
|
200
|
+
'↕' => '\[va]',
|
201
|
+
'⇐' => '\[lA]',
|
202
|
+
'⇒' => '\[rA]',
|
203
|
+
'⇔' => '\[hA]',
|
204
|
+
'⇓' => '\[dA]',
|
205
|
+
'⇑' => '\[uA]',
|
206
|
+
'⇕' => '\[vA]',
|
207
|
+
'⎯' => '\[an]',
|
208
|
+
# Lines
|
209
|
+
# '|' => '\[ba]',
|
210
|
+
'│' => '\[br]',
|
211
|
+
# '_' => '\[ul]',
|
212
|
+
'‾' => '\[rn]',
|
213
|
+
'_' => '\[ru]',
|
214
|
+
'¦' => '\[bb]',
|
215
|
+
'/' => '\[sl]',
|
216
|
+
'\\' => '\e',
|
217
|
+
# Text markers
|
218
|
+
'○' => '\[ci]',
|
219
|
+
# '·' => '\[bu]',
|
220
|
+
'‡' => '\[dd]',
|
221
|
+
'†' => '\[dg]',
|
222
|
+
'◊' => '\[lz]',
|
223
|
+
'□' => '\[sq]',
|
224
|
+
'¶' => '\[ps]',
|
225
|
+
'§' => '\[sc]',
|
226
|
+
'☜' => '\[lh]',
|
227
|
+
'☞' => '\[rh]',
|
228
|
+
'@' => '\[at]',
|
229
|
+
'#' => '\[sh]',
|
230
|
+
'↵' => '\[CR]',
|
231
|
+
'✓' => '\[OK]',
|
232
|
+
# Legal Symbols
|
233
|
+
'©' => '\[co]',
|
234
|
+
'®' => '\[rg]',
|
235
|
+
'™' => '\[tm]',
|
236
|
+
# Currency symbols
|
237
|
+
'$' => '\[Do]',
|
238
|
+
'¢' => '\[ct]',
|
239
|
+
# '€' => '\[eu]',
|
240
|
+
'€' => '\[Eu]',
|
241
|
+
'¥' => '\[Ye]',
|
242
|
+
'£' => '\[Po]',
|
243
|
+
'¤' => '\[Cs]',
|
244
|
+
'ƒ' => '\[Fn]',
|
245
|
+
# Units
|
246
|
+
'°' => '\[de]',
|
247
|
+
'‰' => '\[%0]',
|
248
|
+
'′' => '\[fm]',
|
249
|
+
'″' => '\[sd]',
|
250
|
+
'µ' => '\[mc]',
|
251
|
+
'ª' => '\[Of]',
|
252
|
+
'º' => '\[Om]',
|
253
|
+
# Logical Symbols
|
254
|
+
'∧' => '\[AN]',
|
255
|
+
'∨' => '\[OR]',
|
256
|
+
# '¬' => '\[no]',
|
257
|
+
'¬' => '\[tno]',
|
258
|
+
'∃' => '\[te]',
|
259
|
+
'∀' => '\[fa]',
|
260
|
+
'∋' => '\[st]',
|
261
|
+
# '∴' => '\[3d]',
|
262
|
+
'∴' => '\[tf]',
|
263
|
+
'|' => '\[or]',
|
264
|
+
# Mathematical Symbols
|
265
|
+
'½' => '\[12]',
|
266
|
+
'¼' => '\[14]',
|
267
|
+
'¾' => '\[34]',
|
268
|
+
'⅛' => '\[18]',
|
269
|
+
'⅜' => '\[38]',
|
270
|
+
'⅝' => '\[58]',
|
271
|
+
'⅞' => '\[78]',
|
272
|
+
'¹' => '\[S1]',
|
273
|
+
'²' => '\[S2]',
|
274
|
+
'³' => '\[S3]',
|
275
|
+
'+' => '\[pl]',
|
276
|
+
'-' => '\-',
|
277
|
+
'−' => '\[mi]',
|
278
|
+
'∓' => '\[-+]',
|
279
|
+
# '±' => '\[+-]',
|
280
|
+
'±' => '\[t+-]',
|
281
|
+
'·' => '\[pc]',
|
282
|
+
'⋅' => '\[md]',
|
283
|
+
# '×' => '\[mu]',
|
284
|
+
'×' => '\[tmu]',
|
285
|
+
'⊗' => '\[c*]',
|
286
|
+
'⊕' => '\[c+]',
|
287
|
+
# '÷' => '\[di]',
|
288
|
+
'÷' => '\[tdi]',
|
289
|
+
'⁄' => '\[f/]',
|
290
|
+
'∗' => '\[**]',
|
291
|
+
'≤' => '\[<=]',
|
292
|
+
'≥' => '\[>=]',
|
293
|
+
'≪' => '\[<<]',
|
294
|
+
'≫' => '\[>>]',
|
295
|
+
'=' => '\[eq]',
|
296
|
+
'≠' => '\[!=]',
|
297
|
+
'≡' => '\[==]',
|
298
|
+
'≢' => '\[ne]',
|
299
|
+
'≅' => '\[=~]',
|
300
|
+
'≃' => '\[|=]',
|
301
|
+
'∼' => '\[ap]',
|
302
|
+
# '≈' => '\[~~]',
|
303
|
+
'≈' => '\[~=]',
|
304
|
+
'∝' => '\[pt]',
|
305
|
+
'∅' => '\[es]',
|
306
|
+
'∈' => '\[mo]',
|
307
|
+
'∉' => '\[nm]',
|
308
|
+
'⊂' => '\[sb]',
|
309
|
+
'⊄' => '\[nb]',
|
310
|
+
'⊃' => '\[sp]',
|
311
|
+
'⊅' => '\[nc]',
|
312
|
+
'⊆' => '\[ib]',
|
313
|
+
'⊇' => '\[ip]',
|
314
|
+
'∩' => '\[ca]',
|
315
|
+
'∪' => '\[cu]',
|
316
|
+
'∠' => '\[/_]',
|
317
|
+
'⊥' => '\[pp]',
|
318
|
+
# '∫' => '\[is]',
|
319
|
+
'∫' => '\[integral]',
|
320
|
+
'∑' => '\[sum]',
|
321
|
+
'∏' => '\[product]',
|
322
|
+
'∐' => '\[coproduct]',
|
323
|
+
'∇' => '\[gr]',
|
324
|
+
# '√' => '\[sr]',
|
325
|
+
'√' => '\[sqrt]',
|
326
|
+
'⌈' => '\[lc]',
|
327
|
+
'⌉' => '\[rc]',
|
328
|
+
'⌊' => '\[lf]',
|
329
|
+
'⌋' => '\[rf]',
|
330
|
+
'∞' => '\[if]',
|
331
|
+
'ℵ' => '\[Ah]',
|
332
|
+
'ℑ' => '\[Im]',
|
333
|
+
'ℜ' => '\[Re]',
|
334
|
+
'℘' => '\[wp]',
|
335
|
+
'∂' => '\[pd]',
|
336
|
+
# 'ℏ' => '\[-h]',
|
337
|
+
'ℏ' => '\[hbar]',
|
338
|
+
# Greek glyphs
|
339
|
+
'Α' => '\[*A]',
|
340
|
+
'Β' => '\[*B]',
|
341
|
+
'Γ' => '\[*G]',
|
342
|
+
'Δ' => '\[*D]',
|
343
|
+
'Ε' => '\[*E]',
|
344
|
+
'Ζ' => '\[*Z]',
|
345
|
+
'Η' => '\[*Y]',
|
346
|
+
'Θ' => '\[*H]',
|
347
|
+
'Ι' => '\[*I]',
|
348
|
+
'Κ' => '\[*K]',
|
349
|
+
'Λ' => '\[*L]',
|
350
|
+
'Μ' => '\[*M]',
|
351
|
+
'Ν' => '\[*N]',
|
352
|
+
'Ξ' => '\[*C]',
|
353
|
+
'Ο' => '\[*O]',
|
354
|
+
'Π' => '\[*P]',
|
355
|
+
'Ρ' => '\[*R]',
|
356
|
+
'Σ' => '\[*S]',
|
357
|
+
'Τ' => '\[*T]',
|
358
|
+
'Υ' => '\[*U]',
|
359
|
+
'Φ' => '\[*F]',
|
360
|
+
'Χ' => '\[*X]',
|
361
|
+
'Ψ' => '\[*Q]',
|
362
|
+
'Ω' => '\[*W]',
|
363
|
+
'α' => '\[*a]',
|
364
|
+
'β' => '\[*b]',
|
365
|
+
'γ' => '\[*g]',
|
366
|
+
'δ' => '\[*d]',
|
367
|
+
'ε' => '\[*e]',
|
368
|
+
'ζ' => '\[*z]',
|
369
|
+
'η' => '\[*y]',
|
370
|
+
'θ' => '\[*h]',
|
371
|
+
'ι' => '\[*i]',
|
372
|
+
'κ' => '\[*k]',
|
373
|
+
'λ' => '\[*l]',
|
374
|
+
'μ' => '\[*m]',
|
375
|
+
'ν' => '\[*n]',
|
376
|
+
'ξ' => '\[*c]',
|
377
|
+
'ο' => '\[*o]',
|
378
|
+
'π' => '\[*p]',
|
379
|
+
'ρ' => '\[*r]',
|
380
|
+
'ς' => '\[ts]',
|
381
|
+
'σ' => '\[*s]',
|
382
|
+
'τ' => '\[*t]',
|
383
|
+
'υ' => '\[*u]',
|
384
|
+
'ϕ' => '\[*f]',
|
385
|
+
'χ' => '\[*x]',
|
386
|
+
'ψ' => '\[*q]',
|
387
|
+
'ω' => '\[*w]',
|
388
|
+
'ϑ' => '\[+h]',
|
389
|
+
'φ' => '\[+f]',
|
390
|
+
'ϖ' => '\[+p]',
|
391
|
+
'ϵ' => '\[+e]',
|
392
|
+
# Card symbols
|
393
|
+
'♣' => '\[CL]',
|
394
|
+
'♠' => '\[SP]',
|
395
|
+
'♥' => '\[HE]',
|
396
|
+
'♡' => '\[u2661]',
|
397
|
+
'♦' => '\[DI]',
|
398
|
+
'♢' => '\[u2662]'
|
399
|
+
}
|
400
|
+
|
401
|
+
# Regular expression to convert unicode characters into glyphs
|
402
|
+
GLYPH_REGEXP = Regexp.union(GLYPHS.keys)
|
403
|
+
|
38
404
|
#
|
39
405
|
# Initializes the converter.
|
40
406
|
#
|
@@ -115,7 +481,7 @@ module Kramdown
|
|
115
481
|
# The roff output.
|
116
482
|
#
|
117
483
|
def convert_text(text)
|
118
|
-
escape(text.value)
|
484
|
+
escape(text.value.gsub(/^( +|\t)/,''))
|
119
485
|
end
|
120
486
|
|
121
487
|
#
|
@@ -324,15 +690,21 @@ module Kramdown
|
|
324
690
|
def convert_p(p)
|
325
691
|
children = p.children
|
326
692
|
|
327
|
-
if (children.length >= 2) &&
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
693
|
+
if ((children.length >= 2) && (children.first.type == :codespan ||
|
694
|
+
children.first.type == :em ||
|
695
|
+
children.first.type == :strong))
|
696
|
+
newline = children.find_index { |el|
|
697
|
+
el.type == :text && el.value.start_with?("\n")
|
698
|
+
}
|
699
|
+
|
700
|
+
if newline
|
701
|
+
first_line = convert_children(children[0...newline])
|
702
|
+
rest = convert_children(children[newline..-1]).strip
|
703
|
+
|
704
|
+
".TP\n#{first_line}\n#{rest}"
|
705
|
+
else
|
706
|
+
".HP\n#{convert_children(children)}"
|
707
|
+
end
|
336
708
|
else
|
337
709
|
".PP\n#{convert_children(children)}"
|
338
710
|
end
|
@@ -374,7 +746,7 @@ module Kramdown
|
|
374
746
|
# The roff output.
|
375
747
|
#
|
376
748
|
def convert_codespan(codespan)
|
377
|
-
"\\fB
|
749
|
+
"\\fB#{codespan.value}\\fR"
|
378
750
|
end
|
379
751
|
|
380
752
|
#
|
@@ -387,7 +759,7 @@ module Kramdown
|
|
387
759
|
# The roff output.
|
388
760
|
#
|
389
761
|
def convert_a(a)
|
390
|
-
href = a.attr['href']
|
762
|
+
href = escape(a.attr['href'])
|
391
763
|
text = convert_children(a.children)
|
392
764
|
|
393
765
|
case href
|
@@ -431,7 +803,7 @@ module Kramdown
|
|
431
803
|
# The escaped text.
|
432
804
|
#
|
433
805
|
def escape(text)
|
434
|
-
text.gsub(
|
806
|
+
text.gsub(GLYPH_REGEXP) { |char| GLYPHS[char] }
|
435
807
|
end
|
436
808
|
|
437
809
|
end
|