syntaxe - Comment briser une chaîne en YAML sur plusieurs lignes

Mots clés : stringsyntaxyamlnewlinestring

meilleur 5 Réponses syntaxe - Comment briser une chaîne en YAML sur plusieurs lignes

vote vote

93

  key: >     Your long     string here. 
  key: |     ### Heading      * Bullet     * Points 
  key: "Antidisestab\    lishmentarianism.\n\nGet on it." 
Key: >   this is my very very very   long string 
Key: |   this is my very very very    long string 
Key: this is my very very very    long string 
Key: "this is my very very \"very\" loooo\   ng string.\n\nLove, YAML." 
Key: 'this is my very very "very"   long string, isn''t it.' 
- >8         My long string         starts over here - |+1  This one  starts here 
- >     my long       string                          many spaces above - my long       string                          many spaces above      
- >   very "long"   'string' with    paragraph gap, \n and           spaces. - |    very "long"   'string' with    paragraph gap, \n and           spaces. - very "long"   'string' with    paragraph gap, \n and           spaces. - "very \"long\"   'string' with    paragraph gap, \n and           s\   p\   a\   c\   e\   s." - 'very "long"   ''string'' with    paragraph gap, \n and           spaces.' - >-    very "long"   'string' with    paragraph gap, \n and           spaces.  [   "very \"long\" 'string' with\nparagraph gap, \\n and         spaces.\n",    "very \"long\"\n'string' with\n\nparagraph gap, \\n and        \nspaces.\n",    "very \"long\" 'string' with\nparagraph gap, \\n and spaces.",    "very \"long\" 'string' with\nparagraph gap, \n and spaces.",    "very \"long\" 'string' with\nparagraph gap, \\n and spaces.",    "very \"long\" 'string' with\nparagraph gap, \\n and         spaces." ] 
vote vote

80

Key: >   This is a very long sentence   that spans several lines in the YAML   but which will be rendered as a string   with only a single carriage return appended to the end. 
Key: >-   This is a very long sentence   that spans several lines in the YAML   but which will be rendered as a string   with NO carriage returns. 
vote vote

80

|   This is a very long sentence   that spans several lines in the YAML   but which will be rendered as a string   with newlines preserved. 
vote vote

63

--- # Note: It has 1 new line after the string content:     Arbitrary free text     over multiple lines stopping     after indentation changes...  ... 
{  "content": "Arbitrary free text over multiple lines stopping after indentation changes..." } 
--- # After string we have 2 spaces and 2 new lines content1: |  Arbitrary free text  over "multiple lines" stopping  after indentation changes...     ... 
{  "content1": "Arbitrary free text\nover \"multiple lines\" stopping\nafter indentation changes...  \n" } 
--- # After string we have 2 new lines plain: |+  This unquoted scalar  spans many lines.   ... 
{  "plain": "This unquoted scalar\nspans many lines.\n\n\n" } 
--- # After string we have 2 new lines plain: |-  This unquoted scalar  spans many lines.   ... 
{  "plain": "This unquoted scalar\nspans many lines." } 
--- folded_newlines: >  this is really a  single line of text  despite appearances   ... 
{  "fold_newlines": "this is really a single line of text despite appearances\n" } 
vote vote

56

key: "Loremipsumdolorsitamet,consecteturadipiscingelit,seddoeiusmodtemp\   orincididuntutlaboreetdoloremagnaaliqua." 

Questions similaires