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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 75c588c94f143ff7531246991a1f1cd286e4d22d
4
- data.tar.gz: 9acce914fec1459b92dac42914badf6b4861bff6
2
+ SHA256:
3
+ metadata.gz: 9b4d6cfffb000735e6110b7f97177fed422bd998b1ea8d07672ee0965f0232f8
4
+ data.tar.gz: 92ac94a769691e6bd4a7662bb0b33adcc7b6036d720f5d7171b21c08511a6954
5
5
  SHA512:
6
- metadata.gz: 81094c8d50da145dfd50b7ac42a1965404e87302185beeaa156f7f9e5d0f2162fe6a5a1ed3ac593c0c8e16bc7713b2470327c3cad59633c38dc5a48595634575
7
- data.tar.gz: 0b862ccd85bcd0f374a89b06a2b4abf5bbde43ed965e6723b6e1df1d1f099a3c27f0de8fddfed40f7ef370cc974c69de742ee2b69c89be180297014d3a54b70b
6
+ metadata.gz: fc77e072352a1a301871154af34120ccf5a32bb0857019e92132a0867a972c7ff918f53915a062fc3317b1c702b1512dfdc25889f9f590c0b18f28c883c80820
7
+ data.tar.gz: 3c6df53740b623b39bb5f20e11d314a6f6de3f251cfced2e7f7bb596d98f2a67d4cf04573bb58f3179510ee80d1ac1f018489fc7bc6ed81cc9ae3d82084a66be
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ dist: jammy
2
3
  rvm:
3
- - 2.2.3
4
- before_install: gem install bundler -v 1.10.6
4
+ - 3.1
5
+ - 3.4
6
+ before_install: gem install bundler -v 2.6.8
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
- TODO: Write usage instructions here
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
- if !File.exist?(ARGV[0])
9
- raise IOError.new("no exist #{ARGV[0]}")
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
- puts Hiki2md.new.convert(File.read(ARGV[0]))
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", "~> 1.10"
22
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec"
24
25
  end
@@ -1,3 +1,3 @@
1
1
  class Hiki2md
2
- VERSION = "0.1.3"
2
+ VERSION = "0.3.0"
3
3
  end