elisp2any 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/CHANGELOG.md +11 -0
- data/README.md +16 -2
- data/Rakefile +5 -7
- data/exe/elisp2any +28 -4
- data/lib/elisp/comment.rb +15 -76
- data/lib/elisp/default.css +11 -0
- data/lib/elisp/doc_string_parser.rb +96 -0
- data/lib/elisp/heading.rb +31 -0
- data/lib/elisp/parser.rb +23 -50
- data/lib/elisp/version.rb +18 -0
- data/lib/elisp.rb +19 -62
- metadata +7 -26
- data/lib/elisp2any/aside.rb +0 -23
- data/lib/elisp2any/blanklines.rb +0 -20
- data/lib/elisp2any/code.rb +0 -49
- data/lib/elisp2any/codeblock.rb +0 -56
- data/lib/elisp2any/comment.rb +0 -19
- data/lib/elisp2any/commentary.rb +0 -32
- data/lib/elisp2any/expression.rb +0 -90
- data/lib/elisp2any/footer_line.rb +0 -28
- data/lib/elisp2any/header_line.rb +0 -80
- data/lib/elisp2any/heading.rb +0 -68
- data/lib/elisp2any/html_renderer/index.html.erb +0 -23
- data/lib/elisp2any/html_renderer.erb +0 -22
- data/lib/elisp2any/html_renderer.rb +0 -149
- data/lib/elisp2any/inline_code.rb +0 -10
- data/lib/elisp2any/line.rb +0 -52
- data/lib/elisp2any/paragraph.rb +0 -37
- data/lib/elisp2any/section.rb +0 -49
- data/lib/elisp2any/text.rb +0 -33
- data/lib/elisp2any/version.rb +0 -4
- data/lib/elisp2any.rb +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bf30639582d2ecf42060b4db852d32438545e209b2c2eeac8b23ded371a4d50
|
|
4
|
+
data.tar.gz: 0ae7c862c01e4e5cdb0995d2ce31d6fe8b0df253f3e29ffd58fd5bfed580edbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 747da66f11028d3da70cc731b5bf60e3ed44a261c19359022a33d3a151611e14df560dae64ec650ecb4cb8e8bc9509164e76f72586a7454d44ddf76805d8c856
|
|
7
|
+
data.tar.gz: 63928b7c7b20e1e045159f3457b309e47c9be922c63ce3fda708ac1be98b46c66000052cc7849d157ddce7d8dd1127dc39ba21b2f1a6ea49d9bd3869707c9fca
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Change log of Elisp2any
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.0.7 - 2026-07-05
|
|
6
|
+
|
|
7
|
+
* Add dump flag for debugging.
|
|
8
|
+
* Allow other variables in headers.
|
|
9
|
+
* Remove sidebar.
|
|
10
|
+
* Markup copyright mark.
|
|
11
|
+
* Hide navigation by default.
|
|
12
|
+
* Add comments for command line options.
|
|
13
|
+
|
|
3
14
|
## 0.0.6 - 2025-06-22
|
|
4
15
|
|
|
5
16
|
Removed previous parsers and added simple strscan base parser.
|
data/README.md
CHANGED
|
@@ -15,6 +15,8 @@ $ elisp2any --input /path/to/input/file --output /path/to/output/file
|
|
|
15
15
|
|
|
16
16
|
## Development
|
|
17
17
|
|
|
18
|
+
To run tests, run `test-unit`.
|
|
19
|
+
|
|
18
20
|
Two paragraph types:
|
|
19
21
|
|
|
20
22
|
```emacs-lisp
|
|
@@ -38,5 +40,17 @@ Bug reports and pull requests are welcome.
|
|
|
38
40
|
|
|
39
41
|
## License
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
Copyright (C) 2025 gemmaro
|
|
44
|
+
|
|
45
|
+
This program is free software: you can redistribute it and/or modify
|
|
46
|
+
it under the terms of the GNU General Public License as published by
|
|
47
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
48
|
+
(at your option) any later version.
|
|
49
|
+
|
|
50
|
+
This program is distributed in the hope that it will be useful,
|
|
51
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
52
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
53
|
+
GNU General Public License for more details.
|
|
54
|
+
|
|
55
|
+
You should have received a copy of the GNU General Public License
|
|
56
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
require 'bundler/gem_tasks'
|
|
2
|
-
require
|
|
2
|
+
require "open3"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
task :deploy do
|
|
5
|
+
out, _stat = Open3.capture2("./bin/dev")
|
|
6
|
+
File.write("/tmp/index.html", out)
|
|
7
|
+
sh "rsync", "-av", "/tmp/index.html", "pi:/srv/www/emacs/"
|
|
8
8
|
end
|
|
9
|
-
|
|
10
|
-
task default: :test
|
data/exe/elisp2any
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
+
# Copyright (C) 2025 gemmaro
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
3
18
|
require 'optparse'
|
|
4
19
|
|
|
5
20
|
$LOAD_PATH << File.join(__dir__, "../lib")
|
|
@@ -8,19 +23,28 @@ require 'elisp'
|
|
|
8
23
|
input = $stdin
|
|
9
24
|
output = $stdout
|
|
10
25
|
css = nil
|
|
26
|
+
dump = false
|
|
11
27
|
|
|
12
28
|
OptionParser.new do |parser|
|
|
13
|
-
parser.on('--input=PATH') do |path|
|
|
29
|
+
parser.on('--input=PATH', 'ELisp file (default: stdin)') do |path|
|
|
14
30
|
input = File.open(path)
|
|
15
31
|
end
|
|
16
32
|
|
|
17
|
-
parser.on('--output=PATH') do |path|
|
|
33
|
+
parser.on('--output=PATH', 'HTML file (default: stdout)') do |path|
|
|
18
34
|
output = File.open(path, 'w')
|
|
19
35
|
end
|
|
20
36
|
|
|
21
|
-
parser.on('--css=PATH') do |path|
|
|
37
|
+
parser.on('--css=PATH', 'stylesheet') do |path|
|
|
22
38
|
css = path
|
|
23
39
|
end
|
|
40
|
+
|
|
41
|
+
parser.on("--dump") { dump = true }
|
|
24
42
|
end.parse!
|
|
25
43
|
|
|
26
|
-
Elisp.parse(input)
|
|
44
|
+
doc = Elisp.parse(input)
|
|
45
|
+
if dump
|
|
46
|
+
pp doc
|
|
47
|
+
exit
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
doc.write(output, css:)
|
data/lib/elisp/comment.rb
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# Copyright (C) 2025 gemmaro
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
1
16
|
class Elisp::Comment
|
|
2
17
|
def initialize(content)
|
|
3
18
|
@content = content
|
|
@@ -15,79 +30,3 @@ class Elisp::Comment
|
|
|
15
30
|
self.class.parse(@content)
|
|
16
31
|
end
|
|
17
32
|
end
|
|
18
|
-
|
|
19
|
-
class Elisp::DocStringParser
|
|
20
|
-
URI_PATTERN = URI.regexp
|
|
21
|
-
URI_PATTERN_WITH_ANGLES = /[<](?<uri>#{ URI_PATTERN })[>]/
|
|
22
|
-
EMAIL = Regexp.new(URI::MailTo::EMAIL_REGEXP.to_s
|
|
23
|
-
.sub(/\A[(][?]-mix:\\A/, "(?-mix:")
|
|
24
|
-
.sub(/\\z[)]\z/, ")"))
|
|
25
|
-
EMAIL_WITH_ANGLES = /[<](?<address>#{ EMAIL })[>]/
|
|
26
|
-
|
|
27
|
-
def initialize(source)
|
|
28
|
-
@scanner = StringScanner.new(source)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def html
|
|
32
|
-
result = +""
|
|
33
|
-
normal = +""
|
|
34
|
-
until @scanner.eos?
|
|
35
|
-
if @scanner.skip(/[`](?<code>[A-Za-z!.-]+)[']/)
|
|
36
|
-
result << normal
|
|
37
|
-
normal.clear
|
|
38
|
-
code = CGI.escape_html(@scanner[:code])
|
|
39
|
-
result << "<code>#{code}</code>"
|
|
40
|
-
normal.clear
|
|
41
|
-
elsif @scanner.skip(/\\\\=(?<quote>['`])/)
|
|
42
|
-
normal << @scanner[:quote]
|
|
43
|
-
elsif (uri = scan_http_uri)
|
|
44
|
-
result << normal
|
|
45
|
-
normal.clear
|
|
46
|
-
result << html_url(uri)
|
|
47
|
-
elsif (address = scan_email)
|
|
48
|
-
result << normal
|
|
49
|
-
normal.clear
|
|
50
|
-
uri = CGI.escape(address)
|
|
51
|
-
address = CGI.escape_html(address)
|
|
52
|
-
result << %(<a href="mailto:#{uri}">#{address}</a>)
|
|
53
|
-
else
|
|
54
|
-
normal << @scanner.getch
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
result << normal
|
|
58
|
-
normal.clear
|
|
59
|
-
result
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def scan_email
|
|
63
|
-
if (address = @scanner.scan(EMAIL))
|
|
64
|
-
address
|
|
65
|
-
elsif @scanner.skip(EMAIL_WITH_ANGLES)
|
|
66
|
-
@scanner[:address]
|
|
67
|
-
else
|
|
68
|
-
return
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def scan_http_uri
|
|
73
|
-
if (uri = @scanner.scan(URI_PATTERN))
|
|
74
|
-
elsif @scanner.skip(URI_PATTERN_WITH_ANGLES)
|
|
75
|
-
uri = @scanner[:uri]
|
|
76
|
-
else
|
|
77
|
-
return
|
|
78
|
-
end
|
|
79
|
-
uri = URI(uri)
|
|
80
|
-
unless uri.is_a?(URI::HTTP)
|
|
81
|
-
@scanner.unscan
|
|
82
|
-
return
|
|
83
|
-
end
|
|
84
|
-
uri
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def html_url(url)
|
|
88
|
-
url = url.to_s
|
|
89
|
-
ref = CGI.escape(url)
|
|
90
|
-
label = CGI.escape_html(url)
|
|
91
|
-
%(<a class="pure-url" href="#{ref}">#{label}</a>)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Copyright (C) 2025 gemmaro
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
require "cgi"
|
|
17
|
+
require "uri"
|
|
18
|
+
require "strscan"
|
|
19
|
+
|
|
20
|
+
class Elisp::DocStringParser
|
|
21
|
+
URI_PATTERN = URI.regexp
|
|
22
|
+
URI_PATTERN_WITH_ANGLES = /[<](?<uri>#{ URI_PATTERN })[>]/
|
|
23
|
+
EMAIL = Regexp.new(URI::MailTo::EMAIL_REGEXP.to_s
|
|
24
|
+
.sub(/\A[(][?]-mix:\\A/, "(?-mix:")
|
|
25
|
+
.sub(/\\z[)]\z/, ")"))
|
|
26
|
+
EMAIL_WITH_ANGLES = /[<](?<address>#{ EMAIL })[>]/
|
|
27
|
+
|
|
28
|
+
def initialize(source)
|
|
29
|
+
@scanner = StringScanner.new(source)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def html
|
|
33
|
+
result = +""
|
|
34
|
+
normal = +""
|
|
35
|
+
until @scanner.eos?
|
|
36
|
+
if @scanner.skip(/[`](?<code>[A-Za-z!.-]+)[']/)
|
|
37
|
+
result << normal
|
|
38
|
+
normal.clear
|
|
39
|
+
code = CGI.escape_html(@scanner[:code])
|
|
40
|
+
result << "<code>#{code}</code>"
|
|
41
|
+
normal.clear
|
|
42
|
+
elsif @scanner.skip(/\\\\=(?<quote>['`])/)
|
|
43
|
+
normal << @scanner[:quote]
|
|
44
|
+
elsif (uri = scan_http_uri)
|
|
45
|
+
result << normal
|
|
46
|
+
normal.clear
|
|
47
|
+
result << html_url(uri)
|
|
48
|
+
elsif (address = scan_email)
|
|
49
|
+
result << normal
|
|
50
|
+
normal.clear
|
|
51
|
+
uri = CGI.escape(address)
|
|
52
|
+
address = CGI.escape_html(address)
|
|
53
|
+
result << %(<a href="mailto:#{uri}">#{address}</a>)
|
|
54
|
+
elsif @scanner.skip(/Copyright [(]C[)]/)
|
|
55
|
+
result << "Copyright ©"
|
|
56
|
+
else
|
|
57
|
+
normal << @scanner.getch
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
result << normal
|
|
61
|
+
normal.clear
|
|
62
|
+
result
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def scan_email
|
|
66
|
+
if (address = @scanner.scan(EMAIL))
|
|
67
|
+
address
|
|
68
|
+
elsif @scanner.skip(EMAIL_WITH_ANGLES)
|
|
69
|
+
@scanner[:address]
|
|
70
|
+
else
|
|
71
|
+
return
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def scan_http_uri
|
|
76
|
+
if (uri = @scanner.scan(URI_PATTERN))
|
|
77
|
+
elsif @scanner.skip(URI_PATTERN_WITH_ANGLES)
|
|
78
|
+
uri = @scanner[:uri]
|
|
79
|
+
else
|
|
80
|
+
return
|
|
81
|
+
end
|
|
82
|
+
uri = URI(uri)
|
|
83
|
+
unless uri.is_a?(URI::HTTP)
|
|
84
|
+
@scanner.unscan
|
|
85
|
+
return
|
|
86
|
+
end
|
|
87
|
+
uri
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def html_url(url)
|
|
91
|
+
url = url.to_s
|
|
92
|
+
ref = CGI.escape(url)
|
|
93
|
+
label = CGI.escape_html(url)
|
|
94
|
+
%(<a class="pure-url" href="#{ref}">#{label}</a>)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Copyright (C) 2025 gemmaro
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
require "cgi"
|
|
17
|
+
|
|
18
|
+
class Elisp::Heading
|
|
19
|
+
attr_reader :level, :content
|
|
20
|
+
|
|
21
|
+
def initialize(content, level: 2)
|
|
22
|
+
@content = content
|
|
23
|
+
@level = level
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def html
|
|
27
|
+
name = "h#{@level}"
|
|
28
|
+
content = CGI.escape_html(@content)
|
|
29
|
+
"<#{name}>#{content}</#{name}>"
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/elisp/parser.rb
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
# Copyright (C) 2025 gemmaro
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
1
16
|
class Elisp::Parser
|
|
2
17
|
HEADER_LINE = %r{
|
|
3
18
|
;;;[ ]
|
|
4
19
|
(?<title>[a-z]+[.]el)[ ]---[ ](?<desc>.*?)
|
|
5
|
-
(?:[ ]+-[*]-[ ](?<vars
|
|
20
|
+
(?:[ ]+-[*]-[ ]*(?<vars>.*?)[ ]*-[*]-)?
|
|
6
21
|
\n+
|
|
7
22
|
}x
|
|
8
23
|
COMMENT = / *;; (?<comment>.*)\n/
|
|
@@ -20,45 +35,10 @@ class Elisp::Parser
|
|
|
20
35
|
}x
|
|
21
36
|
BLANKLINES = /\n+/
|
|
22
37
|
CODE_OR_BLANKLINES = Regexp.union(CODE, BLANKLINES)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
body {
|
|
29
|
-
display: flex;
|
|
30
|
-
}
|
|
31
|
-
main {
|
|
32
|
-
max-width: 80rem;
|
|
33
|
-
margin: auto auto auto var(--sidebar-width);
|
|
34
|
-
padding-left: 0.5rem;
|
|
35
|
-
border-box: box-sizing;
|
|
36
|
-
}
|
|
37
|
-
.sidebar {
|
|
38
|
-
padding-right: 0.5rem;
|
|
39
|
-
width: var(--sidebar-width);
|
|
40
|
-
position: fixed;
|
|
41
|
-
boxed-sizing: border-box;
|
|
42
|
-
overflow-y: auto;
|
|
43
|
-
height: 100%;
|
|
44
|
-
}
|
|
45
|
-
.sidebar details ul {
|
|
46
|
-
position: relative;
|
|
47
|
-
left: -1.5rem;
|
|
48
|
-
}
|
|
49
|
-
.description {
|
|
50
|
-
font-style: italic;
|
|
51
|
-
}
|
|
52
|
-
pre {
|
|
53
|
-
font-family: serif;
|
|
54
|
-
}
|
|
55
|
-
pre[class="code"] {
|
|
56
|
-
border-left: solid;
|
|
57
|
-
padding-left: 0.5rem;
|
|
58
|
-
white-space: pre-wrap;
|
|
59
|
-
}
|
|
60
|
-
</style>
|
|
61
|
-
END_CSS
|
|
38
|
+
|
|
39
|
+
css = File.read(File.join(__dir__, "default.css"))
|
|
40
|
+
DEFAULT_CSS = "<style>#{css}</style>"
|
|
41
|
+
|
|
62
42
|
HEADING = %r{
|
|
63
43
|
;;;(?<level>;*)[ ](?<title>.+)\n
|
|
64
44
|
(?:(?:;;)?\n)*
|
|
@@ -132,7 +112,7 @@ class Elisp::Parser
|
|
|
132
112
|
@nodes.last << @scanner[:content]
|
|
133
113
|
|
|
134
114
|
elsif @state == :after_code && @scanner.skip(/\f\n+/)
|
|
135
|
-
@nodes << PageDelimiter.new
|
|
115
|
+
@nodes << Elisp::PageDelimiter.new
|
|
136
116
|
@state = :after_page_delimiter
|
|
137
117
|
|
|
138
118
|
else
|
|
@@ -163,9 +143,6 @@ class Elisp::Parser
|
|
|
163
143
|
|
|
164
144
|
def write(output, css: nil)
|
|
165
145
|
css = css ? %(<link rel="stylesheet" href="#{CGI.escape(css)}">) : DEFAULT_CSS
|
|
166
|
-
sidebar = Elisp::Sidebar.new(@nodes.select { |node| node.is_a?(Elisp::Heading) \
|
|
167
|
-
&& node.level >= 2 })
|
|
168
|
-
.html
|
|
169
146
|
body = @nodes.map(&:html).join("\n")
|
|
170
147
|
output.write(<<~END_HTML)
|
|
171
148
|
<!doctype html>
|
|
@@ -173,14 +150,10 @@ class Elisp::Parser
|
|
|
173
150
|
<head>
|
|
174
151
|
#{css}
|
|
175
152
|
<meta charset="utf8">
|
|
153
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
176
154
|
</head>
|
|
177
155
|
<body>
|
|
178
|
-
<
|
|
179
|
-
#{sidebar}
|
|
180
|
-
</nav>
|
|
181
|
-
<main>
|
|
182
|
-
#{body}
|
|
183
|
-
</main>
|
|
156
|
+
<main>#{body}</main>
|
|
184
157
|
</body>
|
|
185
158
|
</html>
|
|
186
159
|
END_HTML
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright (C) 2025 gemmaro
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
class Elisp
|
|
17
|
+
VERSION = "0.0.7"
|
|
18
|
+
end
|
data/lib/elisp.rb
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# Copyright (C) 2025 gemmaro
|
|
2
|
+
#
|
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
1
16
|
require "strscan"
|
|
2
17
|
require "cgi"
|
|
3
18
|
require "uri"
|
|
@@ -10,70 +25,10 @@ class Elisp
|
|
|
10
25
|
end
|
|
11
26
|
end
|
|
12
27
|
|
|
13
|
-
class Elisp::
|
|
14
|
-
def initialize(headings)
|
|
15
|
-
@headings = headings
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def html
|
|
19
|
-
rest = @headings.dup
|
|
20
|
-
result = +""
|
|
21
|
-
while (head = rest.shift)
|
|
22
|
-
level = head.level
|
|
23
|
-
subheadings = []
|
|
24
|
-
while (heading = rest.shift)
|
|
25
|
-
if heading.level > level
|
|
26
|
-
subheadings << heading
|
|
27
|
-
else
|
|
28
|
-
rest.unshift(heading)
|
|
29
|
-
break
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
sub_sidebar =
|
|
33
|
-
subheadings.empty? ? nil
|
|
34
|
-
: (html = self.class.new(subheadings).html
|
|
35
|
-
"<details open>#{html}</details>")
|
|
36
|
-
content = CGI.escape_html(head.content)
|
|
37
|
-
result << <<~END_HTML
|
|
38
|
-
<li>
|
|
39
|
-
<a href="##{head.html_id}">#{content}</a>
|
|
40
|
-
#{sub_sidebar}
|
|
41
|
-
</li>
|
|
42
|
-
END_HTML
|
|
43
|
-
end
|
|
44
|
-
"<ul>#{result}</ul>"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
class PageDelimiter
|
|
28
|
+
class Elisp::PageDelimiter
|
|
49
29
|
def html = "<hr>"
|
|
50
30
|
end
|
|
51
31
|
|
|
52
|
-
class Elisp::Heading
|
|
53
|
-
attr_reader :level, :content
|
|
54
|
-
|
|
55
|
-
def initialize(content, level: 2)
|
|
56
|
-
@content = content
|
|
57
|
-
@level = level
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def html
|
|
61
|
-
name = "h#{@level}"
|
|
62
|
-
content = CGI.escape_html(@content)
|
|
63
|
-
<<~END_HTML
|
|
64
|
-
<#{name} id="#{html_id}">
|
|
65
|
-
#{content}
|
|
66
|
-
<a href="##{html_id}">#</a>
|
|
67
|
-
</#{name}>
|
|
68
|
-
END_HTML
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def html_id
|
|
72
|
-
content = CGI.escape(@content)
|
|
73
|
-
"#{@level}-#{content}"
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
32
|
class Elisp::Desc
|
|
78
33
|
def initialize(content)
|
|
79
34
|
@content = content
|
|
@@ -95,7 +50,7 @@ class Elisp::Variables
|
|
|
95
50
|
<<~END_HTML
|
|
96
51
|
<article>
|
|
97
52
|
Header line variables:
|
|
98
|
-
<pre><code>#{content}</code></pre>
|
|
53
|
+
<pre class="code"><code>#{content}</code></pre>
|
|
99
54
|
</article>
|
|
100
55
|
END_HTML
|
|
101
56
|
end
|
|
@@ -140,3 +95,5 @@ end
|
|
|
140
95
|
|
|
141
96
|
require_relative "elisp/comment"
|
|
142
97
|
require_relative "elisp/parser"
|
|
98
|
+
require_relative "elisp/heading"
|
|
99
|
+
require_relative "elisp/doc_string_parser"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: elisp2any
|
|
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:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rake
|
|
@@ -56,27 +55,11 @@ files:
|
|
|
56
55
|
- fixtures/init.el
|
|
57
56
|
- lib/elisp.rb
|
|
58
57
|
- lib/elisp/comment.rb
|
|
58
|
+
- lib/elisp/default.css
|
|
59
|
+
- lib/elisp/doc_string_parser.rb
|
|
60
|
+
- lib/elisp/heading.rb
|
|
59
61
|
- lib/elisp/parser.rb
|
|
60
|
-
- lib/
|
|
61
|
-
- lib/elisp2any/aside.rb
|
|
62
|
-
- lib/elisp2any/blanklines.rb
|
|
63
|
-
- lib/elisp2any/code.rb
|
|
64
|
-
- lib/elisp2any/codeblock.rb
|
|
65
|
-
- lib/elisp2any/comment.rb
|
|
66
|
-
- lib/elisp2any/commentary.rb
|
|
67
|
-
- lib/elisp2any/expression.rb
|
|
68
|
-
- lib/elisp2any/footer_line.rb
|
|
69
|
-
- lib/elisp2any/header_line.rb
|
|
70
|
-
- lib/elisp2any/heading.rb
|
|
71
|
-
- lib/elisp2any/html_renderer.erb
|
|
72
|
-
- lib/elisp2any/html_renderer.rb
|
|
73
|
-
- lib/elisp2any/html_renderer/index.html.erb
|
|
74
|
-
- lib/elisp2any/inline_code.rb
|
|
75
|
-
- lib/elisp2any/line.rb
|
|
76
|
-
- lib/elisp2any/paragraph.rb
|
|
77
|
-
- lib/elisp2any/section.rb
|
|
78
|
-
- lib/elisp2any/text.rb
|
|
79
|
-
- lib/elisp2any/version.rb
|
|
62
|
+
- lib/elisp/version.rb
|
|
80
63
|
homepage: https://codeberg.org/gemmaro/elisp2any
|
|
81
64
|
licenses:
|
|
82
65
|
- GPL-3.0-or-later
|
|
@@ -88,7 +71,6 @@ metadata:
|
|
|
88
71
|
homepage_uri: https://codeberg.org/gemmaro/elisp2any
|
|
89
72
|
source_code_uri: https://codeberg.org/gemmaro/elisp2any
|
|
90
73
|
wiki_uri: https://codeberg.org/gemmaro/elisp2any/wiki
|
|
91
|
-
post_install_message:
|
|
92
74
|
rdoc_options: []
|
|
93
75
|
require_paths:
|
|
94
76
|
- lib
|
|
@@ -103,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
103
85
|
- !ruby/object:Gem::Version
|
|
104
86
|
version: '0'
|
|
105
87
|
requirements: []
|
|
106
|
-
rubygems_version:
|
|
107
|
-
signing_key:
|
|
88
|
+
rubygems_version: 4.0.10
|
|
108
89
|
specification_version: 4
|
|
109
90
|
summary: Converter from Emacs Lisp to some document markup
|
|
110
91
|
test_files: []
|
data/lib/elisp2any/aside.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require "elisp2any/comment"
|
|
2
|
-
|
|
3
|
-
module Elisp2any
|
|
4
|
-
class Aside
|
|
5
|
-
def self.scan(scanner)
|
|
6
|
-
pos = scanner.pos
|
|
7
|
-
com = Comment.scan(scanner) or return
|
|
8
|
-
unless com.colons == 1
|
|
9
|
-
scanner.pos = pos
|
|
10
|
-
return
|
|
11
|
-
end
|
|
12
|
-
new(com.content)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def source
|
|
16
|
-
";#{@content}\n"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def initialize(content)
|
|
20
|
-
@content = content
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|