Skip to content

Stringify: Is it possible to overwrite the type of specific elements? #365

Closed Answered by eemeli
Kirdock asked this question in Q&A
Discussion options

You must be logged in to vote

Yes. You'll need to first construct a Document from your JS value, and then set the type of the appropriate node. This is how it looks like with yaml@next:

import { Document } from 'yaml'
const doc = new Document({ name: 'myName', freeText: 'this is my free text\n' })
doc.get('freeText', true).type = 'BLOCK_FOLDED'
doc.toString()
name: myName
freeText: >
  this is my free text

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kirdock
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