nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: arve0/markdown-it-attrs
Pull request #53 (2018-01-07 12:12:10)

avoid "end of block" applying to code_inline
fixes issue #50


Patch:
diff --git a/patterns.js b/patterns.js
index 9a9c071..f79beae 100644
--- a/patterns.js
+++ b/patterns.js
@@ -272,7 +272,8 @@ module.exports = [
         children: [
           {
             position: -1,
-            content: utils.hasCurly('end')
+            content: utils.hasCurly('end'),
+            type: (t) => t !== 'code_inline'
           }
         ]
       }


Test patch:
diff --git a/test.js b/test.js
index f9cf460..cab5671 100644
--- a/test.js
+++ b/test.js
@@ -255,5 +255,11 @@ describe('markdown-it-attrs', () => {
     expected = '<figure><img src="img.png" alt="alt" class="a"></figure>\n';
     assert.equal(md.render(src), expected);
   });
+
+  it('should not apply inside `code{.red}`', () => {
+    src =  'paragraph `code{.red}`';
+    expected = '<p>paragraph <code>code{.red}</code></p>\n';
+    assert.equal(md.render(src), expected);
+  });
 });
Repository: arve0/markdown-it-attrs
Pull request #54 (2018-01-07 12:32:21)

support multiple "inline nesting 0" in same paragraph
fixes issue #52


Patch:
diff --git a/index.js b/index.js
index ac8386d..48aec4f 100644
--- a/index.js
+++ b/index.js
@@ -18,7 +18,7 @@ module.exports = function attributes(md) {
         });
         if (match) {
           pattern.transform(tokens, i, j);
-          if (pattern.name === 'inline attributes') {
+          if (pattern.name === 'inline attributes' || pattern.name === 'inline nesting 0') {
             // retry, may be several inline attributes
             p--;
           }


Test patch:
diff --git a/test.js b/test.js
index cab5671..2752ea3 100644
--- a/test.js
+++ b/test.js
@@ -261,5 +261,11 @@ describe('markdown-it-attrs', () => {
     expected = '<p>paragraph <code>code{.red}</code></p>\n';
     assert.equal(md.render(src), expected);
   });
+
+  it('should work with multiple inline code blocks in same paragraph', () => {
+    src = 'bla `click()`{.c} blah `release()`{.cpp}';
+    expected = '<p>bla <code class="c">click()</code> blah <code class="cpp">release()</code></p>\n';
+    assert.equal(md.render(src), expected);
+  });
 });
Repository: arve0/markdown-it-attrs
Pull request #60 (2018-05-06 05:00:49)

do not match for short curlies when repeating: {1}{2}
fixes issue #58


Patch:
diff --git a/utils.js b/utils.js
index e1a6c9c..031034d 100644
--- a/utils.js
+++ b/utils.js
@@ -157,7 +157,7 @@ exports.hasCurly = function (where) {
     case 'end':
       // last char should be }
       end = str.charAt(str.length - 1) === '}';
-      start = end && str.indexOf('{');
+      start = end && str.lastIndexOf('{');
       return end && (start + 3) < str.length;
 
     case 'only':


Test patch:
diff --git a/test.js b/test.js
index 2752ea3..7bd56c5 100644
--- a/test.js
+++ b/test.js
@@ -267,5 +267,11 @@ describe('markdown-it-attrs', () => {
     expected = '<p>bla <code class="c">click()</code> blah <code class="cpp">release()</code></p>\n';
     assert.equal(md.render(src), expected);
   });
+
+  it('should not remove {} curlies with length < 4', () => {
+    src = 'do not remove the curlies {1}{2}';
+    expected = '<p>do not remove the curlies {1}{2}</p>\n';
+    assert.equal(md.render(src), expected);
+  });
 });
Repository: arve0/markdown-it-attrs
Pull request #68 (2018-06-09 19:04:43)

support horizontal rule <hr> --- {#id}
Closes #68 


Patch:
diff --git a/patterns.js b/patterns.js
index a389003..dc1346c 100644
--- a/patterns.js
+++ b/patterns.js
@@ -260,6 +260,38 @@ module.exports = options => ([
       utils.addAttrs(attrs, openingToken);
       tokens[i].children = tokens[i].children.slice(0, -2);
     }
+  }, {
+    /**
+     * horizontal rule --- {#id}
+     */
+    name: 'horizontal rule',
+    tests: [
+      {
+        shift: 0,
+        type: 'paragraph_open'
+      },
+      {
+        shift: 1,
+        type: 'inline',
+        children: (arr) => arr.length === 1,
+        content: (str) => str.match(/^ {0,3}[-*_]{3,} {0,1}\{[^{]/) !== null
+      },
+      {
+        shift: 2,
+        type: 'paragraph_close'
+      }
+    ],
+    transform: (tokens, i) => {
+      let token = tokens[i];
+      token.type = 'hr';
+      token.tag = 'hr';
+      token.nesting = 0;
+      let content = tokens[i + 1].content;
+      let start = content.lastIndexOf('{');
+      token.attrs = utils.getAttrs(content, start, options);
+      token.markup = content;
+      tokens.splice(i + 1, 2);
+    }
   }, {
     /**
      * end of {.block}


Test patch:
diff --git a/test.js b/test.js
index db0598a..5ca0c36 100644
--- a/test.js
+++ b/test.js
@@ -313,5 +313,12 @@ describe('markdown-it-attrs', () => {
     expected += '</ul>\n';
     assert.equal(md.render(src), expected);
   });
+
+  it('should support horizontal rules ---{#id}', () => {
+    src = '---{#id}';
+    expected = '<hr id="id">\n';
+    assert.equal(md.render(src), expected);
+  });
+
 });
Repository: arve0/markdown-it-attrs
Pull request #133 (2021-12-28 12:35:51)

hr elements does not accept multiple classes
Hi @arve0, 
after looking at the code more carefully, the issue discussed in https://github.com/arve0/markdown-it-attrs/issues/131 turns out to be in `markdown-it-attrs`. It's a very minor bug that only affects hr elements. I am working on a project that uses `markdown-it-attrs` (Thank you 😃), hence putting up this PR to fix the issue at the root.

---
This PR fixes https://github.com/arve0/markdown-it-attrs/issues/131

Like other elements, hr elements should also allow multiple
classes to be added. Currently, hr elements have a direct
assignment of attributes in patterns.js. Thus, multiple
class attributes are not combined into one.

By using the `utils.addAttrs` method, the attribute values
will be merged correctly.

This bug fix helps with attributes on hr elements.
Example:`--- {.a .b}`
Before:`<hr class='a' class='b'>`
After: `<hr class='a b'>`

PS:
I am not sure if I should update browser.js, please feel free to let me know if it needs to be done:)


Patch:
diff --git a/patterns.js b/patterns.js
index 0744a7b..1acec80 100644
--- a/patterns.js
+++ b/patterns.js
@@ -296,7 +296,8 @@ module.exports = options => {
         token.nesting = 0;
         let content = tokens[i + 1].content;
         let start = content.lastIndexOf(options.leftDelimiter);
-        token.attrs = utils.getAttrs(content, start, options);
+        let attrs = utils.getAttrs(content, start, options);
+        utils.addAttrs(attrs, token);
         token.markup = content;
         tokens.splice(i + 1, 2);
       }


Test patch:
diff --git a/test.js b/test.js
index 5589436..bffdae9 100644
--- a/test.js
+++ b/test.js
@@ -389,6 +389,12 @@ function describeTestsWithOptions(options, postText) {
       expected = '<p class="someclass" attr="allowed">text</p>\n';
       assert.equal(md.render(replaceDelimiters(src, options)), expected);
     });
+
+    it(replaceDelimiters('should support multiple classes for <hr>', options), () => {
+      src = '--- {.a .b}';
+      expected = '<hr class="a b">\n';
+      assert.equal(md.render(replaceDelimiters(src, options)), expected);
+    });
   });
 }
Repository: swup/swup
Pull request #995 (2025-04-29 08:31:02)

fix: `matchPath`: treat empty array like an empty string
Replaces #994

**Description**

- Transform an empty array to a string before passing it to `match`
- Fixes https://github.com/pillarjs/path-to-regexp/issues/291 without the need for a breaking update to `path-to-regexp`
- Drive-By: Simplify `matchPath` by passing on the argument types using `Parameters<typeof match>`

**Checks**

<!--
Make sure the PR fulfills as many of the following requirements as possible
-->

- [x] The PR is submitted to the `main` branch
- [x] The code was linted before pushing (`npm run lint`)
- [x] All tests are passing (`npm run test`)
- [x] New or updated tests are included




Patch:
diff --git a/src/helpers/matchPath.ts b/src/helpers/matchPath.ts
index e133291..63cb153 100644
--- a/src/helpers/matchPath.ts
+++ b/src/helpers/matchPath.ts
@@ -1,20 +1,20 @@
 import { match } from 'path-to-regexp';
 
-import type {
-	Path,
-	ParseOptions,
-	TokensToRegexpOptions,
-	RegexpToFunctionOptions,
-	MatchFunction
-} from 'path-to-regexp';
+import type { Path, MatchFunction } from 'path-to-regexp';
 
 export { type Path };
 
+type Params = Parameters<typeof match>;
+
 /** Create a match function from a path pattern that checks if a URLs matches it. */
 export const matchPath = <P extends object = object>(
-	path: Path,
-	options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions
+	path: Params[0],
+	options?: Params[1]
 ): MatchFunction<P> => {
+	if (Array.isArray(path) && !path.length) {
+		path = '';
+	}
+
 	try {
 		return match<P>(path, options);
 	} catch (error) {


Test patch:
diff --git a/tests/unit/matchPath.test.ts b/tests/unit/matchPath.test.ts
index c675dc2..f5933a7 100644
--- a/tests/unit/matchPath.test.ts
+++ b/tests/unit/matchPath.test.ts
@@ -51,4 +51,12 @@ describe('matchPath', () => {
 		// prettier-ignore
 		expect(() => matchPath('/\?user=:user')).toThrowError('[swup] Error parsing path');
 	});
+
+	it('should treat an empty array like an empty string', () => {
+		const urlMatch = matchPath([]);
+
+		expect(urlMatch('')).toEqual({ index: 0, path: '', params: {} });
+
+		expect(urlMatch('/foo/bar')).toBe(false);
+	});
 });
Repository: syuilo/aiscript
Pull request #317 (2023-08-31 23:16:11)

オブジェクトの要素を配列と同じ構文で参照可能に
```
object['index']
```
の形でオブジェクトの要素を取得できるようにします。
## why
`Obj:get(object, 'index')`より直感的な形式を提供するため。


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 51bc0c5..c814152 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,9 @@
 [Read translated version (en)](./translations/en/CHANGELOG.md)
 
 - `Core:to_str`, `テンプレート文字列` でどの値でも文字列へ変換できるように
-
 - 指定時間待機する関数`Core:sleep`を追加
 - `exists 変数名` の構文で変数が存在するか判定できるように
+- オブジェクトを添字で参照できるように（`object['index']`のように）
 
 # 0.15.0
 - Mathを強化
diff --git a/src/interpreter/index.ts b/src/interpreter/index.ts
index 17052d3..cfc359d 100644
--- a/src/interpreter/index.ts
+++ b/src/interpreter/index.ts
@@ -392,14 +392,24 @@ export class Interpreter {
 
 			case 'index': {
 				const target = await this._eval(node.target, scope);
-				assertArray(target);
 				const i = await this._eval(node.index, scope);
-				assertNumber(i);
-				const item = target.value[i.value];
-				if (item === undefined) {
-					throw new IndexOutOfRangeError(`Index out of range. index: ${i.value} max: ${target.value.length - 1}`);
+				if (isArray(target)) {
+					assertNumber(i);
+					const item = target.value[i.value];
+					if (item === undefined) {
+						throw new IndexOutOfRangeError(`Index out of range. index: ${i.value} max: ${target.value.length - 1}`);
+					}
+					return item;
+				} else if (isObject(target)) {
+					assertString(i);
+					if (target.value.has(i.value)) {
+						return target.value.get(i.value)!;
+					} else {
+						return NULL;
+					}
+				} else {
+					throw new RuntimeError(`Cannot read prop (${reprValue(i)}) of ${target.type}.`);
 				}
-				return item;
 			}
 
 			case 'not': {
@@ -540,12 +550,16 @@ export class Interpreter {
 			scope.assign(dest.name, value);
 		} else if (dest.type === 'index') {
 			const assignee = await this._eval(dest.target, scope);
-			assertArray(assignee);
-
 			const i = await this._eval(dest.index, scope);
-			assertNumber(i);
-
-			assignee.value[i.value] = value; // TODO: 存在チェック
+			if (isArray(assignee)) {
+				assertNumber(i);
+				assignee.value[i.value] = value; // TODO: 存在チェック
+			} else if (isObject(assignee)) {
+				assertString(i);
+				assignee.value.set(i.value, value);
+			} else {
+				throw new RuntimeError(`Cannot read prop (${reprValue(i)}) of ${assignee.type}.`);
+			}
 		} else if (dest.type === 'prop') {
 			const assignee = await this._eval(dest.target, scope);
 			assertObject(assignee);


Test patch:
diff --git a/test/index.ts b/test/index.ts
index 70e28de..6e4c977 100644
--- a/test/index.ts
+++ b/test/index.ts
@@ -1048,6 +1048,14 @@ describe('chain', () => {
 		`);
 		eq(res, NUM(45));
 	});
+
+	test.concurrent('object with index', async () => {
+		const res = await exe(`
+		let ai = {a: {}}['a']
+		ai['chan'] = 'kawaii'
+		<: ai[{a: 'chan'}['a']]
+		`);
+		eq(res, STR('kawaii'));
 });
 
 describe('Template syntax', () => {
Repository: xiCO2k/laravel-vue-i18n
Pull request #25 (2022-04-24 18:35:39)

fix: Concatenation in PHP language files causes error in loader


Patch:
diff --git a/.gitignore b/.gitignore
index f203036..cde09bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.idea
 /node_modules
 /coverage
 /dist
diff --git a/src/loader.ts b/src/loader.ts
index a3fef72..e9b8128 100644
--- a/src/loader.ts
+++ b/src/loader.ts
@@ -84,6 +84,10 @@ const parseItem = (expr) => {
     return items
   }
 
+  if (expr.kind === 'bin') {
+    return parseItem(expr.left) + parseItem(expr.right);
+  }
+
   if (expr.key) {
     return { [expr.key.value]: parseItem(expr.value) }
   }


Test patch:
diff --git a/test/fixtures/lang/en/auth.php b/test/fixtures/lang/en/auth.php
index 1d5c80b..47137cd 100644
--- a/test/fixtures/lang/en/auth.php
+++ b/test/fixtures/lang/en/auth.php
@@ -9,4 +9,9 @@ return [
         ]
     ],
     'arr' => ['foo', 'bar'],
+    'multiline' => 'Lorem ' .
+        'ipsum ' .
+        'dolor ' .
+        'sit ' . 
+        'amet.',
 ];
diff --git a/test/loader.test.ts b/test/loader.test.ts
index abb2fa9..637128e 100644
--- a/test/loader.test.ts
+++ b/test/loader.test.ts
@@ -14,6 +14,7 @@ it('creates a file for each lang', () => {
     const langEn = JSON.parse(fs.readFileSync(files[0].path).toString());
     expect(langEn['auth.failed']).toBe('These credentials do not match our records.');
     expect(langEn['auth.foo.level1.level2']).toBe('baren');
+    expect(langEn['auth.multiline']).toBe('Lorem ipsum dolor sit amet.');
 
     const langPt = JSON.parse(fs.readFileSync(files[2].path).toString());
     expect(langPt['auth.failed']).toBe('As credenciais indicadas não coincidem com as registadas no sistema.');
Repository: xiCO2k/laravel-vue-i18n
Pull request #70 (2022-10-03 20:05:42)

Added onLoad Option which is called after language is loaded.
Added `onLoad` field to the options which is called after language is loaded.


Patch:
diff --git a/src/index.ts b/src/index.ts
index 0a0af7c..97c3c18 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -21,7 +21,8 @@ let sharedInstance: I18n = null
 const DEFAULT_OPTIONS: OptionsInterface = {
   lang: !isServer && document.documentElement.lang ? document.documentElement.lang.replace('-', '_') : null,
   fallbackLang: 'en',
-  resolve: (lang: string) => new Promise((resolve) => resolve({ default: {} }))
+  resolve: (lang: string) => new Promise((resolve) => resolve({ default: {} })),
+  onLoad: (lang: string) => {}
 }
 
 /**
@@ -305,6 +306,7 @@ export class I18n {
       }
     }
 
+    this.options.onLoad(lang)
     return lang
   }
 
diff --git a/src/interfaces/options.ts b/src/interfaces/options.ts
index 8c5e4ef..da4dd00 100644
--- a/src/interfaces/options.ts
+++ b/src/interfaces/options.ts
@@ -7,4 +7,5 @@ export interface OptionsInterface {
   lang?: string
   fallbackLang?: string
   resolve?(lang: string): Promise<LanguageJsonFileInterface>
+  onLoad?: (lang: string) => void
 }


Test patch:
diff --git a/test/class.test.ts b/test/class.test.ts
index 525931f..0b24129 100644
--- a/test/class.test.ts
+++ b/test/class.test.ts
@@ -68,3 +68,19 @@ it('allows resetting all data', async () => {
     expect(i18n.getActiveLanguage()).toBe('en')
     expect(i18n.trans('Welcome!')).toBe('Welcome!')
 })
+
+it('calls onLoad when loaded', async () => {
+    const onLoadFunction = jest.fn()
+
+    const i18n = new I18n({
+        lang: 'pt',
+        resolve: lang => import(`./fixtures/lang/${lang}.json`),
+        onLoad: onLoadFunction
+    })
+
+    await i18n.loadLanguageAsync('en')
+
+    expect(onLoadFunction).toHaveBeenCalledTimes(2)
+    expect(onLoadFunction).toHaveBeenCalledWith('en')
+    expect(onLoadFunction).toHaveBeenCalledWith('pt')
+})
Repository: xiCO2k/laravel-vue-i18n
Pull request #89 (2022-12-19 17:23:47)

fix: Translation of strings that use delimiter symbols
When using the `/` delimiter we should check whether the translation exists or not before replacing the string.


Patch:
diff --git a/src/index.ts b/src/index.ts
index b413be3..635032f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -337,7 +337,9 @@ export class I18n {
    * Get the translation for the given key and watch for any changes.
    */
   wTrans(key: string, replacements: ReplacementsInterface = {}): ComputedRef<string> {
-    key = key.replace(/\//g, '.')
+    if (!this.activeMessages[key] && !this.activeMessages[`${key}.0`]) {
+      key = key.replace(/\//g, '.')
+    }
 
     if (!this.activeMessages[key]) {
       const hasChildItems = this.activeMessages[`${key}.0`] !== undefined


Test patch:
diff --git a/test/fixtures/lang/en.json b/test/fixtures/lang/en.json
index f10f7c8..1bf8abb 100644
--- a/test/fixtures/lang/en.json
+++ b/test/fixtures/lang/en.json
@@ -2,5 +2,7 @@
     "Welcome!": "Wecome!",
     "Welcome, :name!": "Welcome, :name!",
     "Only Available on EN": "Only Available on EN",
-    "{1} :count minute ago|[2,*] :count minutes ago": "{1} :count minute ago|[2,*] :count minutes ago"
+    "{1} :count minute ago|[2,*] :count minutes ago": "{1} :count minute ago|[2,*] :count minutes ago",
+    "Start/end": "Start/End",
+    "Get started.": "Get started."
 }
diff --git a/test/fixtures/lang/pt.json b/test/fixtures/lang/pt.json
index 2e9ac78..9c15cf0 100644
--- a/test/fixtures/lang/pt.json
+++ b/test/fixtures/lang/pt.json
@@ -2,5 +2,7 @@
     "Welcome!": "Bem-vindo!",
     "Welcome, :name!": "Bem-vindo, :name!",
     "{1} :count minute ago|[2,*] :count minutes ago": "{1} há :count minuto|[2,*] há :count minutos",
-    "foo.bar": "baz"
+    "foo.bar": "baz",
+    "Start/end": "Início/Fim",
+    "Get started.": "Comece."
 }
diff --git a/test/translate.test.ts b/test/translate.test.ts
index 883a807..80d8a46 100644
--- a/test/translate.test.ts
+++ b/test/translate.test.ts
@@ -197,4 +197,11 @@ it('translates a nested file item while using "/" and "." at the same time as a
 
   expect(trans('nested/cars/car.is_electric')).toBe('É elétrico?');
   expect(trans('nested/cars/car.foo.level1.level2')).toBe('barpt');
+})
+
+it('does not translate existing strings which contain delimiter symbols', async () => {
+  await global.mountPlugin()
+
+  expect(trans('Start/end')).toBe('Início/Fim');
+  expect(trans('Get started.')).toBe('Comece.');
 })
\ No newline at end of file
Repository: go-kratos/kratos
Pull request #2648 (2023-02-03 07:44:16)

chore: clean up deprecated code
#### Description (what this PR does / why we need it):
clean up deprecated code

#### Which issue(s) this PR fixes (resolves / be part of):
NONE

#### Other special notes for the reviewers:
NONE


Patch:
diff --git a/middleware/recovery/recovery.go b/middleware/recovery/recovery.go
index dfa7cb7f..66dcec18 100644
--- a/middleware/recovery/recovery.go
+++ b/middleware/recovery/recovery.go
@@ -29,12 +29,6 @@ func WithHandler(h HandlerFunc) Option {
 	}
 }
 
-// WithLogger with recovery logger.
-// Deprecated: use global logger instead.
-func WithLogger(logger log.Logger) Option {
-	return func(o *options) {}
-}
-
 // Recovery is a server middleware that recovers from any panics.
 func Recovery(opts ...Option) middleware.Middleware {
 	op := options{


Test patch:
diff --git a/middleware/recovery/recovery_test.go b/middleware/recovery/recovery_test.go
index 985cb19b..cf4a7fbb 100644
--- a/middleware/recovery/recovery_test.go
+++ b/middleware/recovery/recovery_test.go
@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/go-kratos/kratos/v2/errors"
-	"github.com/go-kratos/kratos/v2/log"
 )
 
 func TestOnce(t *testing.T) {
@@ -35,8 +34,3 @@ func TestNotPanic(t *testing.T) {
 		t.Errorf("e isn't nil")
 	}
 }
-
-// Deprecated: Remove this test with WithLogger method.
-func TestWithLogger(t *testing.T) {
-	_ = WithLogger(log.DefaultLogger)
-}