Skip to content

Commit

Permalink
feat: integrate rspress
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Sep 21, 2023
1 parent bf741d4 commit 3884128
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions crates/plugin_code_block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn transform_pre_code_element(node: &mut hast::Node) {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-code-title".into()]),
hast::PropertyValue::SpaceSeparated(vec!["rspress-code-title".into()]),
)],
children: vec![hast::Node::Text(hast::Text {
value: title.to_string(),
Expand All @@ -66,7 +66,7 @@ fn transform_pre_code_element(node: &mut hast::Node) {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-code-content".into()]),
hast::PropertyValue::SpaceSeparated(vec!["rspress-code-content".into()]),
)],
children: vec![hast::Node::Element(hast::Element {
tag_name: "pre".into(),
Expand Down Expand Up @@ -122,8 +122,8 @@ pub fn mdx_plugin_code_block(root: &mut hast::Node) {
// </pre>
// Will be transformed to:
// <div className="language-jsx">
// <div className="modern-code-title">title</div>
// <div className="modern-code-content">
// <div className="rspress-code-title">title</div>
// <div className="rspress-code-content">
// <pre>
// <code className="language-jsx">
// <p>hello world</p>
Expand Down Expand Up @@ -178,7 +178,7 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-code-title".into()]),
hast::PropertyValue::SpaceSeparated(vec!["rspress-code-title".into()]),
)],
children: vec![hast::Node::Text(hast::Text {
value: "My-Rust-Code".into(),
Expand All @@ -190,7 +190,7 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-code-content".into()]),
hast::PropertyValue::SpaceSeparated(vec!["rspress-code-content".into()]),
)],
children: vec![hast::Node::Element(hast::Element {
tag_name: "pre".into(),
Expand Down
38 changes: 19 additions & 19 deletions crates/plugin_container/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn create_new_container_node(
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-title".into()]),
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-title".into()]),
)],
children: vec![hast::Node::Text(hast::Text {
value: title,
Expand All @@ -76,7 +76,7 @@ fn create_new_container_node(
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-content".into()]),
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-content".into()]),
)],
children: container_content.clone(),
position: None,
Expand All @@ -85,7 +85,7 @@ fn create_new_container_node(
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive".into(), container_type.into()]),
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive".into(), container_type.into()]),
)],
children: vec![
hast::Node::Element(container_title_node),
Expand Down Expand Up @@ -250,15 +250,15 @@ fn traverse_children(root: &mut hast::Root) {
pub fn mdx_plugin_container(root: &mut hast::Node) {
// Traverse children, get all p tags, check if they start with :::
// If it is, it is regarded as container syntax, and the content from the beginning of ::: to the end of a certain ::: is regarded as a container
// The element of this container is a div element, className is "modern-container"
// The element of this container is a div element, className is "rspress-container"
// for example:
// :::tip
// this is a tip
// :::
// Will be transformed to:
// <div class="modern-container">
// <div class="modern-container-title">tip</div>
// <div class="modern-container-content">
// <div class="rspress-container">
// <div class="rspress-container-title">tip</div>
// <div class="rspress-container-content">
// <p>This is a tip</p>
// </div>
// </div>
Expand Down Expand Up @@ -405,14 +405,14 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive".into(), "tip".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive".into(), "tip".into()])
),],
children: vec![
hast::Node::Element(hast::Element {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-title".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-title".into()])
)],
children: vec![hast::Node::Text(hast::Text {
value: "Note".into(),
Expand All @@ -424,7 +424,7 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-content".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-content".into()])
)],
children: vec![hast::Node::Element(hast::Element {
tag_name: "p".into(),
Expand Down Expand Up @@ -489,14 +489,14 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive".into(), "tip".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive".into(), "tip".into()])
),],
children: vec![
hast::Node::Element(hast::Element {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-title".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-title".into()])
)],
children: vec![hast::Node::Text(hast::Text {
value: "TIP".into(),
Expand All @@ -508,7 +508,7 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-content".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-content".into()])
)],
children: vec![hast::Node::Element(hast::Element {
tag_name: "p".into(),
Expand Down Expand Up @@ -573,14 +573,14 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive".into(), "tip".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive".into(), "tip".into()])
),],
children: vec![
hast::Node::Element(hast::Element {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-title".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-title".into()])
)],
children: vec![hast::Node::Text(hast::Text {
value: "Note".into(),
Expand All @@ -592,7 +592,7 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-content".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-content".into()])
)],
children: vec![hast::Node::Element(hast::Element {
tag_name: "p".into(),
Expand Down Expand Up @@ -654,14 +654,14 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive".into(), "tip".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive".into(), "tip".into()])
),],
children: vec![
hast::Node::Element(hast::Element {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-title".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-title".into()])
)],
children: vec![hast::Node::Text(hast::Text {
value: "TIP".into(),
Expand All @@ -673,7 +673,7 @@ mod tests {
tag_name: "div".into(),
properties: vec![(
"className".into(),
hast::PropertyValue::SpaceSeparated(vec!["modern-directive-content".into()])
hast::PropertyValue::SpaceSeparated(vec!["rspress-directive-content".into()])
)],
children: vec![hast::Node::MdxJsxElement(hast::MdxJsxElement {
name: Some("Rspack".into()),
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@modern-js/mdx-rs-binding",
"description": "MDX compilation binding for Modern.js",
"version": "0.2.8",
"name": "@rspress/mdx-rs-binding",
"description": "MDX compilation binding for Rspress",
"version": "0.3.0",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down

0 comments on commit 3884128

Please sign in to comment.