ci/github-script/commits: keep formatting for diffs of markdown blocks
Previously, when the diff contained a context line with ```, this would end the code block and entirely break the markdown rendering. Now we use the html code blocks provided by `core.summary` and properly escape the content, so that it never escapes via html tags.
This commit is contained in:
parent
40dcbb1483
commit
b19798c8b0
@ -179,9 +179,14 @@ module.exports = async function ({ github, context, core }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.summary.addRaw('<details><summary>Show diff</summary>')
|
core.summary.addRaw('<details><summary>Show diff</summary>')
|
||||||
core.summary.addRaw('\n\n```diff', true)
|
core.summary.addCodeBlock(
|
||||||
core.summary.addRaw(truncated.join('\n'), true)
|
truncated
|
||||||
core.summary.addRaw('```', true)
|
.join('\n')
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>'),
|
||||||
|
'diff',
|
||||||
|
)
|
||||||
core.summary.addRaw('</details>')
|
core.summary.addRaw('</details>')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user