mdx-tex 0.1.8 → 0.1.11
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 +4 -4
- data/lib/mdx/tex.rb +1 -1
- data/lib/{mark_left → mdx_tex}/configuration.rb +9 -7
- data/lib/mdx_tex/core_ext/string.rb +13 -0
- data/lib/mdx_tex/railtie.rb +9 -0
- data/lib/{mark_left → mdx_tex}/to_textile/bold.rb +1 -1
- data/lib/mdx_tex/to_textile/errors.rb +27 -0
- data/lib/{mark_left → mdx_tex}/to_textile/header.rb +1 -1
- data/lib/{mark_left → mdx_tex}/to_textile/ordered_list.rb +1 -1
- data/lib/{mark_left → mdx_tex}/to_textile/unordered_list.rb +1 -1
- data/lib/mdx_tex/to_textile.rb +34 -0
- data/lib/mdx_tex/version.rb +5 -0
- data/lib/mdx_tex.rb +28 -1
- metadata +20 -16
- data/lib/mark_left/engine.rb +0 -8
- data/lib/mark_left/to_textile.rb +0 -55
- data/lib/mark_left/version.rb +0 -5
- data/lib/mark_left.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8b32c8e4c6ace0e3ae05f67c941839f6b2eb60a907b5961f7068a9e4a6c141d
|
|
4
|
+
data.tar.gz: 5b5c0cf00f434f2ef571d68203b6fc93279b9710cca9fdac68cf50fbb3de12a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e645ed99556afc0982ff09ad7dfd2cc967c943ad3aa4441df092583738357b852507eeb928b414d9f9aae98474e0e6c1cf54ae5238ff79237bf49181f9f389d3
|
|
7
|
+
data.tar.gz: b0c8df3a5d0dc1e49ef3b0dc83d2c730580853e05611e51446f53b77c19a33cb172f61b44be2a89db1590a8e02820f3ed424820eefbd7cde774861b3e1f3c308
|
data/lib/mdx/tex.rb
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
# Holds global defaults for all
|
|
5
|
-
# Override these in an initializer (e.g. config/initializers/
|
|
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
|
-
#
|
|
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
|
-
#
|
|
14
|
+
# MdxTex.to_textile(markdown: markdown, list_depth: 1)
|
|
15
15
|
class Configuration
|
|
16
16
|
attr_reader :header_level, :list_depth
|
|
17
|
+
attr_accessor :enable_string_extension
|
|
17
18
|
|
|
18
19
|
def initialize
|
|
19
20
|
@header_level = 'h3'
|
|
20
21
|
@list_depth = 3
|
|
22
|
+
@enable_string_extension = false
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def header_level=(value)
|
|
24
|
-
|
|
26
|
+
MdxTex::ToTextile::InvalidHeaderLevelError.validate!(value)
|
|
25
27
|
@header_level = value
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
def list_depth=(value)
|
|
29
|
-
|
|
31
|
+
MdxTex::ToTextile::InvalidListDepthError.validate!(value)
|
|
30
32
|
@list_depth = value
|
|
31
33
|
end
|
|
32
34
|
end
|
|
@@ -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
|
|
@@ -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
|
data/lib/mdx_tex.rb
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
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
|
+
|
|
24
|
+
def load_string_extension!
|
|
25
|
+
require 'mdx_tex/core_ext/string'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
require 'mdx_tex/railtie' if defined?(Rails::Railtie)
|
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.
|
|
4
|
+
version: 0.1.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gloria Budiman
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
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,25 +19,27 @@ 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
|
|
30
22
|
- lib/mdx/tex.rb
|
|
31
23
|
- lib/mdx_tex.rb
|
|
32
|
-
|
|
24
|
+
- lib/mdx_tex/configuration.rb
|
|
25
|
+
- lib/mdx_tex/core_ext/string.rb
|
|
26
|
+
- lib/mdx_tex/railtie.rb
|
|
27
|
+
- lib/mdx_tex/to_textile.rb
|
|
28
|
+
- lib/mdx_tex/to_textile/bold.rb
|
|
29
|
+
- lib/mdx_tex/to_textile/errors.rb
|
|
30
|
+
- lib/mdx_tex/to_textile/header.rb
|
|
31
|
+
- lib/mdx_tex/to_textile/ordered_list.rb
|
|
32
|
+
- lib/mdx_tex/to_textile/unordered_list.rb
|
|
33
|
+
- lib/mdx_tex/version.rb
|
|
34
|
+
homepage: https://github.com/gbudiman/mdx-tex
|
|
33
35
|
licenses:
|
|
34
36
|
- MIT
|
|
35
37
|
metadata:
|
|
36
38
|
rubygems_mfa_required: 'true'
|
|
37
|
-
homepage_uri: https://github.com/gbudiman/
|
|
38
|
-
source_code_uri: https://github.com/gbudiman/
|
|
39
|
-
changelog_uri: https://github.com/gbudiman/
|
|
39
|
+
homepage_uri: https://github.com/gbudiman/mdx-tex
|
|
40
|
+
source_code_uri: https://github.com/gbudiman/mdx-tex
|
|
41
|
+
changelog_uri: https://github.com/gbudiman/mdx-tex/blob/main/CHANGELOG.md
|
|
42
|
+
post_install_message:
|
|
40
43
|
rdoc_options: []
|
|
41
44
|
require_paths:
|
|
42
45
|
- lib
|
|
@@ -51,7 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
51
54
|
- !ruby/object:Gem::Version
|
|
52
55
|
version: '0'
|
|
53
56
|
requirements: []
|
|
54
|
-
rubygems_version:
|
|
57
|
+
rubygems_version: 3.5.22
|
|
58
|
+
signing_key:
|
|
55
59
|
specification_version: 4
|
|
56
60
|
summary: Convert between Markdown and Textile
|
|
57
61
|
test_files: []
|
data/lib/mark_left/engine.rb
DELETED
data/lib/mark_left/to_textile.rb
DELETED
|
@@ -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
|
data/lib/mark_left/version.rb
DELETED
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
|