llm-shell 0.10.0 → 0.11.0
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/LICENSE +21 -0
- data/README.md +24 -160
- data/exe/llm-shell +7 -0
- data/llm-shell.gemspec +26 -32
- metadata +36 -372
- data/bin/llm-shell +0 -21
- data/lib/llm/shell/command.rb +0 -88
- data/lib/llm/shell/commands/clear_screen.rb +0 -18
- data/lib/llm/shell/commands/debug_mode.rb +0 -12
- data/lib/llm/shell/commands/dir_import.rb +0 -33
- data/lib/llm/shell/commands/disable_tool.rb +0 -33
- data/lib/llm/shell/commands/enable_tool.rb +0 -33
- data/lib/llm/shell/commands/file_import.rb +0 -25
- data/lib/llm/shell/commands/help.rb +0 -53
- data/lib/llm/shell/commands/show_chat.rb +0 -31
- data/lib/llm/shell/commands/show_version.rb +0 -17
- data/lib/llm/shell/commands/system_prompt.rb +0 -21
- data/lib/llm/shell/completion.rb +0 -40
- data/lib/llm/shell/config.rb +0 -34
- data/lib/llm/shell/default.rb +0 -23
- data/lib/llm/shell/formatter.rb +0 -41
- data/lib/llm/shell/internal/coderay/lib/coderay/duo.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/_map.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/comment_filter.rb +0 -25
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/count.rb +0 -39
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug.rb +0 -49
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug_lint.rb +0 -63
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/div.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/encoder.rb +0 -190
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/filter.rb +0 -58
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/css.rb +0 -65
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/numbering.rb +0 -108
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/output.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html.rb +0 -333
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/json.rb +0 -83
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lines_of_code.rb +0 -45
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lint.rb +0 -59
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/null.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/page.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/span.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/statistic.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/terminal.rb +0 -195
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/text.rb +0 -46
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/token_kind_filter.rb +0 -111
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/xml.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/yaml.rb +0 -50
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/for_redcloth.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/file_type.rb +0 -151
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin_host.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/word_list.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/_map.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/c.rb +0 -189
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/clojure.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/cpp.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/css.rb +0 -196
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/debug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/delphi.rb +0 -144
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/diff.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/erb.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/go.rb +0 -208
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/groovy.rb +0 -268
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/haml.rb +0 -168
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/html.rb +0 -275
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java/builtin_types.rb +0 -421
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java.rb +0 -174
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java_script.rb +0 -236
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/json.rb +0 -98
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/lua.rb +0 -280
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/php.rb +0 -527
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/python.rb +0 -287
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/raydebug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/patterns.rb +0 -178
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/string_state.rb +0 -79
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby.rb +0 -477
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sass.rb +0 -232
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/scanner.rb +0 -337
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sql.rb +0 -169
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/taskpaper.rb +0 -36
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/text.rb +0 -26
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/xml.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/yaml.rb +0 -140
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners.rb +0 -27
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/_map.rb +0 -7
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/alpha.rb +0 -153
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/style.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/styles.rb +0 -15
- data/lib/llm/shell/internal/coderay/lib/coderay/token_kinds.rb +0 -85
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens_proxy.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/version.rb +0 -3
- data/lib/llm/shell/internal/coderay/lib/coderay.rb +0 -284
- data/lib/llm/shell/internal/io-line/lib/io/line/multiple.rb +0 -19
- data/lib/llm/shell/internal/io-line/lib/io/line.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/builder.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/conversable.rb +0 -37
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/completion.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/respond.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot.rb +0 -150
- data/lib/llm/shell/internal/llm.rb/lib/llm/buffer.rb +0 -162
- data/lib/llm/shell/internal/llm.rb/lib/llm/client.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/error.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventhandler.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/event.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/parser.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/file.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/function.rb +0 -177
- data/lib/llm/shell/internal/llm.rb/lib/llm/message.rb +0 -178
- data/lib/llm/shell/internal/llm.rb/lib/llm/mime.rb +0 -140
- data/lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb +0 -101
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/builder.rb +0 -38
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/kernel.rb +0 -53
- data/lib/llm/shell/internal/llm.rb/lib/llm/object.rb +0 -89
- data/lib/llm/shell/internal/llm.rb/lib/llm/provider.rb +0 -352
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/files.rb +0 -155
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format/completion_format.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/models.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/completion.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/enumerable.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/file.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/stream_parser.rb +0 -66
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic.rb +0 -138
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb +0 -68
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format.rb +0 -27
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/audio.rb +0 -73
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/error_handler.rb +0 -47
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/files.rb +0 -146
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format/completion_format.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/images.rb +0 -133
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/models.rb +0 -60
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/completion.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/embedding.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/file.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/files.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/image.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/models.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/web_search.rb +0 -22
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini.rb +0 -173
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/llamacpp.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format/completion_format.rb +0 -77
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/models.rb +0 -56
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/completion.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/stream_parser.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama.rb +0 -116
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/audio.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/error_handler.rb +0 -46
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/files.rb +0 -134
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/completion_format.rb +0 -90
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/moderation_format.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/images.rb +0 -109
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/models.rb +0 -55
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/moderations.rb +0 -65
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/audio.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/completion.rb +0 -40
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/enumerable.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/file.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/image.rb +0 -16
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/moderations.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/responds.rb +0 -48
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses/stream_parser.rb +0 -76
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses.rb +0 -99
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/vector_stores.rb +0 -228
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai.rb +0 -206
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai/images.rb +0 -58
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/zai.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/response.rb +0 -67
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/array.rb +0 -26
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/boolean.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/integer.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/leaf.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/null.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/number.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb +0 -41
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/string.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/version.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema.rb +0 -81
- data/lib/llm/shell/internal/llm.rb/lib/llm/server_tool.rb +0 -32
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool/param.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/utils.rb +0 -19
- data/lib/llm/shell/internal/llm.rb/lib/llm/version.rb +0 -5
- data/lib/llm/shell/internal/llm.rb/lib/llm.rb +0 -121
- data/lib/llm/shell/internal/optparse/lib/optionparser.rb +0 -2
- data/lib/llm/shell/internal/optparse/lib/optparse/ac.rb +0 -70
- data/lib/llm/shell/internal/optparse/lib/optparse/date.rb +0 -18
- data/lib/llm/shell/internal/optparse/lib/optparse/kwargs.rb +0 -27
- data/lib/llm/shell/internal/optparse/lib/optparse/shellwords.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/time.rb +0 -11
- data/lib/llm/shell/internal/optparse/lib/optparse/uri.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/version.rb +0 -80
- data/lib/llm/shell/internal/optparse/lib/optparse.rb +0 -2469
- data/lib/llm/shell/internal/paint/lib/paint/constants.rb +0 -104
- data/lib/llm/shell/internal/paint/lib/paint/pa.rb +0 -13
- data/lib/llm/shell/internal/paint/lib/paint/rgb_colors.rb +0 -14
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts.rb +0 -100
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts_version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint/util.rb +0 -16
- data/lib/llm/shell/internal/paint/lib/paint/version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint.rb +0 -261
- data/lib/llm/shell/internal/reline/lib/reline/config.rb +0 -378
- data/lib/llm/shell/internal/reline/lib/reline/face.rb +0 -199
- data/lib/llm/shell/internal/reline/lib/reline/history.rb +0 -76
- data/lib/llm/shell/internal/reline/lib/reline/io/ansi.rb +0 -322
- data/lib/llm/shell/internal/reline/lib/reline/io/dumb.rb +0 -120
- data/lib/llm/shell/internal/reline/lib/reline/io/windows.rb +0 -530
- data/lib/llm/shell/internal/reline/lib/reline/io.rb +0 -55
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/base.rb +0 -37
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/composite.rb +0 -17
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/emacs.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_command.rb +0 -518
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_insert.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor.rb +0 -8
- data/lib/llm/shell/internal/reline/lib/reline/key_stroke.rb +0 -119
- data/lib/llm/shell/internal/reline/lib/reline/kill_ring.rb +0 -125
- data/lib/llm/shell/internal/reline/lib/reline/line_editor.rb +0 -2356
- data/lib/llm/shell/internal/reline/lib/reline/unicode/east_asian_width.rb +0 -1292
- data/lib/llm/shell/internal/reline/lib/reline/unicode.rb +0 -421
- data/lib/llm/shell/internal/reline/lib/reline/version.rb +0 -3
- data/lib/llm/shell/internal/reline/lib/reline.rb +0 -527
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/generated_parser.rb +0 -712
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/handler.rb +0 -268
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date.rb +0 -35
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb +0 -42
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/parser.rb +0 -21
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/scanner.rb +0 -92
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/string_utils.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/version.rb +0 -5
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb.rb +0 -49
- data/lib/llm/shell/markdown.rb +0 -83
- data/lib/llm/shell/options.rb +0 -39
- data/lib/llm/shell/renderer.rb +0 -51
- data/lib/llm/shell/repl.rb +0 -111
- data/lib/llm/shell/tool.rb +0 -42
- data/lib/llm/shell/tools/read_file.rb +0 -15
- data/lib/llm/shell/tools/system.rb +0 -17
- data/lib/llm/shell/tools/write_file.rb +0 -16
- data/lib/llm/shell/version.rb +0 -8
- data/lib/llm/shell.rb +0 -132
- data/lib/llm-shell.rb +0 -3
- data/libexec/llm-shell/shell +0 -43
- data/share/llm-shell/prompts/default.txt +0 -21
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
# Outputs code highlighted for a color terminal.
|
|
5
|
-
#
|
|
6
|
-
# Note: This encoder is in beta. It currently doesn't use the Styles.
|
|
7
|
-
#
|
|
8
|
-
# Alias: +term+
|
|
9
|
-
#
|
|
10
|
-
# == Authors & License
|
|
11
|
-
#
|
|
12
|
-
# By Rob Aldred (http://robaldred.co.uk)
|
|
13
|
-
#
|
|
14
|
-
# Based on idea by Nathan Weizenbaum (http://nex-3.com)
|
|
15
|
-
#
|
|
16
|
-
# MIT License (http://www.opensource.org/licenses/mit-license.php)
|
|
17
|
-
class Terminal < Encoder
|
|
18
|
-
|
|
19
|
-
register_for :terminal
|
|
20
|
-
|
|
21
|
-
TOKEN_COLORS = {
|
|
22
|
-
:debug => "\e[1;37;44m",
|
|
23
|
-
|
|
24
|
-
:annotation => "\e[34m",
|
|
25
|
-
:attribute_name => "\e[35m",
|
|
26
|
-
:attribute_value => "\e[31m",
|
|
27
|
-
:binary => {
|
|
28
|
-
:self => "\e[31m",
|
|
29
|
-
:char => "\e[1;31m",
|
|
30
|
-
:delimiter => "\e[1;31m",
|
|
31
|
-
},
|
|
32
|
-
:char => {
|
|
33
|
-
:self => "\e[35m",
|
|
34
|
-
:delimiter => "\e[1;35m"
|
|
35
|
-
},
|
|
36
|
-
:class => "\e[1;35;4m",
|
|
37
|
-
:class_variable => "\e[36m",
|
|
38
|
-
:color => "\e[32m",
|
|
39
|
-
:comment => {
|
|
40
|
-
:self => "\e[1;30m",
|
|
41
|
-
:char => "\e[37m",
|
|
42
|
-
:delimiter => "\e[37m",
|
|
43
|
-
},
|
|
44
|
-
:constant => "\e[1;34;4m",
|
|
45
|
-
:decorator => "\e[35m",
|
|
46
|
-
:definition => "\e[1;33m",
|
|
47
|
-
:directive => "\e[33m",
|
|
48
|
-
:docstring => "\e[31m",
|
|
49
|
-
:doctype => "\e[1;34m",
|
|
50
|
-
:done => "\e[1;30;2m",
|
|
51
|
-
:entity => "\e[31m",
|
|
52
|
-
:error => "\e[1;37;41m",
|
|
53
|
-
:exception => "\e[1;31m",
|
|
54
|
-
:float => "\e[1;35m",
|
|
55
|
-
:function => "\e[1;34m",
|
|
56
|
-
:global_variable => "\e[1;32m",
|
|
57
|
-
:hex => "\e[1;36m",
|
|
58
|
-
:id => "\e[1;34m",
|
|
59
|
-
:include => "\e[31m",
|
|
60
|
-
:integer => "\e[1;34m",
|
|
61
|
-
:imaginary => "\e[1;34m",
|
|
62
|
-
:important => "\e[1;31m",
|
|
63
|
-
:key => {
|
|
64
|
-
:self => "\e[35m",
|
|
65
|
-
:char => "\e[1;35m",
|
|
66
|
-
:delimiter => "\e[1;35m",
|
|
67
|
-
},
|
|
68
|
-
:keyword => "\e[32m",
|
|
69
|
-
:label => "\e[1;33m",
|
|
70
|
-
:local_variable => "\e[33m",
|
|
71
|
-
:namespace => "\e[1;35m",
|
|
72
|
-
:octal => "\e[1;34m",
|
|
73
|
-
:predefined => "\e[36m",
|
|
74
|
-
:predefined_constant => "\e[1;36m",
|
|
75
|
-
:predefined_type => "\e[1;32m",
|
|
76
|
-
:preprocessor => "\e[1;36m",
|
|
77
|
-
:pseudo_class => "\e[1;34m",
|
|
78
|
-
:regexp => {
|
|
79
|
-
:self => "\e[35m",
|
|
80
|
-
:delimiter => "\e[1;35m",
|
|
81
|
-
:modifier => "\e[35m",
|
|
82
|
-
:char => "\e[1;35m",
|
|
83
|
-
},
|
|
84
|
-
:reserved => "\e[32m",
|
|
85
|
-
:shell => {
|
|
86
|
-
:self => "\e[33m",
|
|
87
|
-
:char => "\e[1;33m",
|
|
88
|
-
:delimiter => "\e[1;33m",
|
|
89
|
-
:escape => "\e[1;33m",
|
|
90
|
-
},
|
|
91
|
-
:string => {
|
|
92
|
-
:self => "\e[31m",
|
|
93
|
-
:modifier => "\e[1;31m",
|
|
94
|
-
:char => "\e[1;35m",
|
|
95
|
-
:delimiter => "\e[1;31m",
|
|
96
|
-
:escape => "\e[1;31m",
|
|
97
|
-
},
|
|
98
|
-
:symbol => {
|
|
99
|
-
:self => "\e[33m",
|
|
100
|
-
:delimiter => "\e[1;33m",
|
|
101
|
-
},
|
|
102
|
-
:tag => "\e[32m",
|
|
103
|
-
:type => "\e[1;34m",
|
|
104
|
-
:value => "\e[36m",
|
|
105
|
-
:variable => "\e[34m",
|
|
106
|
-
|
|
107
|
-
:insert => {
|
|
108
|
-
:self => "\e[42m",
|
|
109
|
-
:insert => "\e[1;32;42m",
|
|
110
|
-
:eyecatcher => "\e[102m",
|
|
111
|
-
},
|
|
112
|
-
:delete => {
|
|
113
|
-
:self => "\e[41m",
|
|
114
|
-
:delete => "\e[1;31;41m",
|
|
115
|
-
:eyecatcher => "\e[101m",
|
|
116
|
-
},
|
|
117
|
-
:change => {
|
|
118
|
-
:self => "\e[44m",
|
|
119
|
-
:change => "\e[37;44m",
|
|
120
|
-
},
|
|
121
|
-
:head => {
|
|
122
|
-
:self => "\e[45m",
|
|
123
|
-
:filename => "\e[37;45m"
|
|
124
|
-
},
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
TOKEN_COLORS[:keyword] = TOKEN_COLORS[:reserved]
|
|
128
|
-
TOKEN_COLORS[:method] = TOKEN_COLORS[:function]
|
|
129
|
-
TOKEN_COLORS[:escape] = TOKEN_COLORS[:delimiter]
|
|
130
|
-
|
|
131
|
-
protected
|
|
132
|
-
|
|
133
|
-
def setup(options)
|
|
134
|
-
super
|
|
135
|
-
@opened = []
|
|
136
|
-
@color_scopes = [TOKEN_COLORS]
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
public
|
|
140
|
-
|
|
141
|
-
def text_token text, kind
|
|
142
|
-
if color = @color_scopes.last[kind]
|
|
143
|
-
color = color[:self] if color.is_a? Hash
|
|
144
|
-
|
|
145
|
-
@out << color
|
|
146
|
-
@out << (text.index("\n") ? text.gsub("\n", "\e[0m\n" + color) : text)
|
|
147
|
-
@out << "\e[0m"
|
|
148
|
-
if outer_color = @color_scopes.last[:self]
|
|
149
|
-
@out << outer_color
|
|
150
|
-
end
|
|
151
|
-
else
|
|
152
|
-
@out << text
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def begin_group kind
|
|
157
|
-
@opened << kind
|
|
158
|
-
@out << open_token(kind)
|
|
159
|
-
end
|
|
160
|
-
alias begin_line begin_group
|
|
161
|
-
|
|
162
|
-
def end_group kind
|
|
163
|
-
if @opened.pop
|
|
164
|
-
@color_scopes.pop
|
|
165
|
-
@out << "\e[0m"
|
|
166
|
-
if outer_color = @color_scopes.last[:self]
|
|
167
|
-
@out << outer_color
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def end_line kind
|
|
173
|
-
@out << (@line_filler ||= "\t" * 100)
|
|
174
|
-
end_group kind
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
private
|
|
178
|
-
|
|
179
|
-
def open_token kind
|
|
180
|
-
if color = @color_scopes.last[kind]
|
|
181
|
-
if color.is_a? Hash
|
|
182
|
-
@color_scopes << color
|
|
183
|
-
color[:self]
|
|
184
|
-
else
|
|
185
|
-
@color_scopes << @color_scopes.last
|
|
186
|
-
color
|
|
187
|
-
end
|
|
188
|
-
else
|
|
189
|
-
@color_scopes << @color_scopes.last
|
|
190
|
-
''
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
# Concats the tokens into a single string, resulting in the original
|
|
5
|
-
# code string if no tokens were removed.
|
|
6
|
-
#
|
|
7
|
-
# Alias: +plain+, +plaintext+
|
|
8
|
-
#
|
|
9
|
-
# == Options
|
|
10
|
-
#
|
|
11
|
-
# === :separator
|
|
12
|
-
# A separator string to join the tokens.
|
|
13
|
-
#
|
|
14
|
-
# Default: empty String
|
|
15
|
-
class Text < Encoder
|
|
16
|
-
|
|
17
|
-
register_for :text
|
|
18
|
-
|
|
19
|
-
FILE_EXTENSION = 'txt'
|
|
20
|
-
|
|
21
|
-
DEFAULT_OPTIONS = {
|
|
22
|
-
:separator => nil
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
def text_token text, kind
|
|
26
|
-
super
|
|
27
|
-
|
|
28
|
-
if @first
|
|
29
|
-
@first = false
|
|
30
|
-
else
|
|
31
|
-
@out << @sep
|
|
32
|
-
end if @sep
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
protected
|
|
36
|
-
def setup options
|
|
37
|
-
super
|
|
38
|
-
|
|
39
|
-
@first = true
|
|
40
|
-
@sep = options[:separator]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
load :filter
|
|
5
|
-
|
|
6
|
-
# A Filter that selects tokens based on their token kind.
|
|
7
|
-
#
|
|
8
|
-
# == Options
|
|
9
|
-
#
|
|
10
|
-
# === :exclude
|
|
11
|
-
#
|
|
12
|
-
# One or many symbols (in an Array) which shall be excluded.
|
|
13
|
-
#
|
|
14
|
-
# Default: []
|
|
15
|
-
#
|
|
16
|
-
# === :include
|
|
17
|
-
#
|
|
18
|
-
# One or many symbols (in an array) which shall be included.
|
|
19
|
-
#
|
|
20
|
-
# Default: :all, which means all tokens are included.
|
|
21
|
-
#
|
|
22
|
-
# Exclusion wins over inclusion.
|
|
23
|
-
#
|
|
24
|
-
# See also: CommentFilter
|
|
25
|
-
class TokenKindFilter < Filter
|
|
26
|
-
|
|
27
|
-
register_for :token_kind_filter
|
|
28
|
-
|
|
29
|
-
DEFAULT_OPTIONS = {
|
|
30
|
-
:exclude => [],
|
|
31
|
-
:include => :all
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
protected
|
|
35
|
-
def setup options
|
|
36
|
-
super
|
|
37
|
-
|
|
38
|
-
@group_excluded = false
|
|
39
|
-
@exclude = options[:exclude]
|
|
40
|
-
@exclude = Array(@exclude) unless @exclude == :all
|
|
41
|
-
@include = options[:include]
|
|
42
|
-
@include = Array(@include) unless @include == :all
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def include_text_token? text, kind
|
|
46
|
-
include_group? kind
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def include_group? kind
|
|
50
|
-
(@include == :all || @include.include?(kind)) &&
|
|
51
|
-
!(@exclude == :all || @exclude.include?(kind))
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
public
|
|
55
|
-
|
|
56
|
-
# Add the token to the output stream if +kind+ matches the conditions.
|
|
57
|
-
def text_token text, kind
|
|
58
|
-
super if !@group_excluded && include_text_token?(text, kind)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Add the token group to the output stream if +kind+ matches the
|
|
62
|
-
# conditions.
|
|
63
|
-
#
|
|
64
|
-
# If it does not, all tokens inside the group are excluded from the
|
|
65
|
-
# stream, even if their kinds match.
|
|
66
|
-
def begin_group kind
|
|
67
|
-
if @group_excluded
|
|
68
|
-
@group_excluded += 1
|
|
69
|
-
elsif include_group? kind
|
|
70
|
-
super
|
|
71
|
-
else
|
|
72
|
-
@group_excluded = 1
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# See +begin_group+.
|
|
77
|
-
def begin_line kind
|
|
78
|
-
if @group_excluded
|
|
79
|
-
@group_excluded += 1
|
|
80
|
-
elsif include_group? kind
|
|
81
|
-
super
|
|
82
|
-
else
|
|
83
|
-
@group_excluded = 1
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Take care of re-enabling the delegation of tokens to the output stream
|
|
88
|
-
# if an exluded group has ended.
|
|
89
|
-
def end_group kind
|
|
90
|
-
if @group_excluded
|
|
91
|
-
@group_excluded -= 1
|
|
92
|
-
@group_excluded = false if @group_excluded.zero?
|
|
93
|
-
else
|
|
94
|
-
super
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# See +end_group+.
|
|
99
|
-
def end_line kind
|
|
100
|
-
if @group_excluded
|
|
101
|
-
@group_excluded -= 1
|
|
102
|
-
@group_excluded = false if @group_excluded.zero?
|
|
103
|
-
else
|
|
104
|
-
super
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
end
|
|
111
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
module Encoders
|
|
3
|
-
|
|
4
|
-
# = XML Encoder
|
|
5
|
-
#
|
|
6
|
-
# Uses REXML. Very slow.
|
|
7
|
-
class XML < Encoder
|
|
8
|
-
|
|
9
|
-
register_for :xml
|
|
10
|
-
|
|
11
|
-
FILE_EXTENSION = 'xml'
|
|
12
|
-
|
|
13
|
-
autoload :REXML, 'rexml/document'
|
|
14
|
-
|
|
15
|
-
DEFAULT_OPTIONS = {
|
|
16
|
-
:tab_width => 8,
|
|
17
|
-
:pretty => -1,
|
|
18
|
-
:transitive => false,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
protected
|
|
22
|
-
def setup options
|
|
23
|
-
super
|
|
24
|
-
|
|
25
|
-
@doc = REXML::Document.new
|
|
26
|
-
@doc << REXML::XMLDecl.new
|
|
27
|
-
@tab_width = options[:tab_width]
|
|
28
|
-
@root = @node = @doc.add_element('coderay-tokens')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def finish options
|
|
32
|
-
@doc.write @out, options[:pretty], options[:transitive], true
|
|
33
|
-
|
|
34
|
-
super
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
public
|
|
38
|
-
def text_token text, kind
|
|
39
|
-
if kind == :space
|
|
40
|
-
token = @node
|
|
41
|
-
else
|
|
42
|
-
token = @node.add_element kind.to_s
|
|
43
|
-
end
|
|
44
|
-
text.scan(/(\x20+)|(\t+)|(\n)|[^\x20\t\n]+/) do |space, tab, nl|
|
|
45
|
-
case
|
|
46
|
-
when space
|
|
47
|
-
token << REXML::Text.new(space, true)
|
|
48
|
-
when tab
|
|
49
|
-
token << REXML::Text.new(tab, true)
|
|
50
|
-
when nl
|
|
51
|
-
token << REXML::Text.new(nl, true)
|
|
52
|
-
else
|
|
53
|
-
token << REXML::Text.new($&)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def begin_group kind
|
|
59
|
-
@node = @node.add_element kind.to_s
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def end_group kind
|
|
63
|
-
if @node == @root
|
|
64
|
-
raise 'no token to close!'
|
|
65
|
-
end
|
|
66
|
-
@node = @node.parent
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
autoload :YAML, 'yaml'
|
|
2
|
-
|
|
3
|
-
module CodeRay
|
|
4
|
-
module Encoders
|
|
5
|
-
|
|
6
|
-
# = YAML Encoder
|
|
7
|
-
#
|
|
8
|
-
# Slow.
|
|
9
|
-
class YAML < Encoder
|
|
10
|
-
|
|
11
|
-
register_for :yaml
|
|
12
|
-
|
|
13
|
-
FILE_EXTENSION = 'yaml'
|
|
14
|
-
|
|
15
|
-
protected
|
|
16
|
-
def setup options
|
|
17
|
-
super
|
|
18
|
-
|
|
19
|
-
@data = []
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def finish options
|
|
23
|
-
output ::YAML.dump(@data)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
public
|
|
27
|
-
def text_token text, kind
|
|
28
|
-
@data << [text, kind]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def begin_group kind
|
|
32
|
-
@data << [:begin_group, kind]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def end_group kind
|
|
36
|
-
@data << [:end_group, kind]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def begin_line kind
|
|
40
|
-
@data << [:begin_line, kind]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def end_line kind
|
|
44
|
-
@data << [:end_line, kind]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
|
|
3
|
-
# This module holds the Encoder class and its subclasses.
|
|
4
|
-
# For example, the HTML encoder is named CodeRay::Encoders::HTML
|
|
5
|
-
# can be found in coderay/encoders/html.
|
|
6
|
-
#
|
|
7
|
-
# Encoders also provides methods and constants for the register
|
|
8
|
-
# mechanism and the [] method that returns the Encoder class
|
|
9
|
-
# belonging to the given format.
|
|
10
|
-
module Encoders
|
|
11
|
-
|
|
12
|
-
extend PluginHost
|
|
13
|
-
plugin_path File.dirname(__FILE__), 'encoders'
|
|
14
|
-
|
|
15
|
-
autoload :Encoder, CodeRay.coderay_path('encoders', 'encoder')
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
module CodeRay
|
|
2
|
-
|
|
3
|
-
# A little hack to enable CodeRay highlighting in RedCloth.
|
|
4
|
-
#
|
|
5
|
-
# Usage:
|
|
6
|
-
# require 'coderay'
|
|
7
|
-
# require 'coderay/for_redcloth'
|
|
8
|
-
# RedCloth.new('@[ruby]puts "Hello, World!"@').to_html
|
|
9
|
-
#
|
|
10
|
-
# Make sure you have RedCloth 4.0.3 activated, for example by calling
|
|
11
|
-
# require 'rubygems'
|
|
12
|
-
# before RedCloth is loaded and before calling CodeRay.for_redcloth.
|
|
13
|
-
module ForRedCloth
|
|
14
|
-
|
|
15
|
-
def self.install
|
|
16
|
-
gem 'RedCloth', '>= 4.0.3' if defined? gem
|
|
17
|
-
require 'redcloth'
|
|
18
|
-
unless RedCloth::VERSION.to_s >= '4.0.3'
|
|
19
|
-
if defined? gem
|
|
20
|
-
raise 'CodeRay.for_redcloth needs RedCloth version 4.0.3 or later. ' +
|
|
21
|
-
"You have #{RedCloth::VERSION}. Please gem install RedCloth."
|
|
22
|
-
else
|
|
23
|
-
$".delete 'redcloth.rb' # sorry, but it works
|
|
24
|
-
require 'rubygems'
|
|
25
|
-
return install # retry
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
unless RedCloth::VERSION.to_s >= '4.2.2'
|
|
29
|
-
warn 'CodeRay.for_redcloth works best with RedCloth version 4.2.2 or later.'
|
|
30
|
-
end
|
|
31
|
-
RedCloth::TextileDoc.send :include, ForRedCloth::TextileDoc
|
|
32
|
-
RedCloth::Formatters::HTML.module_eval do
|
|
33
|
-
def unescape(html) # :nodoc:
|
|
34
|
-
replacements = {
|
|
35
|
-
'&' => '&',
|
|
36
|
-
'"' => '"',
|
|
37
|
-
'>' => '>',
|
|
38
|
-
'<' => '<',
|
|
39
|
-
}
|
|
40
|
-
html.gsub(/&(?:amp|quot|[gl]t);/) { |entity| replacements[entity] }
|
|
41
|
-
end
|
|
42
|
-
undef code, bc_open, bc_close, escape_pre
|
|
43
|
-
def code(opts) # :nodoc:
|
|
44
|
-
opts[:block] = true
|
|
45
|
-
if !opts[:lang] && RedCloth::VERSION.to_s >= '4.2.0'
|
|
46
|
-
# simulating pre-4.2 behavior
|
|
47
|
-
if opts[:text].sub!(/\A\[(\w+)\]/, '')
|
|
48
|
-
if CodeRay::Scanners[$1].lang == :text
|
|
49
|
-
opts[:text] = $& + opts[:text]
|
|
50
|
-
else
|
|
51
|
-
opts[:lang] = $1
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
if opts[:lang] && !filter_coderay
|
|
56
|
-
require 'coderay'
|
|
57
|
-
@in_bc ||= nil
|
|
58
|
-
format = @in_bc ? :div : :span
|
|
59
|
-
opts[:text] = unescape(opts[:text]) unless @in_bc
|
|
60
|
-
highlighted_code = CodeRay.encode opts[:text], opts[:lang], format
|
|
61
|
-
highlighted_code.sub!(/\A<(span|div)/) { |m| m + pba(@in_bc || opts) }
|
|
62
|
-
highlighted_code
|
|
63
|
-
else
|
|
64
|
-
"<code#{pba(opts)}>#{opts[:text]}</code>"
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
def bc_open(opts) # :nodoc:
|
|
68
|
-
opts[:block] = true
|
|
69
|
-
@in_bc = opts
|
|
70
|
-
opts[:lang] ? '' : "<pre#{pba(opts)}>"
|
|
71
|
-
end
|
|
72
|
-
def bc_close(opts) # :nodoc:
|
|
73
|
-
opts = @in_bc
|
|
74
|
-
@in_bc = nil
|
|
75
|
-
opts[:lang] ? '' : "</pre>\n"
|
|
76
|
-
end
|
|
77
|
-
def escape_pre(text) # :nodoc:
|
|
78
|
-
if @in_bc ||= nil
|
|
79
|
-
text
|
|
80
|
-
else
|
|
81
|
-
html_esc(text, :html_escape_preformatted)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
module TextileDoc # :nodoc:
|
|
88
|
-
attr_accessor :filter_coderay
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
CodeRay::ForRedCloth.install
|