hierogloss 0.0.4 → 0.0.5

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
2
  SHA1:
3
- metadata.gz: e1c7226840e4b86ba6e423abc777be7d2e052192
4
- data.tar.gz: 7d147b77e33083bd3906d88c954c48634f5619ee
3
+ metadata.gz: 013868a650a3464e07c17bcca8f37bcba3e52974
4
+ data.tar.gz: a02e8d67a85df5dcfedc9ae87447bf6604ed3587
5
5
  SHA512:
6
- metadata.gz: 5da667b94a99bc656432c66c26e8cf576689ce4c56673ecbc4a1ab39f6d3fef5ada0da69aa2f8171174c9b9e09f4c714343d3316ffbdff359933e56855689a22
7
- data.tar.gz: 77a1887d0318f9e4b88a86b3744fe5715bdf25856dc3de4595d16bc204d822d365db77f14814d6fd89bb6b67c144c2930445a1df582247cbe383122ad277be4d
6
+ metadata.gz: 9a362073542fa41bad251c4f0d38e9310b051fc617615036f9448d68e55a6855e0dd27e2e9c6d2489d7f0987245c07453775083c395817d23e8498d863b5801d
7
+ data.tar.gz: e17841bf61cb0b4b77680c498a6f93169a670246604b593b84b6b26a1ed3ec61b2edf5da8ca1aca437ebc7919cc138d088a8b0c892fa744b1ae23ed8ed36f52b
data/bin/hierogloss CHANGED
@@ -3,12 +3,12 @@
3
3
  require 'optparse'
4
4
  require 'hierogloss'
5
5
 
6
- options = { format: 'html', images: false }
6
+ options = { format: 'html', images: false, translit: :jy_unicode }
7
7
 
8
8
  OptionParser.new do |opts|
9
9
  opts.banner = "Usage: hierogloss [options] files..."
10
10
 
11
- opts.on("-f", "--format [FORMAT]",
11
+ opts.on("-f", "--format FORMAT",
12
12
  "Output format (html, bbcode, htlal)",
13
13
  " (defaults to html)") do |format|
14
14
  options[:format] = format
@@ -19,9 +19,19 @@ OptionParser.new do |opts|
19
19
  " (defaults to off)") do |images|
20
20
  options[:images] = images
21
21
  end
22
+
23
+ opts.on("-t", "--translit TRANSLIT",
24
+ "Output transliteration convention (jy_unicode, mdc)",
25
+ " (defaults to jy_unicode)") do |translit|
26
+ options[:translit] = translit.to_sym
27
+ end
22
28
  end.parse!
23
29
 
24
- args = { input: 'hierogloss', use_images_for_signs: options[:images] }
30
+ args = {
31
+ input: 'hierogloss',
32
+ use_images_for_signs: options[:images],
33
+ transliteration: options[:translit]
34
+ }
25
35
  if options[:format] == 'html'
26
36
  args[:template] =
27
37
  File.join(File.dirname(__FILE__), '..', 'data', 'hierogloss.html.erb')
@@ -88,30 +88,12 @@ module Hierogloss
88
88
 
89
89
  #:nodoc:
90
90
  class TransliterationRow < Row
91
- JR_TRANSLITERATION = {
92
- "A" => "ꜣ",
93
- "i" => "j",
94
- "a" => "ꜥ",
95
- "H" => "ḥ",
96
- "x" => "ḫ",
97
- "X" => "ẖ",
98
- "S" => "š",
99
- "q" => "ḳ",
100
- "K" => "ḳ",
101
- "T" => "ṯ",
102
- "D" => "ḏ"
103
- }
104
-
105
- def self.fancy(tl)
106
- tl.chars.map {|c| JR_TRANSLITERATION[c] || c }.join
107
- end
108
-
109
91
  def class_attr
110
92
  'hgls-l'
111
93
  end
112
94
 
113
95
  def cell_to_kramdown(cell, options)
114
- fancy = self.class.fancy(cell)
96
+ fancy = Hierogloss::Transliteration.render(cell, options[:transliteration])
115
97
  search_link(Dictionary.headword(cell), fancy)
116
98
  end
117
99
  end
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Hierogloss
3
+ # :nodoc: Transliteration utilities.
4
+ module Transliteration
5
+ STYLES = {
6
+ # Output as raw MdC. Useful when the user isn't expected to have any
7
+ # fonts.
8
+ mdc: {},
9
+
10
+ # This is widely used in places like Allen, Loprieno and Thesaurus
11
+ # Linguae Aegyptiae.
12
+ jy_unicode: {
13
+ "A" => "ꜣ",
14
+ "i" => "j",
15
+ "a" => "ꜥ",
16
+ "H" => "ḥ",
17
+ "x" => "ḫ",
18
+ "X" => "ẖ",
19
+ "S" => "š",
20
+ "q" => "ḳ",
21
+ "K" => "ḳ",
22
+ "T" => "ṯ",
23
+ "D" => "ḏ"
24
+ }
25
+ }
26
+
27
+ # Convert from MDC to another transliteration style. Defaults to
28
+ # :jy_unicode.
29
+ def self.render(mdc, style=nil)
30
+ style ||=:jy_unicode
31
+ conv = STYLES[style]
32
+ raise "Unknown transliteration style: #{style}" unless conv
33
+ mdc.chars.map {|c| conv[c] || c }.join
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module Hierogloss
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/hierogloss.rb CHANGED
@@ -3,6 +3,7 @@ require "hierogloss/version"
3
3
  require "hierogloss/dictionary"
4
4
  require "hierogloss/metrics"
5
5
  require "hierogloss/mdc"
6
+ require "hierogloss/transliteration"
6
7
  require "hierogloss/gloss"
7
8
  require "kramdown/parser/hierogloss"
8
9
  require "kramdown/converter/bbcode"
@@ -15,8 +15,9 @@ module Kramdown
15
15
  @src.pos += @src.matched_size
16
16
  mdc = @src.matched[1..-2]
17
17
  em = Element.new(:em, nil, 'class' => 'hgls-l')
18
- em.children <<
19
- Element.new(:text, ::Hierogloss::TransliterationRow.fancy(mdc))
18
+ rendered =
19
+ ::Hierogloss::Transliteration.render(mdc, @options[:transliteration])
20
+ em.children << Element.new(:text, rendered)
20
21
  @tree.children << em
21
22
  end
22
23
  define_parser(:translit, TRANSLIT_START, '{')
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'minitest_helper'
3
+
4
+ class TestTransliteration < MiniTest::Test
5
+ def assert_renders(output, input, type)
6
+ assert_equal output, Hierogloss::Transliteration.render(input, type)
7
+ end
8
+
9
+ def test_should_render_common_tranliterations
10
+ assert_renders "biA.t y", "biA.t y", :mdc
11
+ assert_renders "bjꜣ.t y", "biA.t y", :jy_unicode
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hierogloss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kidd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -132,6 +132,7 @@ files:
132
132
  - lib/hierogloss/mdc.rb
133
133
  - lib/hierogloss/metrics.rb
134
134
  - lib/hierogloss/metrics/data.rb
135
+ - lib/hierogloss/transliteration.rb
135
136
  - lib/hierogloss/version.rb
136
137
  - lib/kramdown/converter/bbcode.rb
137
138
  - lib/kramdown/converter/htlal.rb
@@ -145,6 +146,7 @@ files:
145
146
  - test/test_kramdown_extensions.rb
146
147
  - test/test_mdc.rb
147
148
  - test/test_metrics.rb
149
+ - test/test_transliteration.rb
148
150
  homepage: https://github.com/emk/hierogloss
149
151
  licenses:
150
152
  - Public domain + other open source licenses
@@ -177,3 +179,4 @@ test_files:
177
179
  - test/test_kramdown_extensions.rb
178
180
  - test/test_mdc.rb
179
181
  - test/test_metrics.rb
182
+ - test/test_transliteration.rb