Skip to content

Commit

Permalink
Merge pull request github#30742 from github/repo-sync
Browse files Browse the repository at this point in the history
Repo sync
  • Loading branch information
docs-bot authored Dec 18, 2023
2 parents 1e2e8eb + b83afd5 commit 7c2698b
Show file tree
Hide file tree
Showing 6 changed files with 293 additions and 243 deletions.
2 changes: 1 addition & 1 deletion data/secret-scanning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@
isPublic: true
isPrivateWithGhas: true
hasPushProtection: true
hasValidityCheck: false
hasValidityCheck: '{% ifversion fpt or ghes %}false{% else %}true{% endif %}'

- provider: 'Duffel'
supportedSecret: 'Duffel Live Access Token'
Expand Down
40 changes: 39 additions & 1 deletion src/content-render/liquid/tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,45 @@ import { allPlatforms } from '#src/tools/lib/all-platforms.js'

export const tags = Object.keys(allTools).concat(allPlatforms).concat(['rowheaders'])

const template = '<div class="ghd-tool {{ tagName }}">{{ output }}</div>'
// The trailing newline is important. Without it, the line immediately after
// the `</div>` will be considered part of the previous block, which means the Markdown following the `</div>` will not be rendered to HTML correctly. For example:
//
// <div>Here's some stuff</div>
// And *here* us also some stuff.
//
// Another **sentence** here.
//
// Will yield:
//
// <div>Here's some stuff</div>
// And *here* us also some stuff.
//
// <p>Another <b>sentence</b> here.</p>
//
// when rendering this template with unified.
// If you instead inject an extra newline after the `</div>`, you
// go from:
//
// <div>Here's some stuff</div>
//
// And *here* us also some stuff.
//
// Another **sentence** here.
//
// which yields:
//
// <div>Here's some stuff</div>
//
// <p>And <i>here</i> us also some stuff.</p>
//
// <p>Another <b>sentence</b> here.</p>
//
// The Tool Liquid tags are a little bit fragile because we hope and assume
// that the author of the Liquid+Markdown *don't* do this:
//
// {% vscode %}Bla bla.{% endvscode %}Next stuff here...
//
const template = '<div class="ghd-tool {{ tagName }}">{{ output }}</div>\n'

export const Tool = {
type: 'block',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,11 @@ Bla bla
`linux` specific content.

{% endlinux %}

## Misc testing

{% linux %}
It's important to test that immediately after the end tag, the Markdown
there renders to HTML.
{% endlinux %}
On *this* line is `Markdown` too.
11 changes: 11 additions & 0 deletions src/fixtures/tests/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ describe('misc Liquid', () => {
expect(texts[0]).toBe(url)
expect(texts[1]).toBe('Pricing')
})

test('page with tool Liquid tag followed by Markdown', async () => {
// This test tests Markdown being correctly rendered when the
// Markdown directly follows a tool tag like `{% linux %}...{% endlinux %}`.
// The next line immediately after the `{% endlinux %}` should not
// leave the Markdown unrendered
const $ = await getDOM('/get-started/liquid/tool-platform-switcher')
const innerHTML = $('#article-contents').html()
expect(innerHTML).not.toMatch('On *this* line is `Markdown` too.')
expect(innerHTML).toMatch('<p>On <em>this</em> line is <code>Markdown</code> too.</p>')
})
})

describe('data tag', () => {
Expand Down
Loading

0 comments on commit 7c2698b

Please sign in to comment.