djot 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +7 -15
- data/CHANGELOG.md +21 -0
- data/Dockerfile +10 -0
- data/README.md +3 -6
- data/Rakefile +1 -17
- data/djot.gemspec +2 -2
- data/lib/djot/javascript.rb +4 -2
- data/lib/djot/pure.rb +4 -0
- data/lib/djot/version.rb +1 -1
- data/lib/djot.rb +6 -10
- data/manifest.scm +2 -0
- data/sig/djot.gen.rbs +3 -13
- data/sig/djot.rbs +0 -3
- metadata +13 -32
- data/lib/djot/lua.rb +0 -52
- data/lib/lua/djot/ast.lua +0 -642
- data/lib/lua/djot/attributes.lua +0 -273
- data/lib/lua/djot/block.lua +0 -807
- data/lib/lua/djot/emoji.lua +0 -1880
- data/lib/lua/djot/html.lua +0 -557
- data/lib/lua/djot/inline.lua +0 -641
- data/lib/lua/djot/match.lua +0 -75
- data/lib/lua/djot.lua +0 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b05a8f0740be3ef7a6d70beef262278b751c2c2bf7b199831857a00ea1209b15
|
4
|
+
data.tar.gz: b4f037b12f3c5f96807b3b4b089df2f2b266b4e8b3cec58c4a96016b653fa143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c51a726fe392ac8085ea2014aab561bff1596d6f70b28583c8147fecfa2e5b8e10e70df8c0420d92cf8f997f9ac7a714c7ddab22707dccd51e14626516c9473
|
7
|
+
data.tar.gz: 1ef8cc01d4a8076d1763799d304a3b7bf67a383bdd1abe9ff3b47ddde419474175bcbf7310552be00c1bd95a2e50ef96abfc8dbe9f044e6b3c84daf202cba313
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,23 +1,15 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2023-
|
3
|
+
# on 2023-05-25 12:41:00 UTC using RuboCop version 1.50.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 1
|
10
|
-
# Configuration parameters:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# AllowedMethods: refine
|
17
|
-
Metrics/BlockLength:
|
18
|
-
Max: 37
|
19
|
-
|
20
|
-
# Offense count: 2
|
21
|
-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
22
|
-
Metrics/MethodLength:
|
23
|
-
Max: 22
|
10
|
+
# Configuration parameters: AllowedConstants.
|
11
|
+
Style/Documentation:
|
12
|
+
Exclude:
|
13
|
+
- 'spec/**/*'
|
14
|
+
- 'test/**/*'
|
15
|
+
- 'lib/djot/pure.rb'
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,27 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [0.0.7] - 2023-05-25
|
6
|
+
|
7
|
+
### Removed
|
8
|
+
|
9
|
+
* References to Lua implementation (djot.lua)
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
* Update djot.js to v0.2.1.
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
* `Djot.render_html` to accept `warn` option
|
18
|
+
* Remove `Djot.render_matches`
|
19
|
+
* `Djot.render_ast` to accept `source_positions` option
|
20
|
+
* `Djot::JavaScript` to accept `source_positions` option
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
* Sckelton `Djot::Pure` module for pure Ruby implementation
|
25
|
+
|
5
26
|
## [0.0.6] - 2023-01-31
|
6
27
|
|
7
28
|
Note again that the default parser might be changed from djot.lua to djot.js in future version.
|
data/Dockerfile
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Djot
|
2
2
|
|
3
|
-
[Djot](https://djot.net/) parser for Ruby, using original JavaScript ([jdm/djot.js](https://github.com/jgm/djot.js))
|
3
|
+
[Djot](https://djot.net/) parser for Ruby, using original JavaScript ([jdm/djot.js](https://github.com/jgm/djot.js)) implementation.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -57,8 +57,6 @@ and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
57
57
|
|
58
58
|
* Create document class (and more) for idiomatic control in Ruby.
|
59
59
|
* Write parser in pure Ruby.
|
60
|
-
* Make JavaScript version as default. Currently the default is Lua version.
|
61
|
-
* Update Lua implementation from djot to djot.lua.
|
62
60
|
|
63
61
|
## Contributing
|
64
62
|
|
@@ -70,9 +68,8 @@ to the [code of conduct](CODE_OF_CONDUCT.md).
|
|
70
68
|
|
71
69
|
## Acknowledgement
|
72
70
|
|
73
|
-
As mentioned earlier, this library only calls the original JavaScript
|
74
|
-
|
75
|
-
This gem also uses [MiniRacer](https://github.com/rubyjs/mini_racer) and [ruby-lua](https://github.com/glejeune/ruby-lua) to call JavaScript and Lua source codes respectibly.
|
71
|
+
As mentioned earlier, this library only calls the original JavaScript implementation; the important work is done in that library.
|
72
|
+
This gem also uses [MiniRacer](https://github.com/rubyjs/mini_racer) to call JavaScript source code.
|
76
73
|
|
77
74
|
## License
|
78
75
|
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ require "rubocop/rake_task"
|
|
11
11
|
|
12
12
|
RuboCop::RakeTask.new
|
13
13
|
|
14
|
-
task default: %i[
|
14
|
+
task default: %i[copy_js test rubocop sig mdl]
|
15
15
|
|
16
16
|
desc "Copy JavaScript files"
|
17
17
|
task copy_js: "lib/js/djot.js"
|
@@ -30,22 +30,6 @@ end
|
|
30
30
|
|
31
31
|
directory "lib/js"
|
32
32
|
|
33
|
-
desc "Copy Lua files"
|
34
|
-
task copy: "lib/lua/djot" do
|
35
|
-
license = File.read("vendor/djot/LICENSE")
|
36
|
-
(["vendor/djot/djot.lua"] + Dir["vendor/djot/djot/*.lua"]).each do |file|
|
37
|
-
File.write(file.sub(%r{vendor/djot}, "lib/lua"), <<~END_LUA)
|
38
|
-
#{File.read(file)}
|
39
|
-
|
40
|
-
--[[
|
41
|
-
#{license}
|
42
|
-
]]
|
43
|
-
END_LUA
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
directory "lib/lua/djot"
|
48
|
-
|
49
33
|
require "rdoc/task"
|
50
34
|
|
51
35
|
RDoc::Task.new do |rdoc|
|
data/djot.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.email = ["gemmaro.dev@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = "Djot parser"
|
10
|
-
spec.description = "djot gem provides parsing functions using original JavaScript
|
10
|
+
spec.description = "djot gem provides parsing functions using original JavaScript implementation"
|
11
11
|
spec.homepage = "https://gitlab.com/gemmaro/ruby-djot"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = ">= 2.6.0"
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
end
|
27
27
|
|
28
28
|
spec.require_paths = ["lib"]
|
29
|
+
spec.rdoc_options << "--include" << "lib"
|
29
30
|
|
30
31
|
spec.add_dependency "mini_racer", "~> 0.6.3"
|
31
|
-
spec.add_dependency "ruby-lua", "~> 0.4"
|
32
32
|
end
|
data/lib/djot/javascript.rb
CHANGED
@@ -70,8 +70,10 @@ module Djot
|
|
70
70
|
|
71
71
|
# Correspond to +djot.renderAST+
|
72
72
|
# (https://github.com/jgm/djot.js#pretty-printing-the-djot-ast)
|
73
|
-
def self.render_ast(doc)
|
74
|
-
|
73
|
+
def self.render_ast(doc, source_positions: false)
|
74
|
+
args = [doc]
|
75
|
+
args << { "sourcePositions" => source_positions } if source_positions
|
76
|
+
context.eval("djot.renderAST.apply(this, #{JSON.generate(args)})")
|
75
77
|
end
|
76
78
|
|
77
79
|
# Correspond to +djot.renderHTML+
|
data/lib/djot/pure.rb
ADDED
data/lib/djot/version.rb
CHANGED
data/lib/djot.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
require_relative "djot/version"
|
2
2
|
require_relative "djot/javascript"
|
3
|
-
require_relative "djot/
|
3
|
+
require_relative "djot/pure"
|
4
4
|
|
5
5
|
# Provides Djot parsing functionalities.
|
6
|
-
# +Djot.*+ methods are pointing to
|
6
|
+
# +Djot.*+ methods are pointing to JavaScript implementation now.
|
7
7
|
# See also Djot::JavaScript for ones pointing to JavaScript implementation.
|
8
8
|
module Djot
|
9
9
|
class Error < StandardError; end
|
10
10
|
|
11
|
-
def self.render_html(
|
12
|
-
|
11
|
+
def self.render_html(doc, warn: nil)
|
12
|
+
JavaScript.render_html(doc, warn: warn)
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.render_ast(input)
|
20
|
-
Lua.render_ast(input)
|
15
|
+
def self.render_ast(input, source_positions: false)
|
16
|
+
JavaScript.render_ast(input, source_positions: source_positions)
|
21
17
|
end
|
22
18
|
end
|
data/manifest.scm
ADDED
data/sig/djot.gen.rbs
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# TypeProf 0.21.
|
1
|
+
# TypeProf 0.21.7
|
2
2
|
|
3
3
|
# Classes
|
4
4
|
module Djot
|
5
5
|
VERSION: String
|
6
6
|
|
7
|
-
def self.render_html: (untyped input) -> untyped
|
7
|
+
def self.render_html: (untyped input) -> ((Array[untyped] | Hash[untyped, untyped] | MiniRacer::JavaScriptFunction | Time)?)
|
8
8
|
def self.render_matches: (untyped input) -> untyped
|
9
|
-
def self.render_ast: (untyped input) -> untyped
|
9
|
+
def self.render_ast: (untyped input) -> ((Array[untyped] | Hash[untyped, untyped] | MiniRacer::JavaScriptFunction | Time)?)
|
10
10
|
|
11
11
|
module JavaScript
|
12
12
|
PATH: Pathname
|
@@ -29,14 +29,4 @@ module Djot
|
|
29
29
|
def self.version: -> ((Array[untyped] | Hash[untyped, untyped] | MiniRacer::JavaScriptFunction | Time)?)
|
30
30
|
def self.call: (String name, *Hash[String, untyped] args) -> ((Array[untyped] | Hash[untyped, untyped] | MiniRacer::JavaScriptFunction | Time)?)
|
31
31
|
end
|
32
|
-
|
33
|
-
module Lua
|
34
|
-
LUA: untyped
|
35
|
-
ROOT: Pathname
|
36
|
-
|
37
|
-
def self.render_html: (untyped input) -> untyped
|
38
|
-
def self.render_matches: (untyped input) -> untyped
|
39
|
-
def self.render_ast: (untyped input) -> untyped
|
40
|
-
def self.run_at_root: { (String) -> untyped } -> untyped
|
41
|
-
end
|
42
32
|
end
|
data/sig/djot.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gemmaro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_racer
|
@@ -24,22 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.6.3
|
27
|
-
|
28
|
-
name: ruby-lua
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.4'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.4'
|
41
|
-
description: djot gem provides parsing functions using original JavaScript and Lua
|
42
|
-
implementations
|
27
|
+
description: djot gem provides parsing functions using original JavaScript implementation
|
43
28
|
email:
|
44
29
|
- gemmaro.dev@gmail.com
|
45
30
|
executables: []
|
@@ -52,6 +37,7 @@ files:
|
|
52
37
|
- ".rubocop_todo.yml"
|
53
38
|
- CHANGELOG.md
|
54
39
|
- CODE_OF_CONDUCT.md
|
40
|
+
- Dockerfile
|
55
41
|
- Gemfile
|
56
42
|
- LICENSE.txt
|
57
43
|
- README.md
|
@@ -60,17 +46,10 @@ files:
|
|
60
46
|
- djot.gemspec
|
61
47
|
- lib/djot.rb
|
62
48
|
- lib/djot/javascript.rb
|
63
|
-
- lib/djot/
|
49
|
+
- lib/djot/pure.rb
|
64
50
|
- lib/djot/version.rb
|
65
51
|
- lib/js/djot.js
|
66
|
-
-
|
67
|
-
- lib/lua/djot/ast.lua
|
68
|
-
- lib/lua/djot/attributes.lua
|
69
|
-
- lib/lua/djot/block.lua
|
70
|
-
- lib/lua/djot/emoji.lua
|
71
|
-
- lib/lua/djot/html.lua
|
72
|
-
- lib/lua/djot/inline.lua
|
73
|
-
- lib/lua/djot/match.lua
|
52
|
+
- manifest.scm
|
74
53
|
- sig/djot.gen.rbs
|
75
54
|
- sig/djot.rbs
|
76
55
|
homepage: https://gitlab.com/gemmaro/ruby-djot
|
@@ -81,8 +60,10 @@ metadata:
|
|
81
60
|
source_code_uri: https://gitlab.com/gemmaro/ruby-djot
|
82
61
|
changelog_uri: https://gitlab.com/gemmaro/ruby-djot/blob/main/CHANGELOG.md
|
83
62
|
rubygems_mfa_required: 'true'
|
84
|
-
post_install_message:
|
85
|
-
rdoc_options:
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- "--include"
|
66
|
+
- lib
|
86
67
|
require_paths:
|
87
68
|
- lib
|
88
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -96,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
77
|
- !ruby/object:Gem::Version
|
97
78
|
version: '0'
|
98
79
|
requirements: []
|
99
|
-
rubygems_version: 3.4.
|
100
|
-
signing_key:
|
80
|
+
rubygems_version: 3.4.10
|
81
|
+
signing_key:
|
101
82
|
specification_version: 4
|
102
83
|
summary: Djot parser
|
103
84
|
test_files: []
|
data/lib/djot/lua.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require "language/lua"
|
2
|
-
require "pathname"
|
3
|
-
|
4
|
-
module Djot
|
5
|
-
# Functionalities of djot (Lua implementation)
|
6
|
-
module Lua
|
7
|
-
LUA = Language::Lua.new # :nodoc:
|
8
|
-
LUA.eval(<<~END_LUA)
|
9
|
-
function djot_parser(input)
|
10
|
-
local parser = require("djot").Parser:new(input)
|
11
|
-
parser:parse()
|
12
|
-
return parser
|
13
|
-
end
|
14
|
-
|
15
|
-
function djot_render_html(input)
|
16
|
-
return djot_parser(input):render_html()
|
17
|
-
end
|
18
|
-
|
19
|
-
function djot_render_matches(input)
|
20
|
-
return djot_parser(input):render_matches()
|
21
|
-
end
|
22
|
-
|
23
|
-
function djot_render_ast(input)
|
24
|
-
return djot_parser(input):render_ast()
|
25
|
-
end
|
26
|
-
END_LUA
|
27
|
-
|
28
|
-
ROOT = Pathname(__dir__ || (raise Error)) / ".." / "lua" # :nodoc:
|
29
|
-
|
30
|
-
def self.render_html(input)
|
31
|
-
run_at_root do
|
32
|
-
LUA.djot_render_html(input)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.render_matches(input)
|
37
|
-
run_at_root do
|
38
|
-
LUA.djot_render_matches(input)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.render_ast(input)
|
43
|
-
run_at_root do
|
44
|
-
LUA.djot_render_ast(input)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.run_at_root(&block) # :nodoc:
|
49
|
-
Dir.chdir(ROOT.to_s, &block)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|