stepmod-utils 0.3.33 → 0.3.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/stepmod-annotate-all +30 -3
- data/lib/stepmod/utils/converters/em_express_description.rb +3 -1
- data/lib/stepmod/utils/converters/eqn.rb +4 -3
- data/lib/stepmod/utils/converters/strong.rb +31 -8
- data/lib/stepmod/utils/converters/sub.rb +1 -1
- data/lib/stepmod/utils/converters/sup.rb +1 -1
- data/lib/stepmod/utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d49969e2f3e60a1f5c56132b91a492f695aa1339bb9312b5264d72d54a4d4163
|
4
|
+
data.tar.gz: 8cc9498d0a6bdd52e4b387b32ebf90ec4735d3be3a009a92dfad35cd0a30c21c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c95c28d9b783137773da3bfc003dfdda5488368f48c3eb49a5494b62a47a60f2aa55ed218f3f0042ab558d386ea2d47445a1a44573078365725b5ac04b1246f6
|
7
|
+
data.tar.gz: c9a1d29d6d777f4914596724b5fad8fb256a6ce15ffcc857cbe8a233c37c01db5eebea9dbc7104537037a273d3080cbafc8f9db11d545fecdb5bd3293a970026
|
data/exe/stepmod-annotate-all
CHANGED
@@ -31,6 +31,31 @@ def all_express_files(stepmod_dir)
|
|
31
31
|
files.filter { |file| File.exist?(file) }
|
32
32
|
end
|
33
33
|
|
34
|
+
# On MacOS File.exist? was behaving case sensitive while on
|
35
|
+
# Github Actions it was behaving as case in-sensitive, e.g
|
36
|
+
# File.exist?(`../resource_docs/geometric_and_topological_representation/RationalLRsurf.gif`)
|
37
|
+
# was returning true on MacOS and false on Github Action runner. Because
|
38
|
+
# the original filepath was `geometric_and_topological_representation/RationalLRSurf.gif` (notice the capital `S` for Surf.gif)
|
39
|
+
# So this method is to find the actual path of the file based on
|
40
|
+
# downcased name of the file,
|
41
|
+
#
|
42
|
+
# Example:
|
43
|
+
#
|
44
|
+
# Given `../resource_docs/geometric_and_topological_representation/RationalLRsurf.gif`
|
45
|
+
# return `../resource_docs/geometric_and_topological_representation/RationalLRSurf.gif`
|
46
|
+
# It will return nil if the file does not exist
|
47
|
+
def file_system_path(filepath, filename_cache)
|
48
|
+
dir = File.dirname(filepath)
|
49
|
+
filename = File.basename(filepath)
|
50
|
+
|
51
|
+
return filename_cache[dir][filepath.downcase] if filename_cache[dir]
|
52
|
+
|
53
|
+
files = Dir.glob(File.join(dir, "*")).map { |f| [f.downcase, f] }.to_h
|
54
|
+
filename_cache[dir] = files
|
55
|
+
|
56
|
+
filename_cache[dir][filepath.downcase]
|
57
|
+
end
|
58
|
+
|
34
59
|
MAX_THREADS = 1 #[2, Concurrent.processor_count].max * 2
|
35
60
|
MAX_QUEUE_SIZE = MAX_THREADS * 4
|
36
61
|
# https://github.com/ruby-concurrency/concurrent-ruby/blob/master/docs-source/thread_pools.md
|
@@ -42,6 +67,7 @@ MAX_QUEUE_SIZE = MAX_THREADS * 4
|
|
42
67
|
# )
|
43
68
|
|
44
69
|
files = all_express_files(stepmod_dir)
|
70
|
+
filename_cache = {}
|
45
71
|
|
46
72
|
files.each do |file|
|
47
73
|
puts "#{Thread.current.object_id}: Processing #{file}"
|
@@ -60,13 +86,14 @@ files.each do |file|
|
|
60
86
|
|
61
87
|
result[:images_references].each do |source, destination|
|
62
88
|
source_path = File.join(stepmod_dir, "data", source)
|
89
|
+
system_source_path = file_system_path(source_path, filename_cache)
|
63
90
|
destination_path = File.join(File.dirname(file), destination)
|
64
91
|
|
65
92
|
puts "#{Thread.current.object_id}: Starting to copy file from #{source_path} to #{destination_path}"
|
66
|
-
next if
|
93
|
+
next if !system_source_path
|
67
94
|
|
68
|
-
FileUtils.cp(
|
69
|
-
puts "#{Thread.current.object_id}: Done copying #{
|
95
|
+
FileUtils.cp(system_source_path, destination_path)
|
96
|
+
puts "#{Thread.current.object_id}: Done copying #{system_source_path} to #{destination_path}"
|
70
97
|
end
|
71
98
|
|
72
99
|
puts "#{Thread.current.object_id}: Done processing #{File.basename(file)} => #{annotated_file_path}."
|
@@ -6,7 +6,9 @@ module Stepmod
|
|
6
6
|
class Em < ReverseAdoc::Converters::Base
|
7
7
|
def convert(node, state = {})
|
8
8
|
content = treat_children(node, state.merge(already_italic: true))
|
9
|
-
if
|
9
|
+
if state[:equation]
|
10
|
+
"ii(#{content.strip})"
|
11
|
+
elsif content.strip.empty? || state[:already_italic]
|
10
12
|
content
|
11
13
|
else
|
12
14
|
"#{content[/^\s*/]}_#{content.strip}_#{content[/\s*$/]}"
|
@@ -46,12 +46,13 @@ module Stepmod
|
|
46
46
|
term = first_strong_node.text.strip
|
47
47
|
first_strong_node.remove
|
48
48
|
"\n\n#{term}:: #{remove_trash_symbols(treat_children(cloned_node,
|
49
|
-
state))}\n"
|
49
|
+
state.merge(equation: true)))}\n"
|
50
50
|
end
|
51
51
|
|
52
52
|
def stem_converted(cloned_node, state)
|
53
|
-
|
54
|
-
|
53
|
+
# We are now adding bb() or ii() for bold and italic respectively
|
54
|
+
# remove_tags_not_in_context(cloned_node)
|
55
|
+
internal_content = treat_children(cloned_node, state.merge(equation: true))
|
55
56
|
content = Stepmod::Utils::HtmlToAsciimath.new.call(internal_content)
|
56
57
|
res = <<~TEMPLATE
|
57
58
|
|
@@ -7,19 +7,46 @@ module Stepmod
|
|
7
7
|
BLANK_CHARS = "{blank}"
|
8
8
|
|
9
9
|
def convert(node, state = {})
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
bold_converted(node, state)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def bold_converted(node, state)
|
16
|
+
cloned_node = node.clone
|
17
|
+
equations = extract_equations(cloned_node)
|
18
|
+
content = treat_children(cloned_node, state.merge(already_strong: true))
|
19
|
+
equation_content = equations.map do |equation|
|
20
|
+
treat(equation, state.merge(equation: true, already_strong: true))
|
21
|
+
end
|
22
|
+
|
23
|
+
content = if state[:equation]
|
24
|
+
"bb(#{content.strip})"
|
25
|
+
elsif content.strip.empty? || state[:already_strong]
|
13
26
|
content
|
14
27
|
else
|
28
|
+
strong_tag = state[:non_flanking_whitesapce] ? '**' : '*'
|
15
29
|
handle_express_escape_seq(
|
16
30
|
node,
|
17
31
|
"#{content[/^\s*/]}#{strong_tag}#{content.strip}#{strong_tag}#{content[/\s*$/]}"
|
18
32
|
)
|
19
33
|
end
|
34
|
+
|
35
|
+
[content, equation_content].compact.join("")
|
20
36
|
end
|
21
37
|
|
22
|
-
|
38
|
+
def extract_equations(node)
|
39
|
+
equations = []
|
40
|
+
|
41
|
+
node.children.each do |n|
|
42
|
+
next if n.name != "eqn"
|
43
|
+
|
44
|
+
equations << n
|
45
|
+
n.unlink
|
46
|
+
end
|
47
|
+
|
48
|
+
equations
|
49
|
+
end
|
23
50
|
|
24
51
|
def handle_express_escape_seq(node, content)
|
25
52
|
res = content
|
@@ -36,10 +63,6 @@ module Stepmod
|
|
36
63
|
match = end_of_text ? /\($/ : /^\)/
|
37
64
|
sibling&.text? && sibling.text =~ match
|
38
65
|
end
|
39
|
-
|
40
|
-
def content_is_equation?(content)
|
41
|
-
content.match(/^\s*\[\[[^\]]*\]\]/) || content.match(/^\s*\[stem\]/)
|
42
|
-
end
|
43
66
|
end
|
44
67
|
|
45
68
|
ReverseAdoc::Converters.register :strong, Strong.new
|
@@ -6,7 +6,7 @@ module Stepmod
|
|
6
6
|
class Sub < ReverseAdoc::Converters::Base
|
7
7
|
def convert(node, state = {})
|
8
8
|
content = treat_children(node, state)
|
9
|
-
return stem_notation(content) if
|
9
|
+
return stem_notation(content) if state[:equation]
|
10
10
|
|
11
11
|
"#{content[/^\s*/]}~#{content.strip}~#{content[/\s*$/]}"
|
12
12
|
end
|
@@ -6,7 +6,7 @@ module Stepmod
|
|
6
6
|
class Sup < ReverseAdoc::Converters::Base
|
7
7
|
def convert(node, state = {})
|
8
8
|
content = treat_children(node, state)
|
9
|
-
return stem_notation(content) if
|
9
|
+
return stem_notation(content) if state[:equation]
|
10
10
|
|
11
11
|
"#{content[/^\s*/]}^#{content.strip}^#{content[/\s*$/]}"
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stepmod-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|