From 1bc2637e0579e57a2afebe03fd34bfbbb990d9e5 Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Thu, 2 Mar 2023 21:21:04 +0100 Subject: [PATCH 1/2] feat: support multi-line Basic support for multi-line. YAML multi-line strings a converted to a single line for the tables. --- __tests__/fixtures/action.yml | 12 ++++++++++-- __tests__/fixtures/default.output | 3 ++- src/action-docs.ts | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/__tests__/fixtures/action.yml b/__tests__/fixtures/action.yml index 32670bb5..87940b82 100644 --- a/__tests__/fixtures/action.yml +++ b/__tests__/fixtures/action.yml @@ -4,7 +4,15 @@ author: 'Niek Palm' inputs: inputA: required: false - description: 'A description' + description: | + A description + This is a multiline description + default: test + inputB: + required: false + description: | + This is a + multiline description default: test outputs: @@ -13,4 +21,4 @@ outputs: runs: using: 'node12' - main: 'dist/index.js' \ No newline at end of file + main: 'dist/index.js' diff --git a/__tests__/fixtures/default.output b/__tests__/fixtures/default.output index d0be2851..c4723193 100644 --- a/__tests__/fixtures/default.output +++ b/__tests__/fixtures/default.output @@ -6,7 +6,8 @@ Default test | parameter | description | required | default | | --- | --- | --- | --- | -| inputA | A description | `false` | test | +| inputA | A description This is a multiline description | `false` | test | +| inputB | This is a multiline description | `false` | test | ## Outputs diff --git a/src/action-docs.ts b/src/action-docs.ts index 889140b8..ae9e09dd 100644 --- a/src/action-docs.ts +++ b/src/action-docs.ts @@ -69,10 +69,13 @@ function createMdTable( let result = ""; + let abc = "abc\ndef\n"; + // remove inner line br + for (const line of tableArray) { result = `${result}|`; for (const c of line) { - result = `${result} ${c} |`; + result = `${result} ${c.replace(/(\r\n|\n|\r)/gm, " ")} |`; } result = `${result}${getLineBreak(options.lineBreaks)}`; } From 9587fc2271e9e80316fdf08b634da6e6c97d9b47 Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Thu, 2 Mar 2023 21:23:38 +0100 Subject: [PATCH 2/2] cleanup --- src/action-docs.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/action-docs.ts b/src/action-docs.ts index ae9e09dd..4d824b09 100644 --- a/src/action-docs.ts +++ b/src/action-docs.ts @@ -69,9 +69,6 @@ function createMdTable( let result = ""; - let abc = "abc\ndef\n"; - // remove inner line br - for (const line of tableArray) { result = `${result}|`; for (const c of line) {