livetext 0.9.52 → 0.9.56

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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/imports/bookish.rb +3 -3
  3. data/lib/livetext/ast/show_ast_clean.rb +10 -0
  4. data/lib/livetext/ast/show_ast_result.rb +60 -0
  5. data/lib/livetext/ast/show_raw_arrays.rb +13 -0
  6. data/lib/livetext/ast.rb +464 -0
  7. data/lib/livetext/ast_to_html.rb +32 -0
  8. data/lib/livetext/core.rb +110 -53
  9. data/lib/livetext/errors.rb +1 -0
  10. data/lib/livetext/expansion.rb +21 -21
  11. data/lib/livetext/formatter.rb +70 -200
  12. data/lib/livetext/formatter_component.rb +189 -0
  13. data/lib/livetext/function_registry.rb +163 -0
  14. data/lib/livetext/functions.rb +26 -0
  15. data/lib/livetext/handler/mixin.rb +53 -0
  16. data/lib/livetext/helpers.rb +33 -16
  17. data/lib/livetext/reopen.rb +2 -0
  18. data/lib/livetext/skeleton.rb +0 -3
  19. data/lib/livetext/standard.rb +120 -72
  20. data/lib/livetext/userapi.rb +20 -1
  21. data/lib/livetext/variable_manager.rb +78 -0
  22. data/lib/livetext/variables.rb +9 -1
  23. data/lib/livetext/version.rb +1 -1
  24. data/lib/livetext.rb +9 -3
  25. data/plugin/booktool.rb +14 -14
  26. data/plugin/lt3scriptor.rb +914 -0
  27. data/plugin/mixin_functions_class.rb +33 -0
  28. data/test/snapshots/complex_body/expected-error.txt +0 -0
  29. data/test/snapshots/complex_body/expected-output.txt +8 -0
  30. data/test/snapshots/complex_body/source.lt3 +19 -0
  31. data/test/snapshots/debug_command/expected-error.txt +0 -0
  32. data/test/snapshots/debug_command/expected-output.txt +1 -0
  33. data/test/snapshots/debug_command/source.lt3 +3 -0
  34. data/test/snapshots/def_parameters/expected-error.txt +0 -0
  35. data/test/snapshots/def_parameters/expected-output.txt +21 -0
  36. data/test/snapshots/def_parameters/source.lt3 +44 -0
  37. data/test/snapshots/error_missing_end/match-error.txt +1 -1
  38. data/test/snapshots/functions_reflection/expected-error.txt +0 -0
  39. data/test/snapshots/functions_reflection/expected-output.txt +27 -0
  40. data/test/snapshots/functions_reflection/source.lt3 +5 -0
  41. data/test/snapshots/mixin_functions_class/expected-error.txt +0 -0
  42. data/test/snapshots/mixin_functions_class/expected-output.txt +20 -0
  43. data/test/snapshots/mixin_functions_class/mixin_functions_class.rb +33 -0
  44. data/test/snapshots/mixin_functions_class/source.lt3 +17 -0
  45. data/test/snapshots/multiple_functions/expected-error.txt +0 -0
  46. data/test/snapshots/multiple_functions/expected-output.txt +5 -0
  47. data/test/snapshots/multiple_functions/source.lt3 +16 -0
  48. data/test/snapshots/nested_includes/expected-error.txt +0 -0
  49. data/test/snapshots/nested_includes/expected-output.txt +68 -0
  50. data/test/snapshots/nested_includes/level2.inc +34 -0
  51. data/test/snapshots/nested_includes/level3.inc +20 -0
  52. data/test/snapshots/nested_includes/source.lt3 +49 -0
  53. data/test/snapshots/parameter_handling/expected-error.txt +0 -0
  54. data/test/snapshots/parameter_handling/expected-output.txt +7 -0
  55. data/test/snapshots/parameter_handling/source.lt3 +10 -0
  56. data/test/snapshots/subset.txt +1 -0
  57. data/test/snapshots/system_info/expected-error.txt +0 -0
  58. data/test/snapshots/system_info/match-output.txt +18 -0
  59. data/test/snapshots/system_info/source.lt3 +16 -0
  60. data/test/unit/all.rb +7 -0
  61. data/test/unit/ast.rb +90 -0
  62. data/test/unit/ast_directives.rb +104 -0
  63. data/test/unit/ast_variables.rb +71 -0
  64. data/test/unit/core_methods.rb +317 -0
  65. data/test/unit/formatter.rb +84 -0
  66. data/test/unit/formatter_component.rb +84 -0
  67. data/test/unit/function_registry.rb +132 -0
  68. data/test/unit/mixin_functions_class.rb +131 -0
  69. data/test/unit/stringparser.rb +14 -32
  70. data/test/unit/variable_manager.rb +71 -0
  71. metadata +51 -5
  72. data/imports/markdown.rb +0 -44
  73. data/lib/livetext/processor.rb +0 -88
  74. data/plugin/markdown.rb +0 -43
@@ -1,88 +0,0 @@
1
-
2
- # Class Processor does the actual work of processing input.
3
-
4
- class Processor
5
-
6
- include Livetext::Standard
7
-
8
- Disallowed =
9
- %i[ __binding__ __id__ __send__ class
10
- clone display dup enum_for
11
- eql? equal? extend freeze
12
- frozen? hash inspect instance_eval
13
- instance_exec instance_of? is_a? kind_of?
14
- method methods nil? object_id
15
- pretty_inspect private_methods protected_methods public_method
16
- public_methods public_send respond_to? send
17
- singleton_class singleton_method singleton_methods taint
18
- tainted? tap to_enum to_s
19
- trust untaint untrust untrusted?
20
- define_singleton_method instance_variable_defined?
21
- instance_variable_get instance_variable_set
22
- remove_instance_variable instance_variables ]
23
-
24
- attr_reader :parent, :sources
25
-
26
- def initialize(parent, output = nil) # Processor
27
- @parent = parent || self
28
- # STDERR.puts "PARENT.api = #{parent.api.inspect}"
29
- @parent.api ||= Livetext::UserAPI.new(@parent)
30
- @nopass = false
31
- @nopara = false
32
- # Meh?
33
- @output = ::Livetext.output = (output || File.open("/dev/null", "w"))
34
- @sources = []
35
- @indentation = @parent.indentation
36
- @_mixins = []
37
- @_imports = []
38
- @html = Livetext::HTML.new(@parent.api)
39
- end
40
-
41
- def api
42
- @parent.api # FIXME Is this weird??
43
- end
44
-
45
- def html
46
- @html
47
- end
48
-
49
- def output=(io)
50
- @output = io
51
- end
52
-
53
- def error(*args)
54
- ::STDERR.puts *args
55
- end
56
-
57
- def disallowed?(name)
58
- flag = Disallowed.include?(name.to_sym)
59
- flag
60
- end
61
-
62
- def source(enum, file, line)
63
- @sources.push([enum, file, line])
64
- end
65
-
66
- def peek_nextline
67
- return nil if @sources.empty?
68
- source = @sources.last
69
- line = source[0].peek
70
- line
71
- rescue StopIteration
72
- @sources.pop
73
- nil
74
- rescue => err
75
- TTY.puts "#{__method__}: RESCUE err = #{err.inspect}"
76
- nil
77
- end
78
-
79
- def nextline
80
- return nil if @sources.empty?
81
- line = @sources.last[0].next
82
- @sources.last[2] += 1
83
- line
84
- rescue StopIteration
85
- @sources.pop
86
- nil
87
- end
88
- end
data/plugin/markdown.rb DELETED
@@ -1,43 +0,0 @@
1
- # This file is intended to be used via a Livetext .mixin
2
- # or the equivalent.
3
-
4
- SimpleFormats = {}
5
- SimpleFormats[:b] = %w[* *]
6
- SimpleFormats[:i] = %w[_ _]
7
- SimpleFormats[:t] = %w[` `]
8
- SimpleFormats[:s] = %w[<strike> </strike>]
9
-
10
-
11
- def h1(args = nil, body = nil); api.out "# #{Livetext.interpolate(api.data)}"; api.optional_blank_line end # atx style for now
12
- def h2(args = nil, body = nil); api.out "## #{Livetext.interpolate(api.data)}"; api.optional_blank_line end
13
- def h3(args = nil, body = nil); api.out "### #{Livetext.interpolate(api.data)}"; api.optional_blank_line end
14
- def h4(args = nil, body = nil); api.out "#### #{Livetext.interpolate(api.data)}"; api.optional_blank_line end
15
- def h5(args = nil, body = nil); api.out "##### #{Livetext.interpolate(api.data)}"; api.optional_blank_line end
16
- def h6(args = nil, body = nil); api.out "###### #{Livetext.interpolate(api.data)}"; api.optional_blank_line end
17
-
18
- def title(args = nil, body = nil)
19
- h1
20
- end
21
-
22
- def section(args = nil, body = nil)
23
- h3
24
- end
25
-
26
- def bq(args = nil, body = nil) # block quote
27
- api.body {|line| api.out "> #{line}" }
28
- end
29
-
30
- def list(args = nil, body = nil)
31
- api.body {|line| api.out " * #{line}" }
32
- end
33
-
34
- def olist(args = nil, body = nil) # Doesn't handle paragraphs yet
35
- n = 0
36
- api.body do |line|
37
- n += 1
38
- api.out "#{n}. #{_format(line)}"
39
- end
40
- end
41
-
42
- alias nlist olist
43
-