Skip to content

Commit

Permalink
Merge pull request #174 from fty4/fix/vertical-bar-quote
Browse files Browse the repository at this point in the history
remove code-quote when vertical bar inside table
  • Loading branch information
Jamie-BitFlight authored Aug 11, 2022
2 parents e1451c8 + 53a8f23 commit d7cbdb4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ or use none, and instead use a `.ghadocs.json` file.
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------- | ------------ |
| **`action`** | The absolute or relative path to the `action.yml` file to read in from. | `action.yml` | **false** |
| **`readme`** | The absolute or relative path to the markdown output file that contains the formatting tokens within it. | `README.md` | **false** |
| **`owner`** | The GitHub Action repository owner. i.e: `bitflight-devops`|`your-gh-username` | | **false** |
| **`owner`** | The GitHub Action repository owner. i.e: <code>bitflight-devops</code>&#124;<code>your-gh-username</code> | | **false** |
| **`repo`** | The GitHub Action repository name. i.e: `github-action-readme-generator` | | **false** |
| **`save`** | Save the provided values in a `.ghadocs.json` file. This will update any existing `.ghadocs.json` file that is in place. | | **false** |
| **`pretty`** | Use `prettier` to pretty print the new README.md file | | **false** |
Expand Down
18 changes: 15 additions & 3 deletions dist/index.cjs

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion src/markdowner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,24 @@ export function ArrayOfArraysToMarkdownTable(providedTableContent: MarkdownArray
const idx = i > 1 ? i - 1 : 0;
const dataRow = tableContent[idx] as string[];
for (const [j] of row.entries()) {
const content = dataRow[col]?.replace(/\|/g, '&#124;').replace(/\n/, '<br />') ?? '';
let content = dataRow[col]?.replace(/\n/, '<br />') ?? '';

// vertical pipe has to be escaped in markdown table
if (content.includes('|')) {
content = content.replace(/\|/g, '&#124;');

// replace grave accents with <code> HTML element to resolve unicode character in markdown
let isClosingTag = false;
content.match(/`/g)?.forEach((match) => {
if (!isClosingTag) {
content = content.replace(match, '<code>');
} else {
content = content.replace(match, '</code>');
}
isClosingTag = !isClosingTag;
});
}

if (j % 2 === 1) {
if (i === 0) {
(markdownArrays[i] as string[])[j] = ` **${content}** `;
Expand Down

0 comments on commit d7cbdb4

Please sign in to comment.