textbringer-markdown 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 60d17f89dfbd5f920a78c3e04bd03604129fedd62a0f975baa497d8511e84b98
4
+ data.tar.gz: 54ea71007ea98170ae782336a65a89dc0a102277d492fcf6c7c233afa0138d18
5
+ SHA512:
6
+ metadata.gz: 238c540899297f066343656f8db3d2cff0dd09ba049501d39526c855562d8d95677d4090fe7d1a0213bfdf8483668f842e0a037bc02c603af07295ce476761ca
7
+ data.tar.gz: 388a48f423f5de5aa894cd0d49a42c1a8cd23fce67168c24e50cafb84e80fcc50bab969f4498a29e0156d64fc4a3fff54ee7f1179aac417e11ab902c26c0a08f
data/CLAUDE.md ADDED
@@ -0,0 +1,60 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ Textbringer::Markdown is a Ruby gem that provides Markdown syntax highlighting for the Textbringer text editor. The implementation is compact (83 lines) and uses regex-based pattern matching to highlight Markdown elements like headings, bold, italic, code blocks, links, lists, and blockquotes.
8
+
9
+ ## Common Commands
10
+
11
+ ### Development Setup
12
+ ```bash
13
+ bin/setup # Install dependencies
14
+ ```
15
+
16
+ ### Testing
17
+ ```bash
18
+ rake spec # Run tests via RSpec
19
+ rake # Default task (runs spec)
20
+ ```
21
+
22
+ ### Development Console
23
+ ```bash
24
+ bin/console # Interactive IRB prompt for experimentation
25
+ ```
26
+
27
+ ### Installation & Release
28
+ ```bash
29
+ bundle exec rake install # Install gem locally
30
+ bundle exec rake release # Release new version (updates version in version.rb first)
31
+ ```
32
+
33
+ ## Architecture
34
+
35
+ ### Core Implementation
36
+ All functionality is in `lib/textbringer/markdown.rb` (83 lines):
37
+
38
+ - **Face Definitions**: 10 color schemes for different Markdown elements (heading, bold, italic, code, code_block, link, url, quote, list, hr)
39
+ - **Syntax Rules**: 10 regex-based patterns using Textbringer's `define_syntax` API
40
+ - **File Pattern**: Matches `.md`, `.markdown`, `.mkd`, `.mdown`, `.mkdn`, `.mdwn` extensions
41
+ - **Buffer Settings**: Disables tab mode (uses spaces), sets tab width to 4
42
+
43
+ ### Textbringer Integration
44
+ - Inherits from `Textbringer::Mode` base class
45
+ - Uses Textbringer's `Face.define` for color definitions
46
+ - Uses `define_syntax` with regex patterns for syntax highlighting
47
+ - Integrates automatically when matching file extensions are opened
48
+
49
+ ### Regex Pattern Priority
50
+ Syntax rules are defined in order:
51
+ 1. Headings → 2. Horizontal rules → 3. Code blocks → 4. Inline code → 5. Bold → 6. Italic → 7. Links → 8. URLs → 9. Blockquotes → 10. Lists
52
+
53
+ When modifying patterns, consider that earlier definitions may take precedence.
54
+
55
+ ## Key Design Decisions
56
+
57
+ - **Single-file implementation**: All logic consolidated in one file for simplicity
58
+ - **Regex-based parsing**: No complex AST parsing, uses straightforward pattern matching
59
+ - **Minimal dependencies**: Only requires `textbringer >= 1.0`
60
+ - **No tab mode**: Markdown convention prefers spaces (enforced in buffer initialization)
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2026 yancya <yancya@upec.jp>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Textbringer::Markdown
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/textbringer/markdown`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/textbringer-markdown.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [WTFPL](http://www.wtfpl.net/).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Textbringer
4
+ module Markdown
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "markdown/version"
4
+
5
+ # Markdown Mode Plugin for Textbringer
6
+ # Provides syntax highlighting for Markdown files
7
+
8
+ module Textbringer
9
+ # Define faces for Markdown syntax elements
10
+ Face.define :markdown_heading, foreground: "cyan", bold: true
11
+ Face.define :markdown_bold, foreground: "yellow", bold: true
12
+ Face.define :markdown_italic, foreground: "green"
13
+ Face.define :markdown_code, foreground: "magenta"
14
+ Face.define :markdown_code_block, foreground: "magenta", bold: true
15
+ Face.define :markdown_link, foreground: "blue", underline: true
16
+ Face.define :markdown_url, foreground: "blue"
17
+ Face.define :markdown_quote, foreground: "yellow"
18
+ Face.define :markdown_list, foreground: "cyan"
19
+ Face.define :markdown_hr, foreground: "white", bold: true
20
+
21
+ class MarkdownMode < Mode
22
+ self.file_name_pattern = /\.md\z/i
23
+
24
+ # Headings (# ## ### etc)
25
+ define_syntax :markdown_heading, /
26
+ ^ [ \t]* \#{1,6} [ \t]+ .+? $
27
+ /x
28
+
29
+ # Horizontal rules (--- or *** or ___)
30
+ define_syntax :markdown_hr, /
31
+ ^ [ \t]* (?: [-*_] [ \t]* ){3,} $
32
+ /x
33
+
34
+ # Code blocks (```...``` or indented by 4 spaces)
35
+ define_syntax :markdown_code_block, /
36
+ (?: ^ [ \t]* ``` .*? $ .*? ^ [ \t]* ``` [ \t]* $ ) |
37
+ (?: ^ [ \t]{4,} .+ $ )
38
+ /xm
39
+
40
+ # Inline code (`code`)
41
+ define_syntax :markdown_code, /
42
+ (?<!`) ` [^`\n]+ `(?!`)
43
+ /x
44
+
45
+ # Bold (**text** or __text__)
46
+ define_syntax :markdown_bold, /
47
+ (?: \*\* [^\*\n]+ \*\* ) |
48
+ (?: __ [^_\n]+ __ )
49
+ /x
50
+
51
+ # Italic (*text* or _text_)
52
+ define_syntax :markdown_italic, /
53
+ (?: (?<!\*) \* [^\*\n]+ \* (?!\*) ) |
54
+ (?: (?<!_) _ [^_\n]+ _ (?!_) )
55
+ /x
56
+
57
+ # Links ([text](url) or [text][ref])
58
+ define_syntax :markdown_link, /
59
+ \[ [^\]]+ \] (?: \( [^\)]+ \) | \[ [^\]]* \] )
60
+ /x
61
+
62
+ # URLs (http:// or https://)
63
+ define_syntax :markdown_url, /
64
+ https?:\/\/ [^\s<>]+
65
+ /x
66
+
67
+ # Blockquotes (> text)
68
+ define_syntax :markdown_quote, /
69
+ ^ [ \t]* > .*? $
70
+ /xm
71
+
72
+ # List markers (-, *, +, 1.)
73
+ define_syntax :markdown_list, /
74
+ ^ [ \t]* (?: [-*+] | \d+\. ) [ \t]+
75
+ /x
76
+
77
+ def initialize(buffer)
78
+ super(buffer)
79
+ @buffer[:indent_tabs_mode] = false
80
+ @buffer[:tab_width] = 4
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
5
+ # Mock Textbringer for testing without the actual dependency
6
+ module Textbringer
7
+ class Face
8
+ def self.define(name, **options)
9
+ # Mock Face.define
10
+ end
11
+ end
12
+
13
+ class Mode
14
+ attr_reader :buffer
15
+
16
+ def initialize(buffer)
17
+ @buffer = buffer
18
+ end
19
+
20
+ def self.define_syntax(face, pattern)
21
+ # Mock define_syntax
22
+ end
23
+
24
+ def self.file_name_pattern
25
+ @file_name_pattern
26
+ end
27
+
28
+ def self.file_name_pattern=(pattern)
29
+ @file_name_pattern = pattern
30
+ end
31
+ end
32
+ end
33
+
34
+ require "textbringer/markdown"
35
+
36
+ require "test/unit"
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class Textbringer::MarkdownTest < Test::Unit::TestCase
6
+ test "VERSION is defined" do
7
+ assert do
8
+ ::Textbringer::Markdown.const_defined?(:VERSION)
9
+ end
10
+ end
11
+
12
+ test "MarkdownMode class exists" do
13
+ assert do
14
+ defined?(Textbringer::MarkdownMode)
15
+ end
16
+ end
17
+
18
+ test "MarkdownMode file pattern matches .md files" do
19
+ assert do
20
+ Textbringer::MarkdownMode.file_name_pattern =~ "test.md"
21
+ end
22
+ end
23
+
24
+ test "MarkdownMode file pattern does not match .txt files" do
25
+ assert_nil(Textbringer::MarkdownMode.file_name_pattern =~ "test.txt")
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: textbringer-markdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - yancya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: textbringer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: A Textbringer plugin that provides comprehensive Markdown syntax highlighting
28
+ with support for headings, code blocks, links, lists, and more.
29
+ email:
30
+ - yancya@upec.jp
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - CLAUDE.md
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/textbringer/markdown.rb
40
+ - lib/textbringer/markdown/version.rb
41
+ - test/test_helper.rb
42
+ - test/textbringer/markdown_test.rb
43
+ homepage: https://github.com/yancya/textbringer-markdown
44
+ licenses:
45
+ - WTFPL
46
+ metadata:
47
+ allowed_push_host: https://rubygems.org
48
+ homepage_uri: https://github.com/yancya/textbringer-markdown
49
+ source_code_uri: https://github.com/yancya/textbringer-markdown
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 3.2.0
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 3.4.19
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Markdown syntax highlighting mode for Textbringer
69
+ test_files: []