diff --git a/.github/workflows/cloudflare-preview.yml b/.github/workflows/cloudflare-preview.yml index f3917cc05c..c13476a259 100644 --- a/.github/workflows/cloudflare-preview.yml +++ b/.github/workflows/cloudflare-preview.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout PR Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: ${{ github.event.client_payload.pr_checkout_repository }} ref: ${{ github.event.client_payload.pr_head_sha }} diff --git a/.github/workflows/fork-preview-deploy.yml b/.github/workflows/fork-preview-deploy.yml index 995f63abbd..a6a58b17ea 100644 --- a/.github/workflows/fork-preview-deploy.yml +++ b/.github/workflows/fork-preview-deploy.yml @@ -14,7 +14,7 @@ jobs: github.event.workflow_run.event == 'pull_request' steps: - name: Download PR information - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: pr github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index d5d467cd46..3aed342352 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -20,7 +20,7 @@ jobs: if: ${{ github.repository == 'ruby/rdoc' && !startsWith(github.event_name, 'pull') }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Ruby uses: ruby/setup-ruby@eaecf785f6a34567a6d97f686bbb7bccc1ac1e5c # v1.237.0 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 27ea686ca1..3a744e26f5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 # v3.3.0 + - uses: actions/checkout@v5 # v3.3.0 # libyaml-dev is needed for psych, see https://github.com/ruby/setup-ruby/issues/409 - if: ${{ matrix.os == 'ubuntu-latest' }} run: sudo apt install libyaml-dev diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 73d5173320..50fed5315b 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -27,7 +27,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set up Ruby uses: ruby/setup-ruby@eaecf785f6a34567a6d97f686bbb7bccc1ac1e5c # v1.237.0 diff --git a/.github/workflows/ruby-core.yml b/.github/workflows/ruby-core.yml index f243aa14ca..d0f2754111 100644 --- a/.github/workflows/ruby-core.yml +++ b/.github/workflows/ruby-core.yml @@ -28,7 +28,7 @@ jobs: bundler: none - name: Save latest buildable revision to environment run: echo "REF=$(ruby -v | cut -d')' -f1 | cut -d' ' -f5)" >> $GITHUB_ENV - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3.1.0 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v3.1.0 with: repository: ruby/ruby path: ruby/ruby @@ -51,7 +51,7 @@ jobs: autoconf ./configure -C --disable-install-doc working-directory: ruby/ruby - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3.1.0 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v3.1.0 with: path: ruby/rdoc - name: Build RDoc locally diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce0b9aedef..ab26d8030b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 # v3.3.0 + - uses: actions/checkout@v5 # v3.3.0 # libyaml-dev is needed for psych, see https://github.com/ruby/setup-ruby/issues/409 - if: ${{ matrix.os == 'ubuntu-latest' }} run: sudo apt install libyaml-dev diff --git a/lib/rdoc/markdown.kpeg b/lib/rdoc/markdown.kpeg index 174206ea74..46c8f07f41 100644 --- a/lib/rdoc/markdown.kpeg +++ b/lib/rdoc/markdown.kpeg @@ -497,6 +497,17 @@ end end + ## + # Wraps `text` in code markup for rdoc inline formatting + + def code text + # trim even spaces + text = $2 while /\A( +|\t+)(.*)\1\z/ =~ text + # escape unescaped backslash at the end + backslash_at_end = "\\" if /(?#{text}#{backslash_at_end}" + end + ## # Parses inline markdown in table cells @@ -1104,32 +1115,32 @@ Ticks3 = "```" !"`" Ticks4 = "````" !"`" Ticks5 = "`````" !"`" -Code = ( Ticks1 @Sp < ( +Code = ( Ticks1 < ( ( !"`" Nonspacechar )+ | !Ticks1 /`+/ | - !( @Sp Ticks1 ) ( @Spacechar | @Newline !@BlankLine ) - )+ > @Sp Ticks1 | - Ticks2 @Sp < ( + !Ticks1 ( @Spacechar | @Newline !@BlankLine ) + )+ > Ticks1 | + Ticks2 < ( ( !"`" Nonspacechar )+ | !Ticks2 /`+/ | - !( @Sp Ticks2 ) ( @Spacechar | @Newline !@BlankLine ) - )+ > @Sp Ticks2 | - Ticks3 @Sp < ( + !Ticks2 ( @Spacechar | @Newline !@BlankLine ) + )+ > Ticks2 | + Ticks3 < ( ( !"`" Nonspacechar )+ | !Ticks3 /`+/ | - !( @Sp Ticks3 ) ( @Spacechar | @Newline !@BlankLine ) - )+ > @Sp Ticks3 | - Ticks4 @Sp < ( + !Ticks3 ( @Spacechar | @Newline !@BlankLine ) + )+ > Ticks3 | + Ticks4 < ( ( !"`" Nonspacechar )+ | !Ticks4 /`+/ | - !( @Sp Ticks4 ) ( @Spacechar | @Newline !@BlankLine ) - )+ > @Sp Ticks4 | - Ticks5 @Sp < ( + !Ticks4 ( @Spacechar | @Newline !@BlankLine ) + )+ > Ticks4 | + Ticks5 < ( ( !"`" Nonspacechar )+ | !Ticks5 /`+/ | - !( @Sp Ticks5 ) ( @Spacechar | @Newline !@BlankLine ) - )+ > @Sp Ticks5 + !Ticks5 ( @Spacechar | @Newline !@BlankLine ) + )+ > Ticks5 ) - { "#{text}" } + { code text } RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) > { if html? then text else '' end } diff --git a/test/rdoc/rdoc_generator_darkfish_test.rb b/test/rdoc/rdoc_generator_darkfish_test.rb index 67715951ec..52ae0601d3 100644 --- a/test/rdoc/rdoc_generator_darkfish_test.rb +++ b/test/rdoc/rdoc_generator_darkfish_test.rb @@ -469,7 +469,8 @@ def test_meta_tags_for_markdown_files_paragraph top_level.comment = <<~MARKDOWN # Distributed Ruby: dRuby - dRuby is a distributed object system for Ruby. It allows an object. + dRuby is a distributed object system for Ruby. It allows an object in one + Ruby process to invoke methods on an object in another Ruby process. MARKDOWN @g.generate @@ -480,7 +481,7 @@ def test_meta_tags_for_markdown_files_paragraph "text")) assert_equal expected, doc + doc = parse "Code: ` text`" + expected = doc(para("Code: text")) + assert_equal expected, doc + + doc = parse "Code: `text `" + expected = doc(para("Code: text ")) + assert_equal expected, doc + doc = parse "Code: ` text `" expected = doc(para("Code: text")) assert_equal expected, doc + doc = parse "Code: ` text\t`" + expected = doc(para("Code: text\t")) + assert_equal expected, doc + + doc = parse "Code: `\ttext `" + expected = doc(para("Code: \ttext ")) + assert_equal expected, doc + doc = parse "Code: ``text`s``" expected = doc(para("Code: text`s")) assert_equal expected, doc + doc = parse "Code: `` text`s``" + expected = doc(para("Code: text`s")) + assert_equal expected, doc + + doc = parse "Code: ``text`s ``" + expected = doc(para("Code: text`s ")) + assert_equal expected, doc + doc = parse "Code: `` text`s ``" expected = doc(para("Code: text`s")) assert_equal expected, doc + doc = parse "Code: `` text`s\t``" + expected = doc(para("Code: text`s\t")) + assert_equal expected, doc + + doc = parse "Code: ``\ttext`s ``" + expected = doc(para("Code: \ttext`s ")) + assert_equal expected, doc + doc = parse "Code: ```text`s```" expected = doc(para("Code: text`s")) assert_equal expected, doc + doc = parse "Code: ``` text`s```" + expected = doc(para("Code: text`s")) + assert_equal expected, doc + + doc = parse "Code: ```text`s ```" + expected = doc(para("Code: text`s ")) + assert_equal expected, doc + doc = parse "Code: ``` text`s ```" expected = doc(para("Code: text`s")) assert_equal expected, doc + + doc = parse "Code: ``` text`s\t```" + expected = doc(para("Code: text`s\t")) + assert_equal expected, doc + + doc = parse "Code: ```\ttext`s ```" + expected = doc(para("Code: \ttext`s ")) + assert_equal expected, doc + + doc = parse "Code: `\\`" + expected = doc(para("Code: \\\\")) + assert_equal expected, doc + + doc = parse "Code: ` \\ `" + expected = doc(para("Code: \\\\")) + assert_equal expected, doc + + doc = parse "Code: `\\`s`" + expected = doc(para("Code: \\\\s`")) + assert_equal expected, doc + + doc = parse "Code: ``\\`s``" + expected = doc(para("Code: \\`s")) + assert_equal expected, doc + + doc = parse "Code: `` \\`s ``" + expected = doc(para("Code: \\`s")) + assert_equal expected, doc + + doc = parse "Code: ```\\`s```" + expected = doc(para("Code: \\`s")) + assert_equal expected, doc + + doc = parse "Code: ``` \\`s ```" + expected = doc(para("Code: \\`s")) + assert_equal expected, doc end def test_parse_code_github @@ -195,7 +271,7 @@ def test_parse_code_github_format doc = <<-MD Example: -``` ruby +```ruby code goes here ``` MD @@ -1173,14 +1249,14 @@ def test_gfm_table_with_backslashes_in_code_spans body = [ ['Plain', '$\\\\', 'Should show backslash'], - ['Escaped', '$\\\\', 'Should show backslash'], + ['Escaped', '$\\\\ ', 'Should show backslash'], ['Multiple', '\\\\n\\\\t', 'Should show backslashes'], ] expected_table = @RM::Table.new(head, align, body) expected = doc( - para('Plain text: $\\\\ and $\\\\ should work.'), + para('Plain text: $\\\\ and $\\\\ should work.'), expected_table )