djot 0.0.6 → 0.0.7
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/.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
data/lib/lua/djot/match.lua
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
local make_match, unpack_match
|
2
|
-
|
3
|
-
if jit or not string.pack then
|
4
|
-
-- for luajit or lua 5.1, we don't have string.pack/unpack, so we use arrays.
|
5
|
-
-- This is faster than using ffi to pack things in C structs.
|
6
|
-
|
7
|
-
make_match = function(startpos, endpos, annotation)
|
8
|
-
return {startpos, endpos, annotation}
|
9
|
-
end
|
10
|
-
|
11
|
-
unpack_match = unpack
|
12
|
-
|
13
|
-
else
|
14
|
-
-- for standard lua >= 5.2, we use string.pack/unpack which gives a
|
15
|
-
-- more memory-efficient representation than arrays.
|
16
|
-
|
17
|
-
make_match = function(startpos, endpos, annotation)
|
18
|
-
return string.pack("=I4I4z", startpos, endpos, annotation)
|
19
|
-
end
|
20
|
-
|
21
|
-
unpack_match = function(match)
|
22
|
-
local startpos, endpos, annotation = string.unpack("=I4I4z", match)
|
23
|
-
return startpos, endpos, annotation
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
local get_length = function(match)
|
28
|
-
local startpos, endpos = unpack_match(match)
|
29
|
-
return 1 + (endpos - startpos)
|
30
|
-
end
|
31
|
-
|
32
|
-
local format_match = function(match)
|
33
|
-
local startpos, endpos, annotation = unpack_match(match)
|
34
|
-
return string.format("%-s %d-%d\n", annotation, startpos, endpos)
|
35
|
-
end
|
36
|
-
|
37
|
-
local function matches_pattern(match, patt)
|
38
|
-
if match then
|
39
|
-
local _, _, annot = unpack_match(match)
|
40
|
-
return string.find(annot, patt)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
return {
|
45
|
-
make_match = make_match,
|
46
|
-
unpack_match = unpack_match,
|
47
|
-
get_length = get_length,
|
48
|
-
format_match = format_match,
|
49
|
-
matches_pattern = matches_pattern
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
|
-
--[[
|
54
|
-
Copyright (C) 2022 John MacFarlane
|
55
|
-
|
56
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
57
|
-
a copy of this software and associated documentation files (the
|
58
|
-
"Software"), to deal in the Software without restriction, including
|
59
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
60
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
61
|
-
permit persons to whom the Software is furnished to do so, subject to
|
62
|
-
the following conditions:
|
63
|
-
|
64
|
-
The above copyright notice and this permission notice shall be included
|
65
|
-
in all copies or substantial portions of the Software.
|
66
|
-
|
67
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
68
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
69
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
70
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
71
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
72
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
73
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
74
|
-
|
75
|
-
]]
|
data/lib/lua/djot.lua
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
local block = require("djot.block")
|
2
|
-
local ast = require("djot.ast")
|
3
|
-
local html = require("djot.html")
|
4
|
-
local match = require("djot.match")
|
5
|
-
|
6
|
-
local format_match = match.format_match
|
7
|
-
|
8
|
-
local StringHandle = {}
|
9
|
-
|
10
|
-
function StringHandle:new()
|
11
|
-
local buffer = {}
|
12
|
-
setmetatable(buffer, StringHandle)
|
13
|
-
StringHandle.__index = StringHandle
|
14
|
-
return buffer
|
15
|
-
end
|
16
|
-
|
17
|
-
function StringHandle:write(s)
|
18
|
-
self[#self + 1] = s
|
19
|
-
end
|
20
|
-
|
21
|
-
function StringHandle:flush()
|
22
|
-
local result = table.concat(self)
|
23
|
-
self = {}
|
24
|
-
return result
|
25
|
-
end
|
26
|
-
|
27
|
-
local Parser = block.Parser
|
28
|
-
|
29
|
-
function Parser:issue_warnings(handle)
|
30
|
-
if self.opts.verbose then
|
31
|
-
local warnings = self.warnings
|
32
|
-
for i=1,#warnings do
|
33
|
-
handle:write(string.format("Warning: %s at byte position %d\n",
|
34
|
-
warnings[i][2], warnings[i][1]))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
function Parser:render_matches(handle)
|
40
|
-
if not handle then
|
41
|
-
handle = StringHandle:new()
|
42
|
-
end
|
43
|
-
local matches = self:get_matches()
|
44
|
-
self:issue_warnings(io.stderr)
|
45
|
-
for i=1,#matches do
|
46
|
-
handle:write(format_match(matches[i]))
|
47
|
-
end
|
48
|
-
return handle:flush()
|
49
|
-
end
|
50
|
-
|
51
|
-
function Parser:build_ast()
|
52
|
-
self.ast = ast.to_ast(self.subject, self.matches, self.opts)
|
53
|
-
end
|
54
|
-
|
55
|
-
function Parser:render_ast(handle)
|
56
|
-
if not handle then
|
57
|
-
handle = StringHandle:new()
|
58
|
-
end
|
59
|
-
if not self.ast then
|
60
|
-
self:build_ast()
|
61
|
-
end
|
62
|
-
self:issue_warnings(io.stderr)
|
63
|
-
ast.render(self.ast, handle)
|
64
|
-
return handle:flush()
|
65
|
-
end
|
66
|
-
|
67
|
-
function Parser:render_html(handle)
|
68
|
-
if not handle then
|
69
|
-
handle = StringHandle:new()
|
70
|
-
end
|
71
|
-
if not self.ast then
|
72
|
-
self:build_ast()
|
73
|
-
end
|
74
|
-
self:issue_warnings(io.stderr)
|
75
|
-
local renderer = html.Renderer:new()
|
76
|
-
renderer:render(self.ast, handle)
|
77
|
-
return handle:flush()
|
78
|
-
end
|
79
|
-
|
80
|
-
return {
|
81
|
-
Parser = Parser
|
82
|
-
}
|
83
|
-
|
84
|
-
|
85
|
-
--[[
|
86
|
-
Copyright (C) 2022 John MacFarlane
|
87
|
-
|
88
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
89
|
-
a copy of this software and associated documentation files (the
|
90
|
-
"Software"), to deal in the Software without restriction, including
|
91
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
92
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
93
|
-
permit persons to whom the Software is furnished to do so, subject to
|
94
|
-
the following conditions:
|
95
|
-
|
96
|
-
The above copyright notice and this permission notice shall be included
|
97
|
-
in all copies or substantial portions of the Software.
|
98
|
-
|
99
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
100
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
101
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
102
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
103
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
104
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
105
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
106
|
-
|
107
|
-
]]
|