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

Support fror code blocks #2

Closed
chekos opened this issue Jan 26, 2022 · 3 comments
Closed

Support fror code blocks #2

chekos opened this issue Jan 26, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@chekos
Copy link
Owner

chekos commented Jan 26, 2022

Code blocks seem to be more or less the same as other, as I've been calling, "text-y" blocks. Except they include a "language" property after the list of rich text objects (still within the block[_type] property.

{
  "type": "code",
  //...other keys excluded
  "code": {
    "text": [{
      "type": "text",
      "text": {
        "content": "const a = 3"
      }
    }],
    "language": "javascript"
  }
}

Option 1

Maybe this is as simple as "enclosing" md_text by "```" and grabbing the "language"

md_text = f"```{block[_type]['language']}\n{md_text}\n```"
@chekos chekos added the enhancement New feature or request label Jan 26, 2022
@chekos
Copy link
Owner Author

chekos commented Jan 26, 2022

md_text is actually executed/built for each text-rich object in the block and is appended to text_chunks list.

a quick solution is to append "\n```" at the end of text_chunks and "```{language}\n```" at the beginning.

right now, there is logic for the heading_* blocks before the text_chunks are calculated.

Option 1

To not change heading block logic we can .insert(0, "```{language}\n") and .append("\n```") to the text_chunks

@chekos
Copy link
Owner Author

chekos commented Jan 26, 2022

Code block's rich-text objects don't have annotations - just text so the logic needs to be changed around the text_chunks for-loop.

@chekos
Copy link
Owner Author

chekos commented Jan 26, 2022

actually...
it seems like code block rich-text objects include annotations just like any other rich-text object...

@chekos chekos closed this as completed in 06d88f0 Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant