hiki2md 0.1.3 → 0.3.0
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 +5 -5
- data/.gitignore +0 -1
- data/.travis.yml +4 -2
- data/Gemfile.lock +36 -0
- data/README.md +83 -2
- data/exe/hiki2md +36 -3
- data/hiki2md.gemspec +3 -2
- data/lib/hiki2md/version.rb +1 -1
- data/lib/hiki2md.rb +844 -157
- metadata +13 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9b4d6cfffb000735e6110b7f97177fed422bd998b1ea8d07672ee0965f0232f8
|
|
4
|
+
data.tar.gz: 92ac94a769691e6bd4a7662bb0b33adcc7b6036d720f5d7171b21c08511a6954
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc77e072352a1a301871154af34120ccf5a32bb0857019e92132a0867a972c7ff918f53915a062fc3317b1c702b1512dfdc25889f9f590c0b18f28c883c80820
|
|
7
|
+
data.tar.gz: 3c6df53740b623b39bb5f20e11d314a6f6de3f251cfced2e7f7bb596d98f2a67d4cf04573bb58f3179510ee80d1ac1f018489fc7bc6ed81cc9ae3d82084a66be
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
hiki2md (0.3.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
diff-lcs (1.6.2)
|
|
10
|
+
rake (13.3.0)
|
|
11
|
+
rspec (3.13.1)
|
|
12
|
+
rspec-core (~> 3.13.0)
|
|
13
|
+
rspec-expectations (~> 3.13.0)
|
|
14
|
+
rspec-mocks (~> 3.13.0)
|
|
15
|
+
rspec-core (3.13.5)
|
|
16
|
+
rspec-support (~> 3.13.0)
|
|
17
|
+
rspec-expectations (3.13.5)
|
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
19
|
+
rspec-support (~> 3.13.0)
|
|
20
|
+
rspec-mocks (3.13.5)
|
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
22
|
+
rspec-support (~> 3.13.0)
|
|
23
|
+
rspec-support (3.13.6)
|
|
24
|
+
|
|
25
|
+
PLATFORMS
|
|
26
|
+
arm64-darwin-23
|
|
27
|
+
ruby
|
|
28
|
+
|
|
29
|
+
DEPENDENCIES
|
|
30
|
+
bundler
|
|
31
|
+
hiki2md!
|
|
32
|
+
rake
|
|
33
|
+
rspec
|
|
34
|
+
|
|
35
|
+
BUNDLED WITH
|
|
36
|
+
2.6.8
|
data/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Converter of Hiki to Markdown.
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
+
Hiki2md requires Ruby 2.2 or newer.
|
|
10
|
+
|
|
9
11
|
Add this line to your application's Gemfile:
|
|
10
12
|
|
|
11
13
|
```ruby
|
|
@@ -22,7 +24,87 @@ Or install it yourself as:
|
|
|
22
24
|
|
|
23
25
|
## Usage
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
### Ruby
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require "hiki2md"
|
|
31
|
+
|
|
32
|
+
converter = Hiki2md.new(
|
|
33
|
+
interwiki_map: {
|
|
34
|
+
"Google" => "https://www.google.com/search?q=",
|
|
35
|
+
"Issues" => "https://example.com/issues/$1"
|
|
36
|
+
},
|
|
37
|
+
use_wiki_name: true,
|
|
38
|
+
preserve_plugins: false
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
markdown = converter.convert(hiki_source)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Internal page links receive a `.md` extension. InterWiki values either have
|
|
45
|
+
the encoded page name appended, or can contain `$1` where the page name should
|
|
46
|
+
be inserted.
|
|
47
|
+
|
|
48
|
+
### Command line
|
|
49
|
+
|
|
50
|
+
```console
|
|
51
|
+
$ hiki2md [options] input.hiki
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Options:
|
|
55
|
+
|
|
56
|
+
- `--interwiki-map PATH`: load InterWiki prefixes from a YAML mapping.
|
|
57
|
+
- `--[no-]wiki-name`: enable or disable automatic WikiName links.
|
|
58
|
+
- `--preserve-plugins`: retain plugins as escaped Markdown text instead of
|
|
59
|
+
removing them.
|
|
60
|
+
|
|
61
|
+
### Supported Hiki syntax
|
|
62
|
+
|
|
63
|
+
The converter targets Hiki's default style and emits GitHub Flavored Markdown
|
|
64
|
+
(GFM).
|
|
65
|
+
|
|
66
|
+
| Hiki | Output |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `!` through `!!!!!` | headings 2 through 6 |
|
|
69
|
+
| `*` / `#` | nested unordered / ordered lists |
|
|
70
|
+
| `''text''` / `'''text'''` | emphasis / strong emphasis |
|
|
71
|
+
| `==text==` / double-backtick text | strikethrough / inline code |
|
|
72
|
+
| `[[Page]]` / `[[label\|target]]` | page, URL, and InterWiki links |
|
|
73
|
+
| image URLs | Markdown images, including basename or labeled alt text |
|
|
74
|
+
| leading space or tab, `<<<` ... `>>>` | fenced code blocks |
|
|
75
|
+
| `""` | recursive blockquotes |
|
|
76
|
+
| `:term:description` | HTML definition lists |
|
|
77
|
+
| `\|\|cell` | raw HTML tables |
|
|
78
|
+
| `----` | horizontal rules |
|
|
79
|
+
| `// comment` | removed comments |
|
|
80
|
+
|
|
81
|
+
Hiki permits tables without a header row, while GFM pipe tables require one.
|
|
82
|
+
All Hiki tables are therefore emitted as raw HTML so ordinary `td` cells,
|
|
83
|
+
explicit `!` header cells, and `^` / `>` row and column spans retain their
|
|
84
|
+
meaning.
|
|
85
|
+
|
|
86
|
+
Hiki plugins are executable Ruby extensions and cannot be converted
|
|
87
|
+
generically. Plugin calls are removed by default. Use `preserve_plugins: true`
|
|
88
|
+
or `--preserve-plugins` to keep them as escaped Markdown text for manual
|
|
89
|
+
migration. Plugin-looking text inside preformatted blocks is always kept
|
|
90
|
+
literally.
|
|
91
|
+
|
|
92
|
+
### Version 0.3 output changes
|
|
93
|
+
|
|
94
|
+
Version 0.3 favors the rendered meaning of Hiki over preserving the exact
|
|
95
|
+
Markdown source produced by 0.2. In particular, all tables now use raw HTML,
|
|
96
|
+
ordered-list indentation follows CommonMark, and Markdown-looking source text
|
|
97
|
+
is escaped when Hiki treats it as plain text. The legacy public `make_matrix`
|
|
98
|
+
and `make_table` helpers retain their 0.2 behavior.
|
|
99
|
+
|
|
100
|
+
Lists deeper than 100 levels use raw HTML to keep output growth bounded.
|
|
101
|
+
Uniform blockquotes may be arbitrarily deep; blocks containing more than 100
|
|
102
|
+
distinct quote depths raise `ArgumentError` instead of risking stack or CPU
|
|
103
|
+
exhaustion.
|
|
104
|
+
|
|
105
|
+
See Hiki's
|
|
106
|
+
[TextFormattingRules](https://hikiwiki.org/en/TextFormattingRules.html) for
|
|
107
|
+
the source syntax.
|
|
26
108
|
|
|
27
109
|
## Development
|
|
28
110
|
|
|
@@ -40,4 +122,3 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
|
40
122
|
## Inspired by
|
|
41
123
|
|
|
42
124
|
https://github.com/masasuzu/p5-App-hiki2md
|
|
43
|
-
|
data/exe/hiki2md
CHANGED
|
@@ -1,12 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
require 'hiki2md'
|
|
3
|
+
require 'optparse'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
|
|
6
|
+
interwiki_map = {}
|
|
7
|
+
use_wiki_name = true
|
|
8
|
+
preserve_plugins = false
|
|
9
|
+
|
|
10
|
+
OptionParser.new do |opts|
|
|
11
|
+
opts.banner = "Usage: hiki2md [options] <file>"
|
|
12
|
+
|
|
13
|
+
opts.on("--interwiki-map PATH", "Path to a YAML file for InterWiki definitions") do |path|
|
|
14
|
+
if File.exist?(path)
|
|
15
|
+
interwiki_map.merge!(YAML.load_file(path))
|
|
16
|
+
else
|
|
17
|
+
raise IOError.new("InterWiki map file not found: #{path}")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
opts.on("--[no-]wiki-name", "Enable or disable WikiName autolinking") do |enabled|
|
|
22
|
+
use_wiki_name = enabled
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
opts.on("--preserve-plugins", "Keep Hiki plugins as escaped Markdown text") do
|
|
26
|
+
preserve_plugins = true
|
|
27
|
+
end
|
|
28
|
+
end.parse!
|
|
3
29
|
|
|
4
30
|
if ARGV.size != 1
|
|
5
31
|
raise ArgumentError.new("no file specified")
|
|
6
32
|
end
|
|
7
33
|
|
|
8
|
-
|
|
9
|
-
|
|
34
|
+
input_file = ARGV[0]
|
|
35
|
+
|
|
36
|
+
if !File.exist?(input_file)
|
|
37
|
+
raise IOError.new("no exist #{input_file}")
|
|
10
38
|
end
|
|
11
39
|
|
|
12
|
-
|
|
40
|
+
hiki2md = Hiki2md.new(
|
|
41
|
+
interwiki_map: interwiki_map,
|
|
42
|
+
use_wiki_name: use_wiki_name,
|
|
43
|
+
preserve_plugins: preserve_plugins
|
|
44
|
+
)
|
|
45
|
+
puts hiki2md.convert(File.read(input_file))
|
data/hiki2md.gemspec
CHANGED
|
@@ -12,13 +12,14 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.summary = %q{Converter of Hiki to Markdown}
|
|
13
13
|
spec.homepage = "http://github.com/kdmsnr/hiki2md"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 2.2.0"
|
|
15
16
|
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
18
|
spec.bindir = "exe"
|
|
18
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
20
|
spec.require_paths = ["lib"]
|
|
20
21
|
|
|
21
|
-
spec.add_development_dependency "bundler"
|
|
22
|
-
spec.add_development_dependency "rake"
|
|
22
|
+
spec.add_development_dependency "bundler"
|
|
23
|
+
spec.add_development_dependency "rake"
|
|
23
24
|
spec.add_development_dependency "rspec"
|
|
24
25
|
end
|
data/lib/hiki2md/version.rb
CHANGED