mdx-tex 0.1.7 → 0.1.10

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
  SHA256:
3
- metadata.gz: c81dc6718c19d8287bac86ac03e49a3674122e188a84b0e0567e2dfd5d57edbc
4
- data.tar.gz: 342cd80018cc3ea02fb321a5f94f4073d2dc01a213e5482b7730a7300dab9a05
3
+ metadata.gz: 1445c84b79d3839f67f786d03c5f2ca3639acdd88a0e16250c477934c37b5c7b
4
+ data.tar.gz: e0a60dd96456b945d31ea20a9c695f130636ba60d449b755ea086b7e5b1f6761
5
5
  SHA512:
6
- metadata.gz: 25df2404988ade176532776424e3c07ddd3d93b0d21462b0f2c46fbe53fdd585a00253a67f0fa54fdfabe37f23582b3cb9271307e4a216e4e45742c10f9c05f3
7
- data.tar.gz: b60afd7f7ceb139327390021858879b382834938ce00bf19eb80510854ee18c2bcc89c3309d3a96f862c6fb771a5cfd51213da6e9b2d0f90fc3ae1ffe9855e1c
6
+ metadata.gz: c92ec8da08b5794f6ed990c71afbbe1f7092eee06e43bf8c63451b3c0dc86625d7fdf529007f592baaf80e5a692e53f11eb6ccea05811c14ce97d80192596fa9
7
+ data.tar.gz: a03042264fd9b7675a75a35af09361f05da24724bdbef88027e41a6fda6212781c1b2400700538ac9a54b75e45baee30269f52a380b505505362f1a48e3dd1e0
data/lib/mdx/tex.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mdx_tex'
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MarkLeft
4
- # Holds global defaults for all MarkLeft conversions.
5
- # Override these in an initializer (e.g. config/initializers/mark_left.rb):
3
+ module MdxTex
4
+ # Holds global defaults for all MdxTex conversions.
5
+ # Override these in an initializer (e.g. config/initializers/mdx_tex.rb):
6
6
  #
7
- # MarkLeft.configure do |config|
7
+ # MdxTex.configure do |config|
8
8
  # config.header_level = 'h2' # Textile heading tag (default: 'h3')
9
9
  # config.list_depth = 1 # Leading asterisks for depth-1 unordered list items (default: 3)
10
10
  # end
11
11
  #
12
12
  # Per-call options always take precedence over these defaults:
13
13
  #
14
- # MarkLeft.convert(markdown, list_depth: 1)
14
+ # MdxTex.to_textile(markdown: markdown, list_depth: 1)
15
15
  class Configuration
16
16
  attr_reader :header_level, :list_depth
17
17
 
@@ -21,12 +21,12 @@ module MarkLeft
21
21
  end
22
22
 
23
23
  def header_level=(value)
24
- MarkLeft::ToTextile::InvalidHeaderLevelError.validate!(value)
24
+ MdxTex::ToTextile::InvalidHeaderLevelError.validate!(value)
25
25
  @header_level = value
26
26
  end
27
27
 
28
28
  def list_depth=(value)
29
- MarkLeft::ToTextile::InvalidListDepthError.validate!(value)
29
+ MdxTex::ToTextile::InvalidListDepthError.validate!(value)
30
30
  @list_depth = value
31
31
  end
32
32
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MarkLeft
3
+ module MdxTex
4
4
  class ToTextile
5
5
  # Converts Markdown bold syntax to Textile bold syntax.
6
6
  # Both ** and __ delimiters are supported and processed independently.
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MdxTex
4
+ class ToTextile
5
+ VALID_HEADER_LEVELS = %w[h1 h2 h3 h4 h5 h6].freeze
6
+
7
+ class InvalidListDepthError < ArgumentError
8
+ def initialize(value)
9
+ super("list_depth must be a positive integer, got: #{value.inspect}")
10
+ end
11
+
12
+ def self.validate!(value)
13
+ raise self, value unless value.is_a?(Integer) && value.positive?
14
+ end
15
+ end
16
+
17
+ class InvalidHeaderLevelError < ArgumentError
18
+ def initialize(value)
19
+ super("header_level must be one of #{VALID_HEADER_LEVELS.join(', ')}, got: #{value.inspect}")
20
+ end
21
+
22
+ def self.validate!(value)
23
+ raise self, value unless VALID_HEADER_LEVELS.include?(value)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MarkLeft
3
+ module MdxTex
4
4
  class ToTextile
5
5
  # Converts a Markdown heading to a Textile heading.
6
6
  # The caller supplies the desired Textile header tag via +header_level+.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MarkLeft
3
+ module MdxTex
4
4
  class ToTextile
5
5
  # Converts a Markdown ordered list item to a Textile ordered list item.
6
6
  # Nesting depth is determined by leading indentation (2 spaces per level).
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MarkLeft
3
+ module MdxTex
4
4
  class ToTextile
5
5
  # Converts a Markdown unordered list item to a Textile unordered list item.
6
6
  # Nesting depth is determined by leading indentation (2 spaces per level),
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mdx_tex/to_textile/errors'
4
+ require 'mdx_tex/to_textile/header'
5
+ require 'mdx_tex/to_textile/bold'
6
+ require 'mdx_tex/to_textile/unordered_list'
7
+ require 'mdx_tex/to_textile/ordered_list'
8
+
9
+ module MdxTex
10
+ class ToTextile
11
+ def initialize(header_level: 'h3', list_depth: 3)
12
+ InvalidHeaderLevelError.validate!(header_level)
13
+ InvalidListDepthError.validate!(list_depth)
14
+
15
+ @header_level = header_level
16
+ @list_depth = list_depth
17
+ end
18
+
19
+ def execute(input)
20
+ return '' if input.nil?
21
+
22
+ input.to_s.split("\n", -1).map { |line| convert_line(line) }.join("\n")
23
+ end
24
+
25
+ private
26
+
27
+ def convert_line(line)
28
+ line = Header.execute(line, header_level: @header_level)
29
+ line = Bold.execute(line)
30
+ line = UnorderedList.execute(line, list_depth: @list_depth)
31
+ OrderedList.execute(line)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MdxTex
4
+ VERSION = '0.1.10'
5
+ end
data/lib/mdx_tex.rb CHANGED
@@ -1,3 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mark_left'
3
+ require 'mdx_tex/version'
4
+ require 'mdx_tex/configuration'
5
+ require 'mdx_tex/to_textile'
6
+
7
+ module MdxTex
8
+ class << self
9
+ attr_writer :configuration
10
+
11
+ def configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def configure
16
+ yield configuration
17
+ end
18
+
19
+ def to_textile(markdown:, **options)
20
+ merged = { header_level: configuration.header_level, list_depth: configuration.list_depth }.merge(options)
21
+ MdxTex::ToTextile.new(**merged).execute(markdown)
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdx-tex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gloria Budiman
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-03-27 00:00:00.000000000 Z
11
12
  dependencies: []
12
13
  description: Converts Markdown syntax to Textile syntax, with configurable header
13
14
  levels and list depth.
@@ -18,16 +19,16 @@ extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
21
  - LICENSE
21
- - lib/mark_left.rb
22
- - lib/mark_left/configuration.rb
23
- - lib/mark_left/engine.rb
24
- - lib/mark_left/to_textile.rb
25
- - lib/mark_left/to_textile/bold.rb
26
- - lib/mark_left/to_textile/header.rb
27
- - lib/mark_left/to_textile/ordered_list.rb
28
- - lib/mark_left/to_textile/unordered_list.rb
29
- - lib/mark_left/version.rb
22
+ - lib/mdx/tex.rb
30
23
  - lib/mdx_tex.rb
24
+ - lib/mdx_tex/configuration.rb
25
+ - lib/mdx_tex/to_textile.rb
26
+ - lib/mdx_tex/to_textile/bold.rb
27
+ - lib/mdx_tex/to_textile/errors.rb
28
+ - lib/mdx_tex/to_textile/header.rb
29
+ - lib/mdx_tex/to_textile/ordered_list.rb
30
+ - lib/mdx_tex/to_textile/unordered_list.rb
31
+ - lib/mdx_tex/version.rb
31
32
  homepage: https://github.com/gbudiman/mark-left
32
33
  licenses:
33
34
  - MIT
@@ -36,6 +37,7 @@ metadata:
36
37
  homepage_uri: https://github.com/gbudiman/mark-left
37
38
  source_code_uri: https://github.com/gbudiman/mark-left
38
39
  changelog_uri: https://github.com/gbudiman/mark-left/blob/main/CHANGELOG.md
40
+ post_install_message:
39
41
  rdoc_options: []
40
42
  require_paths:
41
43
  - lib
@@ -50,7 +52,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
52
  - !ruby/object:Gem::Version
51
53
  version: '0'
52
54
  requirements: []
53
- rubygems_version: 4.0.3
55
+ rubygems_version: 3.5.22
56
+ signing_key:
54
57
  specification_version: 4
55
58
  summary: Convert between Markdown and Textile
56
59
  test_files: []
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if defined?(Rails::Engine)
4
- module MarkLeft
5
- class Engine < ::Rails::Engine
6
- end
7
- end
8
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'mark_left/to_textile/header'
4
- require 'mark_left/to_textile/bold'
5
- require 'mark_left/to_textile/unordered_list'
6
- require 'mark_left/to_textile/ordered_list'
7
-
8
- module MarkLeft
9
- class ToTextile
10
- VALID_HEADER_LEVELS = %w[h1 h2 h3 h4 h5 h6].freeze
11
-
12
- class InvalidListDepthError < ArgumentError
13
- def initialize(value)
14
- super("list_depth must be a positive integer, got: #{value.inspect}")
15
- end
16
-
17
- def self.validate!(value)
18
- raise self, value unless value.is_a?(Integer) && value.positive?
19
- end
20
- end
21
-
22
- class InvalidHeaderLevelError < ArgumentError
23
- def initialize(value)
24
- super("header_level must be one of #{VALID_HEADER_LEVELS.join(', ')}, got: #{value.inspect}")
25
- end
26
-
27
- def self.validate!(value)
28
- raise self, value unless VALID_HEADER_LEVELS.include?(value)
29
- end
30
- end
31
-
32
- def initialize(header_level: 'h3', list_depth: 3)
33
- InvalidHeaderLevelError.validate!(header_level)
34
- InvalidListDepthError.validate!(list_depth)
35
-
36
- @header_level = header_level
37
- @list_depth = list_depth
38
- end
39
-
40
- def convert(input)
41
- return '' if input.nil?
42
-
43
- input.to_s.split("\n", -1).map { |line| convert_line(line) }.join("\n")
44
- end
45
-
46
- private
47
-
48
- def convert_line(line)
49
- line = Header.execute(line, header_level: @header_level)
50
- line = Bold.execute(line)
51
- line = UnorderedList.execute(line, list_depth: @list_depth)
52
- OrderedList.execute(line)
53
- end
54
- end
55
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MarkLeft
4
- VERSION = '0.1.7'
5
- end
data/lib/mark_left.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'mark_left/version'
4
- require 'mark_left/configuration'
5
- require 'mark_left/engine'
6
- require 'mark_left/to_textile'
7
-
8
- module MarkLeft
9
- class << self
10
- attr_writer :configuration
11
-
12
- def configuration
13
- @configuration ||= Configuration.new
14
- end
15
-
16
- def configure
17
- yield configuration
18
- end
19
-
20
- def to_textile(markdown:, **options)
21
- merged = { header_level: configuration.header_level, list_depth: configuration.list_depth }.merge(options)
22
- MarkLeft::ToTextile.new(**merged).convert(markdown)
23
- end
24
- end
25
- end