mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 19:17:09 +03:00
Merge pull request #629 from pulsar-edit/markdown-preview/fix-yaml-frontmatter
[markdown-preview]: Support for nested table objects in Yaml Frontmatter
This commit is contained in:
commit
76e358bc60
@ -107,7 +107,14 @@ function renderYamlTable (variables) {
|
||||
const markdownRows = [
|
||||
entries.map(entry => entry[0]),
|
||||
entries.map(entry => '--'),
|
||||
entries.map(entry => entry[1])
|
||||
entries.map((entry) => {
|
||||
if (typeof entry[1] === "object" && !Array.isArray(entry[1])) {
|
||||
// Remove all newlines, or they ruin formatting of parent table
|
||||
return marked.parse(renderYamlTable(entry[1])).replace(/\n/g,"");
|
||||
} else {
|
||||
return entry[1];
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
return (
|
||||
|
@ -15,7 +15,7 @@
|
||||
"fs-plus": "^3.0.0",
|
||||
"marked": "5.0.3",
|
||||
"underscore-plus": "^1.0.0",
|
||||
"yaml-front-matter": "^4.0.0"
|
||||
"yaml-front-matter": "^4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"temp": "^0.8.1"
|
||||
|
@ -3,6 +3,8 @@ variable1: value1
|
||||
array:
|
||||
- foo
|
||||
- bar
|
||||
object:
|
||||
key: value2
|
||||
---
|
||||
|
||||
## File.markdown
|
||||
|
@ -338,12 +338,12 @@ end\
|
||||
[...preview.element.querySelectorAll('table th')].map(
|
||||
el => el.textContent
|
||||
)
|
||||
).toEqual(['variable1', 'array'])
|
||||
).toEqual(['variable1', 'array', 'object', 'key'])
|
||||
expect(
|
||||
[...preview.element.querySelectorAll('table td')].map(
|
||||
el => el.textContent
|
||||
)
|
||||
).toEqual(['value1', 'foo,bar'])
|
||||
).toEqual(['value1', 'foo,bar', 'keyvalue2', 'value2'])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user