pax_global_header 0000666 0000000 0000000 00000000064 15173533273 0014523 g ustar 00root root 0000000 0000000 52 comment=d6465eefd2535b22d9bb3483e5326e16fdb40276 davidfstr-rdiscount-d6465ee/ 0000775 0000000 0000000 00000000000 15173533273 0016145 5 ustar 00root root 0000000 0000000 davidfstr-rdiscount-d6465ee/.github/ 0000775 0000000 0000000 00000000000 15173533273 0017505 5 ustar 00root root 0000000 0000000 davidfstr-rdiscount-d6465ee/.github/copilot-instructions.md 0000664 0000000 0000000 00000005756 15173533273 0024257 0 ustar 00root root 0000000 0000000 # RDiscount — Copilot Instructions ## Project Overview RDiscount is a Ruby C extension wrapping David Parsons' [Discount](https://www.pell.portland.or.us/~orc/Code/discount/) Markdown library. It provides fast Markdown-to-HTML conversion from Ruby. - **Ruby API**: `lib/rdiscount.rb`, `lib/markdown.rb` - **C bridge**: `ext/rdiscount.c` (Ruby ↔ Discount glue, ~150 LOC) - **Discount sources**: `ext/*.c`, `ext/*.h` (copied from `discount/` submodule via `rake gather`) - **Tests**: `test/rdiscount_test.rb`, `test/markdown_test.rb`, plus conformance suites in `test/MarkdownTest_1.0*/` ## Build & Test ```bash # Build the C extension rake build # Run all tests (unit + conformance) rake test # Unit tests only rake test:unit # Conformance tests (Markdown spec 1.0.3) rake test:conformance ``` ## Architecture ``` discount/ ← Git submodule (upstream Discount C library) ext/ ← C extension: Discount sources + rdiscount.c bridge + extconf.rb rdiscount.c ← Ruby-C bridge (do NOT overwrite during gather) extconf.rb ← mkmf build config (do NOT overwrite during gather) config.h ← RDiscount-specific (do NOT overwrite during gather) lib/ rdiscount.rb ← Ruby API class, VERSION constant (single source of truth) markdown.rb ← BlueCloth compatibility alias test/ ← Test::Unit tests + MarkdownTest conformance suites ext.diff ← Patches applied to Discount sources in ext/ after copying ``` ### How Discount sources flow into ext/ 1. `git submodule update --init` fetches `discount/` 2. `cd discount && ./configure.sh` generates config 3. `rake gather` copies `*.c`, `*.h` from `discount/` → `ext/` (skipping files with `main()` and RDiscount-specific files) 4. `ext.diff` is applied via `patch -p1 -d ext` See [BUILDING](../BUILDING) for the full upgrade procedure. ## Key Conventions - **Version**: Single source of truth is `VERSION` constant in `lib/rdiscount.rb`. The gemspec extracts it automatically. - **Testing pattern**: Create `RDiscount.new(text, *flags)`, call `.to_html`, assert output HTML. - **Locale**: The C bridge sets `LC_CTYPE=C` during processing for consistent ASCII behavior regardless of Ruby's UTF-8 locale. - **Default flags**: Always enabled: `MKD_TABSTOP | MKD_NOHEADER | MKD_DLEXTRA | MKD_FENCEDCODE | MKD_GITHUBTAGS`. - **Flag mapping**: Ruby boolean accessors (e.g., `:smart`, `:autolink`) map to Discount C flags in the `ACCESSOR_2_FLAG[]` array in `ext/rdiscount.c`. ## Files You Should NOT Edit Directly The following files in `ext/` are **copied from discount/** by `rake gather` and will be overwritten: - All `*.c` and `*.h` files EXCEPT `rdiscount.c`, `extconf.rb`, `config.h`, `ruby-config.h` To make persistent changes to Discount sources, update `ext.diff` instead. ## Release Process 1. Update `VERSION` in `lib/rdiscount.rb` 2. `rake rdiscount.gemspec` — regenerates file manifest 3. `rake test` — verify all tests pass 4. `gem build rdiscount.gemspec` 5. `gem push rdiscount-X.Y.Z.gem` davidfstr-rdiscount-d6465ee/.github/workflows/ 0000775 0000000 0000000 00000000000 15173533273 0021542 5 ustar 00root root 0000000 0000000 davidfstr-rdiscount-d6465ee/.github/workflows/main.yml 0000664 0000000 0000000 00000001357 15173533273 0023217 0 ustar 00root root 0000000 0000000 name: CI on: [push, pull_request, workflow_dispatch] jobs: test: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] ruby-version: ['4.0', '3.4', '3.3', '3.2', '3.1', '3.0', '2.7', truffleruby] # conformance require perl because of that we # only run unit tests on windows include: - os: windows-latest args: test:unit exclude: - os: windows-latest ruby-version: truffleruby runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6 with: submodules: recursive - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} - run: rake ${{matrix.args}} davidfstr-rdiscount-d6465ee/.gitignore 0000664 0000000 0000000 00000000416 15173533273 0020136 0 ustar 00root root 0000000 0000000 # AI Coding /plan # Operating System: macOS .DS_Store # Build outputs rdiscount-*.gem # Other /ext/*.o /ext/*.bundle /ext/*.bundle.dSYM /ext/*.so /ext/*.dll /ext/mkmf.log /ext/ruby-* /lib/*.bundle /lib/*.so /lib/*.dll /ext/Makefile /pkg /discount-* .yardoc doc .idea davidfstr-rdiscount-d6465ee/.gitmodules 0000664 0000000 0000000 00000000117 15173533273 0020321 0 ustar 00root root 0000000 0000000 [submodule "discount"] path = discount url = git@github.com:Orc/discount.git davidfstr-rdiscount-d6465ee/BUILDING 0000664 0000000 0000000 00000011171 15173533273 0017266 0 ustar 00root root 0000000 0000000 BUILDING rdiscount ================== You'll be needing Ruby, rake, and a basic build environment. Build the rdiscount extension for tests and local development: $ rake build Use your rdiscount working copy when running ruby programs: $ export RUBYLIB=~/rdiscount/lib:$RUBYLIB $ ruby some-program.rb Gathering changes from an upstream discount clone requires first grabbing the discount submodule into the root of the project and then running the rake gather task to copy discount source files into the ext/ directory: $ git submodule update --init Submodule 'discount' (git@github.com:Orc/discount.git) registered for path 'discount' Cloning into discount... $ cd discount $ ./configure.sh $ make # ensure it compiles $ cd .. $ rake gather $ rake build UPGRADING Discount ================== The most common maintenance task is upgrading the version of Discount that RDiscount is using. Before doing anything, make sure you can build the current (unmodified) version of RDiscount. See the section above for details. Update the Discount submodule to the desired version: $ cd discount $ git fetch $ git checkout v2.0.7.x # insert desired version $ cd .. Copy the new Discount sources to the appropriate directories for RDiscount: $ rake gather Update rdiscount.gemspec to include all *.c, *.h, and *.rb files in ext: $ rake rdiscount.gemspec Build the RDiscount gem. If you get errors related to missing files in ext, make sure you updated the gemspec correctly in the previous step. $ gem build rdiscount.gemspec Install this new gem locally. It is recommended that you use RVM to create an isolated installation environment. If you get an error after the line "Building native extensions", see the troubleshooting section below. $ rvm ruby@rdiscount --create # recommended; requires RVM $ gem install rdiscount-*.gem Make sure the gem can be imported: $ ruby -e 'require "rdiscount"' Make sure the tests (still) pass: $ rake test Worked? Swell! The hard part is past. Check the Discount release notes to determine whether it has gained any new features that should be exposed through the RDiscount Ruby interface (lib/rdiscount.rb), such as new MKD_* flags or configure flags. If so, update the Ruby interface. If the ./configure.sh line needs to be changed to support new features, you will need to port some #defines from discount/config.h to ext/config.h manually to get RDiscount's embedded Discount to use the same configure flags. For new Discount extensions via new MKD_* flags, you will need to update: * lib/rdiscount.rb with new accessors and * the rb_rdiscount__get_flags function in ext/rdiscount.c with new accessor-to-flag mappings for each new extension. You should also look for RDiscount-specific bugs & feature requests in the GitHub tracker and fix a few. If any bugs were fixed or features added be sure to also add new tests! And don't forget to rerun the preexisting tests. Update the CHANGELOG. Update rdiscount.gemspec with the new RDiscount version number. Also update the VERSION constant in lib/rdiscount.rb. Push that change as the final commit with a message in the format "2.0.7 release". Tag the release commit: $ git tag 2.0.7 # insert desired version Rebuild the gem file and push it to RubyGems. $ gem build rdiscount.gemspec $ gem push rdiscount-NEW_VERSION.gem Announce the new release! For releases with new features it is recommended to write a full blog post. Troubleshooting Native Extension Issues --------------------------------------- The most likely place where errors will crop up is when you attempt to build the C extension. If this happens, you will have to debug manually. Below are a few recommended sanity checks: Ensure the Makefile is generated correctly: $ cd ext $ ruby extconf.rb Ensure make succeeds: $ make If you get linker errors related to there being duplicate symbols for _main, you probably need to update the deploy target of the Rakefile to exclude new *.c files from Discount that have a main function. For issues related to config.h or extconf.rb, there was probably some change to Discount's configure.sh that broke them. You will probably need to update these files in ext/ manually. For other errors, you'll have to investigate yourself. Common error classes: * 'ext/configure.sh' fails: - Create a patch to the upstream Discount. * Some files missing from ext/ that are present in discount/: - Update 'rake deploy' target to copy more files. * Some files missing when `gem build` is run: - Update gemspec to enumerate the correct files in ext/. davidfstr-rdiscount-d6465ee/CHANGELOG.md 0000664 0000000 0000000 00000011317 15173533273 0017761 0 ustar 00root root 0000000 0000000 # RDiscount Changelog ## Version 2.2.7.5 (April 26, 2026) * Fix build failure in newer compilers that use C23 mode by default, such as Clang on macOS. ## Version 2.2.7.4 (April 1, 2026) * Fix crash if `to_html` called on a string longer than INT_MAX (2 GiB of text). ## Version 2.2.7.3 (December 31, 2023) * Add Ruby 3.2 and 3.3 to continuous integration * Reinstate fix for compilation issue with Clang 16 ## Version 2.2.7.2 (December 19, 2023) * Discount upgraded from 2.2.7c -> 2.2.7d * Fix compilation on openSUSE Tumbleweed ## Version 2.2.7.1 (June 16, 2023) * Fix to not filter out ` EOS assert_equal "
Hello
\n\n\n\n", rd.to_html end def test_that_style_tag_is_filtered_with_flag rd = RDiscount.new(<Hello
\n\n\n", rd.to_html end def test_that_tables_can_have_leading_and_trailing_pipes rd = RDiscount.new(<line 1\n\nline 2\n\n", rd.to_html
end
def test_that_gfm_code_blocks_work_with_language
rd = RDiscount.new(<line 1\n\nline 2\n\n", rd.to_html
end
def test_that_pandoc_code_blocks_work
rd = RDiscount.new(<line 1\n\nline 2\n\n", rd.to_html
end
def test_that_discount_definition_lists_work
rd = RDiscount.new(<$$[(1+2)*3-4](1-2)$$
\n", rd.to_html end def test_that_emphasis_beside_international_characters_detected rd = RDiscount.new(%(*foo ä bar*)) assert_equal %(foo ä bar
\n), rd.to_html rd = RDiscount.new(%(*ä foobar*)) assert_equal %(ä foobar
\n), rd.to_html rd = RDiscount.new(%(*foobar ä*)) assert_equal %(foobar ä
\n), rd.to_html end def test_taht rd = RDiscount.new(<