how to extract markdown from yml with the original formatting

56 Views Asked by At

i have some yml file, the remark entity contains markdown, how do I achieve successful data extraction from remark with the original string formatting.

Structure of yaml

test.yml

remark: "iljoijhoijhoiho pojpojpoij ohouihoui hp[oipoi
oiiohoihjoijh [p[pik[ [oi[p

kughkughiupokjpoj uiohgiuoh poipojk kpoip 

ouiyioyh[pop[uouypoipoikoiuo

"

my code

import yml
import pypandoc

content = yml.load('test.yml')

remark = content.get('remark', None)

text = pypandoc.convert_text(remark, 'rst', format='md')

print(text)

I expect a similar output as in the source file, but I get the wrong one

Output:

 iljoijhoijhoiho pojpojpoij ohouihoui hp[oipoi oiiohoihjoijh [p[pik[ [oi[p
kughkughiupokjpoj uiohgiuoh poipojk kpoip
ouiyioyh[pop[uouypoipoikoiuo
| heading 1 | heading 3 | heading 2 | |------------|------------|------------| | string 1,1 | string 1,3 | string 1,2 | | string 2,1 | string 2,3 | string 2,2 | | string 3,1 | string 3,3 | string 3,2 | 
1

There are 1 best solutions below

0
On

The answer to my question was: To write multiline values in YAML, you can use a special format called a "literal block". Literal blocks start with the | or > character and allow you to insert multi-line strings without having to escape special characters.About