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

slateToRemark produces empty string for inlineCode if bold or italic marks are used #145

Closed
ayanb1991 opened this issue Jun 10, 2023 · 3 comments · Fixed by #147
Closed
Assignees

Comments

@ayanb1991
Copy link

If I have a slate data structure as described below which is used for representing inlineCode, which is also bold or italic or both of them, slateToRemark produces empty string in output.

// slate data
const root = {type: "root", children:[{text: 'inline code', strong: true, emphasis: true}]}

To Reproduce

const processor = unified().use(slateToRemark);

// create root tree
const tree = {
  type: "root",
  children: {text: 'inline code', strong: true, emphasis: true},
};

const ast = processor.runSync(tree);
const markdown = toMarkdown(ast, {
  fences: true,
});

console.log(markdown)

Expected behavior
The markdown should output like

**`inline code`**

Additional context
Versions Used Are
"remark-slate-transformer": "^0.6.8"
"unified": "^10.1.2",
"slate": "0.88.1",

@inokawa
Copy link
Owner

inokawa commented Jun 10, 2023

It would be the same issue with #129.
Upgrade your remark-slate-transformer to 0.7.4.

@inokawa inokawa closed this as completed Jun 10, 2023
@inokawa inokawa mentioned this issue Jun 10, 2023
@ayanb1991
Copy link
Author

Not working. Its might be a different issue. Here are my test examples.

package.json

{
  "name": "slate",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "remark-parse": "^10.0.2",
    "remark-slate-transformer": "^0.7.4",
    "unified": "^10.1.2"
  }
}

index.js

import markdown from "remark-parse";
import { slateToRemark } from "remark-slate-transformer";
import { unified } from "unified";

const root = {
  type: "root",
  children: [
    {
      type: 'paragraph',
      // setting emphasis or strong to true outputs value as undefined
      children: [ { emphasis: true, inlineCode: true, text: 'code' } ]
    }
  ]
}

const processor = unified().use(markdown).use(slateToRemark);
const value3 = processor.runSync(root);
console.dir(value3, { depth: null });

output

{
  type: 'root',
  children: [
    {
      type: 'paragraph',
      children: [ { type: 'inlineCode', value: undefined } ]
    }
  ]
}

@inokawa
Copy link
Owner

inokawa commented Jun 11, 2023

@ayanb1991
Thank you for your reproduction!
It would be solved in 0.7.5.

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 a pull request may close this issue.

2 participants