Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix padded code (text) in mdast #123

Merged
merged 3 commits into from
Aug 13, 2024
Merged

Fix padded code (text) in mdast #123

merged 3 commits into from
Aug 13, 2024

Conversation

yshavit
Copy link
Contributor

@yshavit yshavit commented Aug 11, 2024

Strip one space from the beginning and end of InlineCode if (a) the value starts and ends with a space and (b) is not all spaces.

From CommonMark spec section 6.1:

If the resulting string both begins and ends with a space character, but does not consist entirely of space characters, a single space character is removed from the front and back.

Resolves #122

The offsets are still TODO to verify and possibly fix.
@wooorm
Copy link
Owner

wooorm commented Aug 12, 2024

whether this should apply to all inline code text, or just `

How do you mean? Isn’t all “inline code” / “code (text)” with `?

whether I should adjust the position fields (and if so, which? all of them, or just the *_offsets?) to account for the stripping the spaces

I don’t think that’s needed. Positional info represents the whole, which includes the backticks too. So the spaces have no effect on it.

apologies if this PR is not the appropriate way to do that!

This is great! Thank you!

@yshavit
Copy link
Contributor Author

yshavit commented Aug 12, 2024

whether this should apply to all inline code text, or just `

How do you mean? Isn’t all “inline code” / “code (text)” with `?

I think this the raw_text also covers $$, but I'm not 100% — I haven't tested it out yet. And I'm also not sure whether $$ also requires stripping the space.

whether I should adjust the position fields (and if so, which? all of them, or just the *_offsets?) to account for the stripping the spaces

I don’t think that’s needed. Positional info represents the whole, which includes the backticks too. So the spaces have no effect on it.

Awesome, thanks! That makes it easy.

apologies if this PR is not the appropriate way to do that!

This is great! Thank you!

Glad to hear it! 😁

Unfortunately, I won't be able to get to it until later tonight (US east coast), but I'm guessing there's no urgency on this from your end. :-)

@wooorm
Copy link
Owner

wooorm commented Aug 12, 2024

$, as in math, has no standard. I intentionally here use the exact same working of ` for $. So 👍 to same workings for both.

No urgency from me! I really appreciate you helping!

@yshavit
Copy link
Contributor Author

yshavit commented Aug 12, 2024

Ah, if they intentionally work the same, then perhaps this PR is ready to go? I'll go ahead and mark it as "ready for review" and subject it to full critique! :-)

@yshavit yshavit marked this pull request as ready for review August 12, 2024 14:46
src/to_mdast.rs Outdated Show resolved Hide resolved
@wooorm wooorm changed the title repro and fix for stripping spaces in inline code Fix padded code repro and fix for stripping spaces in inline code Aug 13, 2024
@wooorm wooorm changed the title Fix padded code repro and fix for stripping spaces in inline code Fix padded code (text) in mdast Aug 13, 2024
@wooorm wooorm merged commit 6144c58 into wooorm:main Aug 13, 2024
3 checks passed
@wooorm
Copy link
Owner

wooorm commented Aug 13, 2024

Thanks Yuval! Released!!

@yshavit
Copy link
Contributor Author

yshavit commented Aug 13, 2024

Awesome, thanks so much!

renovate bot referenced this pull request in oxc-project/oxc Aug 19, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [indexmap](https://togithub.com/indexmap-rs/indexmap) |
workspace.dependencies | minor | `2.3.0` -> `2.4.0` |
| [markdown](https://togithub.com/wooorm/markdown-rs) | dev-dependencies
| patch | `1.0.0-alpha.19` -> `1.0.0-alpha.20` |
| [serde](https://serde.rs)
([source](https://togithub.com/serde-rs/serde)) | workspace.dependencies
| patch | `1.0.206` -> `1.0.208` |
| [serde_json](https://togithub.com/serde-rs/json) |
workspace.dependencies | patch | `1.0.124` -> `1.0.125` |
| [tokio](https://tokio.rs)
([source](https://togithub.com/tokio-rs/tokio)) | workspace.dependencies
| patch | `1.39.2` -> `1.39.3` |
| [wasm-bindgen](https://rustwasm.github.io/)
([source](https://togithub.com/rustwasm/wasm-bindgen)) |
workspace.dependencies | patch | `0.2.92` -> `0.2.93` |

---

### Release Notes

<details>
<summary>indexmap-rs/indexmap (indexmap)</summary>

###
[`v2.4.0`](https://togithub.com/indexmap-rs/indexmap/blob/HEAD/RELEASES.md#240)

[Compare
Source](https://togithub.com/indexmap-rs/indexmap/compare/2.3.0...2.4.0)

- Added methods `IndexMap::append` and `IndexSet::append`, moving all
items from
one map or set into another, and leaving the original capacity for
reuse.

</details>

<details>
<summary>wooorm/markdown-rs (markdown)</summary>

###
[`v1.0.0-alpha.20`](https://togithub.com/wooorm/markdown-rs/releases/tag/1.0.0-alpha.20)

[Compare
Source](https://togithub.com/wooorm/markdown-rs/compare/1.0.0-alpha.19...1.0.0-alpha.20)

- [`6144c58`](https://togithub.com/wooorm/markdown-rs/commit/6144c58)
Fix padded code (text) in mdast
by [@&#8203;yshavit](https://togithub.com/yshavit) in
[https://github.com/wooorm/markdown-rs/pull/123](https://togithub.com/wooorm/markdown-rs/pull/123)

**Full Changelog**:
wooorm/markdown-rs@1.0.0-alpha.19...1.0.0-alpha.20

</details>

<details>
<summary>serde-rs/serde (serde)</summary>

###
[`v1.0.208`](https://togithub.com/serde-rs/serde/releases/tag/v1.0.208)

[Compare
Source](https://togithub.com/serde-rs/serde/compare/v1.0.207...v1.0.208)

- Support serializing and deserializing unit structs in a `flatten`
field ([#&#8203;2802](https://togithub.com/serde-rs/serde/issues/2802),
thanks [@&#8203;jonhoo](https://togithub.com/jonhoo))

###
[`v1.0.207`](https://togithub.com/serde-rs/serde/releases/tag/v1.0.207)

[Compare
Source](https://togithub.com/serde-rs/serde/compare/v1.0.206...v1.0.207)

- Improve interactions between `flatten` attribute and
`skip_serializing`/`skip_deserializing`
([#&#8203;2795](https://togithub.com/serde-rs/serde/issues/2795), thanks
[@&#8203;Mingun](https://togithub.com/Mingun))

</details>

<details>
<summary>serde-rs/json (serde_json)</summary>

###
[`v1.0.125`](https://togithub.com/serde-rs/json/releases/tag/1.0.125)

[Compare
Source](https://togithub.com/serde-rs/json/compare/v1.0.124...1.0.125)

- Speed up \uXXXX parsing and improve handling of unpaired surrogates
when deserializing to bytes
([#&#8203;1172](https://togithub.com/serde-rs/json/issues/1172),
[#&#8203;1175](https://togithub.com/serde-rs/json/issues/1175), thanks
[@&#8203;purplesyringa](https://togithub.com/purplesyringa))

</details>

<details>
<summary>tokio-rs/tokio (tokio)</summary>

###
[`v1.39.3`](https://togithub.com/tokio-rs/tokio/releases/tag/tokio-1.39.3):
Tokio v1.39.3

[Compare
Source](https://togithub.com/tokio-rs/tokio/compare/tokio-1.39.2...tokio-1.39.3)

### 1.39.3 (August 17th, 2024)

This release fixes a regression where the unix socket api stopped
accepting the abstract socket namespace. ([#&#8203;6772])

[#&#8203;6772]: https://togithub.com/tokio-rs/tokio/pull/6772

</details>

<details>
<summary>rustwasm/wasm-bindgen (wasm-bindgen)</summary>

###
[`v0.2.93`](https://togithub.com/rustwasm/wasm-bindgen/blob/HEAD/CHANGELOG.md#0293)

[Compare
Source](https://togithub.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93)

Released 2024-08-13

##### Added

- Allow exporting functions named `default`. Throw error in
wasm-bindgen-cli if --target web and
    an exported symbol is named `default`.
    [#&#8203;3930](https://togithub.com/rustwasm/wasm-bindgen/pull/3930)

- Added support for arbitrary expressions when using
`#[wasm_bindgen(typescript_custom_section)]`.
    [#&#8203;3901](https://togithub.com/rustwasm/wasm-bindgen/pull/3901)

-   Implement `From<NonNull<T>>` for `JsValue`.
    [#&#8203;3877](https://togithub.com/rustwasm/wasm-bindgen/pull/3877)

- Add method `copy_within` for TypedArray, add methods
`find_last`,`find_last_index` for Array.
    [#&#8203;3888](https://togithub.com/rustwasm/wasm-bindgen/pull/3888)

-   Added support for returning `Vec`s from async functions.
    [#&#8203;3630](https://togithub.com/rustwasm/wasm-bindgen/pull/3630)

-   Added bindings for `InputDeviceInfo` and `MediaTrackCapabilities`.
    [#&#8203;3935](https://togithub.com/rustwasm/wasm-bindgen/pull/3935)

-   Add bindings for `RTCRtpReceiver.getCapabilities(DOMString)` method.
    [#&#8203;3941](https://togithub.com/rustwasm/wasm-bindgen/pull/3941)

-   Add bindings for `VisualViewport`.
    [#&#8203;3931](https://togithub.com/rustwasm/wasm-bindgen/pull/3931)

-   Add bindings for `queueMicrotask`.
    [#&#8203;3981](https://togithub.com/rustwasm/wasm-bindgen/pull/3981)

-   Add experimental bindings for User Agent Client Hints API
    [#&#8203;3989](https://togithub.com/rustwasm/wasm-bindgen/pull/3989)

-   Add bindings for `FocusOptions`.
    [#&#8203;3996](https://togithub.com/rustwasm/wasm-bindgen/pull/3996)

-   Add bindings for `RTCRtpReceiver.jitterBufferTarget`.
    [#&#8203;3968](https://togithub.com/rustwasm/wasm-bindgen/pull/3968)

-   Generate getters for all WebIDL dictionary types.
    [#&#8203;3993](https://togithub.com/rustwasm/wasm-bindgen/pull/3993)

- Support for iterable in WebIDL. Gives `entries`, `keys`, `values`
methods for regular and asynchronous, as well as `for_each` for regular,
iterables.
    [#&#8203;3962](https://togithub.com/rustwasm/wasm-bindgen/pull/3962)

-   Add bindings for `HTMLTableCellElement.abbr` and `scope` properties.
    [#&#8203;3972](https://togithub.com/rustwasm/wasm-bindgen/pull/3972)

-   Add WebIDL definitions relating to `Popover API`.
    [#&#8203;3977](https://togithub.com/rustwasm/wasm-bindgen/pull/3977)

- Added the `thread_stack_size` property to the object parameter of
`default()` (`init()`) and `initSync()`, making it possible to set the
stack size of spawned threads. `__wbindgen_thread_destroy()` now has a
third optional parameter for the stack size, the default stack size is
assumed when not passing it. When calling from the thread to be
destroyed, by passing no parameters, the correct stack size is
determined internally.
    [#&#8203;3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995)

-   Added bindings to the Device Memory API.
    [#&#8203;4011](https://togithub.com/rustwasm/wasm-bindgen/pull/4011)

- Added support for WebIDL records. This added new methods to various
APIs, notably `ClipboardItem()`, `GPUDeviceDescriptor.requiredLimits`
and `Header()`.
    [#&#8203;4030](https://togithub.com/rustwasm/wasm-bindgen/pull/4030)

- Added an official MSRV policy. Library MSRV changes will be
accompanied by a minor version bump. CLI tool MSRV can change with any
version bump.
    [#&#8203;4038](https://togithub.com/rustwasm/wasm-bindgen/pull/4038)

-   Added bindings to `NavigatorOptions.vibrate`.
    [#&#8203;4041](https://togithub.com/rustwasm/wasm-bindgen/pull/4041)

- Added an experimental Node.JS ES module target, in comparison the
current `node` target uses CommonJS, with `--target
experimental-nodejs-module` or when testing with
`wasm_bindgen_test_configure!(run_in_node_experimental)`.
    [#&#8203;4027](https://togithub.com/rustwasm/wasm-bindgen/pull/4027)

- Added importing strings as `JsString` through
`#[wasm_bindgen(thread_local, static_string)] static STRING: JsString =
"a string literal";`.
    [#&#8203;4055](https://togithub.com/rustwasm/wasm-bindgen/pull/4055)

- Added experimental test coverage support for
`wasm-bindgen-test-runner`, see the guide for more information.
    [#&#8203;4060](https://togithub.com/rustwasm/wasm-bindgen/pull/4060)

##### Changed

-   Stabilize Web Share API.
    [#&#8203;3882](https://togithub.com/rustwasm/wasm-bindgen/pull/3882)

- Generate JS bindings for WebIDL dictionary setters instead of using
`Reflect`. This increases the size of the Web API bindings but should be
more performant. Also, importing getters/setters from JS now supports
specifying the JS attribute name as a string, e.g.
`#[wasm_bindgen(method, setter = "x-cdm-codecs")]`.
    [#&#8203;3898](https://togithub.com/rustwasm/wasm-bindgen/pull/3898)

- Greatly improve the performance of sending WebIDL 'string enums'
across the JavaScript boundary by converting the enum variant string
to/from an int.
    [#&#8203;3915](https://togithub.com/rustwasm/wasm-bindgen/pull/3915)

-   Use `table.fill` when appropriate.
    [#&#8203;3446](https://togithub.com/rustwasm/wasm-bindgen/pull/3446)

-   Annotated methods in WebCodecs that throw.
    [#&#8203;3970](https://togithub.com/rustwasm/wasm-bindgen/pull/3970)

-   Update and stabilize the Clipboard API.
    [#&#8203;3992](https://togithub.com/rustwasm/wasm-bindgen/pull/3992)

- Deprecate builder-pattern type setters for WebIDL dictionary types and
introduce non-mutable setters instead.
    [#&#8203;3993](https://togithub.com/rustwasm/wasm-bindgen/pull/3993)

- Allow imported async functions to return any type that can be
converted from a `JsValue`.
    [#&#8203;3919](https://togithub.com/rustwasm/wasm-bindgen/pull/3919)

-   Update Web Authentication API to level 3.
    [#&#8203;4000](https://togithub.com/rustwasm/wasm-bindgen/pull/4000)

- Deprecate `AudioBufferSourceNode.onended` and
`AudioBufferSourceNode.stop()`.
    [#&#8203;4020](https://togithub.com/rustwasm/wasm-bindgen/pull/4020)

-   Increase default stack size for spawned threads from 1 to 2 MB.
    [#&#8203;3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995)

- Deprecated parameters to `default` (`init`) and `initSync` in favor of
an object.
    [#&#8203;3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995)

- Update `AbortSignal` and `AbortController` according to the WHATWG
specification.
    [#&#8203;4026](https://togithub.com/rustwasm/wasm-bindgen/pull/4026)

-   Update the Indexed DB API.
    [#&#8203;4027](https://togithub.com/rustwasm/wasm-bindgen/pull/4027)

- `UnwrapThrowExt for Result` now makes use of the required `Debug`
bound to display the error as well.
    [#&#8203;4035](https://togithub.com/rustwasm/wasm-bindgen/pull/4035)
    [#&#8203;4049](https://togithub.com/rustwasm/wasm-bindgen/pull/4049)

- MSRV of CLI tools bumped to v1.76. This does not affect libraries like
`wasm-bindgen`, `js-sys` and `web-sys`!
    [#&#8203;4037](https://togithub.com/rustwasm/wasm-bindgen/pull/4037)

- Filtered files in published crates, significantly reducing the package
size and notably excluding any bash files.
    [#&#8203;4046](https://togithub.com/rustwasm/wasm-bindgen/pull/4046)

- Deprecated `JsStatic` in favor of `#[wasm_bindgen(thread_local)]`,
which creates a `std::thread::LocalKey`. The syntax is otherwise the
same.
    [#&#8203;4057](https://togithub.com/rustwasm/wasm-bindgen/pull/4057)

- Removed `impl Deref for JsStatic` when compiling with
`cfg(target_feature = "atomics")`, which was unsound.
    [#&#8203;4057](https://togithub.com/rustwasm/wasm-bindgen/pull/4057)

-   Updated the WebGPU WebIDL to the current draft as of 2024-08-05.
    [#&#8203;4062](https://togithub.com/rustwasm/wasm-bindgen/pull/4062)

-   Use object URLs for linked modules without `--split-linked-modules`.
    [#&#8203;4067](https://togithub.com/rustwasm/wasm-bindgen/pull/4067)

##### Fixed

- Copy port from headless test server when using
`WASM_BINDGEN_TEST_ADDRESS`.
    [#&#8203;3873](https://togithub.com/rustwasm/wasm-bindgen/pull/3873)

-   Fix `catch` not being thread-safe.
    [#&#8203;3879](https://togithub.com/rustwasm/wasm-bindgen/pull/3879)

-   Fix MSRV compilation.
    [#&#8203;3927](https://togithub.com/rustwasm/wasm-bindgen/pull/3927)

-   Fix `clippy::empty_docs` lint.
    [#&#8203;3946](https://togithub.com/rustwasm/wasm-bindgen/pull/3946)

- Fix missing target features in module when enabling reference types or
multi-value transformation.
    [#&#8203;3967](https://togithub.com/rustwasm/wasm-bindgen/pull/3967)

-   Fixed Rust values getting GC'd while still borrowed.
    [#&#8203;3940](https://togithub.com/rustwasm/wasm-bindgen/pull/3940)

- Fixed Rust values not getting GC'd if they were created via. a
constructor.
    [#&#8203;3940](https://togithub.com/rustwasm/wasm-bindgen/pull/3940)

-   Fix triggering `clippy::mem_forget` lint in exported structs.
    [#&#8203;3985](https://togithub.com/rustwasm/wasm-bindgen/pull/3985)

-   Fix MDN links to static interface methods.
    [#&#8203;4010](https://togithub.com/rustwasm/wasm-bindgen/pull/4010)

-   Fixed Deno support.
    [#&#8203;3990](https://togithub.com/rustwasm/wasm-bindgen/pull/3990)

-   Fix `__wbindgen_thread_destroy()` ignoring parameters.
    [#&#8203;3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995)

- Fix `no_std` support and therefor compiling with `default-features =
false`.
    [#&#8203;4005](https://togithub.com/rustwasm/wasm-bindgen/pull/4005)

-   Fix byte order for big-endian platforms.
    [#&#8203;4015](https://togithub.com/rustwasm/wasm-bindgen/pull/4015)

- Allow ex/importing structs, functions and parameters named with raw
identifiers.
    [#&#8203;4025](https://togithub.com/rustwasm/wasm-bindgen/pull/4025)

-   Implement a more reliable way to detect the stack pointer.
    [#&#8203;4036](https://togithub.com/rustwasm/wasm-bindgen/pull/4036)

- `#[track_caller]` is now always applied on `UnwrapThrowExt` methods
when not targetting `wasm32-unknown-unknown`.
    [#&#8203;4042](https://togithub.com/rustwasm/wasm-bindgen/pull/4042)

- Fixed linked modules emitting snippet files when not using
`--split-linked-modules`.
    [#&#8203;4066](https://togithub.com/rustwasm/wasm-bindgen/pull/4066)

***

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mdast Inline code should strip prefix+suffix space
2 participants