Skip to content

Wrap untagged text #7

Answered by JiLiZART
arkhamvm asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @arkhamvm parser result your string as AST

[
  {
    "tag": "h2",
    "attrs": {},
    "content": [
      "Header",
      " ",
      "text"
    ]
  },
  "\\r\\nBefore",
  " ",
  "text\\r\\n",
  {
    "tag": "img",
    "attrs": {
      "src": "https://www.google.com/favicon.ico"
    },
    "content": null
  },
  "\\r\\nAfter",
  " ",
  "Text",
  "\n"
]

You can try transform this array by yourself, like this

import bbob from '@bbob/core'
import { render } from '@bbob/html'
import presetHTML5 from '@bbob/preset-html5'

const processed = bbob(presetHTML5()).process(`[h2]Header text[/h2]\r\nBefore text\r\n[img]https://www.google.com/favicon.ico[/img]\r\nAfter Text`, { render })

const myTree =

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by JiLiZART
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #7 on December 10, 2020 20:43.